fix: correctly disable the sdk sampling when no endpoint is defined#1865
fix: correctly disable the sdk sampling when no endpoint is defined#1865
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 34 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughOpenTelemetry instrumentation configuration was refactored to replace conditional span processor assembly with fixed BatchSpanProcessor configuration, introduce sampling control via AlwaysOnSampler/AlwaysOffSampler based on environment variables, and simplify debug logging gating. Server startup warm-up comments were clarified without functional changes. Changes
Possibly related PRs
Poem
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
Greptile SummaryThis PR fixes telemetry overhead when no OTLP endpoint is configured by switching from a conditionally-added Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[sdk.start] --> B{OTEL_EXPORTER_OTLP_ENDPOINT set?}
B -- yes --> C[AlwaysOnSampler\nspans recorded]
B -- no --> D[AlwaysOffSampler\nspans dropped]
C --> E[BatchSpanProcessor]
D --> E
E --> F[OTLPTraceExporter\nalways constructed]
F -- enabled=true --> G[HTTP POST to OTLP endpoint]
F -- enabled=false --> H[No spans reach exporter\n queue always empty]
Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/noop-spans" | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Updates ENSApi’s OpenTelemetry setup so tracing can be effectively disabled when OTEL_EXPORTER_OTLP_ENDPOINT is not provided, reducing span creation overhead in non-instrumented deployments.
Changes:
- Add an
enabledflag derived fromOTEL_EXPORTER_OTLP_ENDPOINTand use it to switch betweenAlwaysOnSampler/AlwaysOffSampler. - Refactor OTel debug logging toggle into a
debugboolean. - Simplify the startup cache-warming comment in the main server entrypoint.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/ensapi/src/lib/instrumentation/index.ts | Introduces endpoint-driven enable/disable behavior via sampler configuration and refactors tracing setup. |
| apps/ensapi/src/index.ts | Comment-only change clarifying cache warm-up at startup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 `@apps/ensapi/src/lib/instrumentation/index.ts`:
- Around line 27-33: The span processor and exporter (BatchSpanProcessor,
OTLPTraceExporter) are still being instantiated even when telemetry is disabled;
update the instrumentation setup so that when enabled is false you do not
construct BatchSpanProcessor/OTLPTraceExporter — e.g., build spanProcessors as
enabled ? [new BatchSpanProcessor(new OTLPTraceExporter(), {...})] : [] (or
undefined) while keeping sampler: enabled ? new AlwaysOnSampler() : new
AlwaysOffSampler(); this avoids allocating exporter/processor when
AlwaysOffSampler will drop all spans.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8f9cec9b-e57f-4173-bf17-f28b884858ed
📒 Files selected for processing (2)
apps/ensapi/src/index.tsapps/ensapi/src/lib/instrumentation/index.ts
OTEL_EXPORTER_OTLP_ENDPOINTdoesn't exist