docs: fix Datadog example -- correct endpoint, add required header and temporality env var#29
Conversation
📝 WalkthroughWalkthroughThe README.md documentation was updated to reflect current Datadog OTLP configuration best practices. The changes include a new endpoint URL, additional environment variable for authentication headers, metric temporality preference setting, and clarification notes regarding regional endpoint variants. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… temporality env var
f467f2f to
55e6439
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 157-158: Update the README recommendation to use OPENCODE_ prefix
for the temporality setting (replace
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE with
OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE in the example) and add handling in
src/config.ts to copy process.env.OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE
into process.env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE before SDK
initialization (follow the same pattern used for OPENCODE_OTLP_HEADERS and
OPENCODE_RESOURCE_ATTRIBUTES), ensuring the SDK sees the OTEL_* variable while
users configure the OPENCODE_* variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| # Required — Datadog's OTLP intake only accepts delta temporality | ||
| export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if config.ts handles OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE
# Search for temporality preference handling in config.ts
rg -n -A5 -B5 'TEMPORALITY|temporality' --glob 'src/config.ts'
# Also check if the variable is used directly in other files
rg -n 'OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE' --glob 'src/**/*.ts'Repository: DEVtheOPS/opencode-plugin-otel
Length of output: 56
🏁 Script executed:
# Check what config.ts actually looks like
fd 'config.ts' -t f && wc -l src/config.tsRepository: DEVtheOPS/opencode-plugin-otel
Length of output: 104
🏁 Script executed:
# Look for how OPENCODE_ variables are handled in config.ts
rg -n 'OPENCODE_' src/config.tsRepository: DEVtheOPS/opencode-plugin-otel
Length of output: 1072
🏁 Script executed:
# Check how OTEL_ variables are set/copied
rg -n 'OTEL_EXPORTER_OTLP' src/config.tsRepository: DEVtheOPS/opencode-plugin-otel
Length of output: 223
🏁 Script executed:
# Look at the full context of config.ts to understand the pattern
cat -n src/config.tsRepository: DEVtheOPS/opencode-plugin-otel
Length of output: 3264
Use OPENCODE_ prefix for plugin configuration variables.
The documentation instructs users to set OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE directly, but this violates the plugin's established design pattern. All plugin configuration must use the OPENCODE_ prefix (e.g., OPENCODE_OTLP_HEADERS, OPENCODE_RESOURCE_ATTRIBUTES, OPENCODE_OTLP_ENDPOINT), which are then copied to their OTEL_* equivalents before SDK initialization.
The temporality preference should follow this same pattern:
# User-facing configuration variable (OPENCODE_ prefix)
export OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE=deltaThen in src/config.ts, add handling to copy this to OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE before the SDK initializes (similar to the existing OPENCODE_OTLP_HEADERS and OPENCODE_RESOURCE_ATTRIBUTES handling).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 157 - 158, Update the README recommendation to use
OPENCODE_ prefix for the temporality setting (replace
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE with
OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE in the example) and add handling in
src/config.ts to copy process.env.OPENCODE_OTLP_METRICS_TEMPORALITY_PREFERENCE
into process.env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE before SDK
initialization (follow the same pattern used for OPENCODE_OTLP_HEADERS and
OPENCODE_RESOURCE_ATTRIBUTES), ensuring the SDK sees the OTEL_* variable while
users configure the OPENCODE_* variable.
Description
Impact: Anyone following the current Datadog example in the README will get zero metrics -- the endpoint is wrong, the auth header is missing, and the required temporality setting is undocumented.
Three issues fixed:
api.datadoghq.comis the REST API, not the OTLP intake. The correct endpoint isotlp.datadoghq.com(Datadog OTLP docs).dd-api-keyin the request headers.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta, the OTel SDK defaults to cumulative and Datadog silently drops the data (Datadog delta temporality guide, OTel spec). The JS SDK's OTLP exporter already reads this env var -- no code change needed.Also adds region guidance (EU, US3, etc.) with a link to the official docs.
Type of change
Checklist
bun run lintpasses with no errorsbun run check:jsdoc-coveragepasses with no errorsbun run typecheckpasses with no errorsbun testpasses with no errorsRelated issues
Discovered while integrating this plugin with Datadog's direct OTLP intake at
otlp.datadoghq.com.Summary by CodeRabbit