Skip to content

fix: start tracing only if enabled and endpoint exists#884

Merged
ferhatelmas merged 1 commit intomasterfrom
ferhat/otel-tracing-endpoint-case
Mar 3, 2026
Merged

fix: start tracing only if enabled and endpoint exists#884
ferhatelmas merged 1 commit intomasterfrom
ferhat/otel-tracing-endpoint-case

Conversation

@ferhatelmas
Copy link
Member

@ferhatelmas ferhatelmas commented Mar 3, 2026

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

If tracing is enabled but endpoint is missing, instrumentation will start but won't export anything. Pure overhead.

What is the new behavior?

Start tracing only if enabled and exporter endpoint is given.

Additional context

None

@ferhatelmas ferhatelmas requested a review from a team as a code owner March 3, 2026 13:02
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9c044 and 7b7fc02.

📒 Files selected for processing (1)
  • src/internal/monitoring/otel-tracing.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Tracing now initializes only when fully configured, preventing partial startup when exporter is missing.
    • Added warnings when tracing is enabled but no exporter/endpoint is configured.
    • Startup reliability improved by ensuring tracing processors and SDK start only when all required tracing components are present.

Walkthrough

The change tightens OpenTelemetry tracing initialization: span processors are only created when a trace exporter exists (BatchSpanProcessor is instantiated inline alongside TenantSpanProcessor), and the SDK is started only if tracing is enabled, a trace exporter is configured, and at least one span processor is present. If tracing is enabled but no OTLP endpoint/trace exporter is configured, a warning is logged and SDK startup is skipped.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Tracing Config
    participant Logger as Logger
    participant Exporter as TraceExporter
    participant Processors as SpanProcessors
    participant SDK as Tracing SDK

    Config->>Logger: Read tracingEnabled
    alt tracingEnabled = false
        Config->>Logger: Do not initialize tracing
    else tracingEnabled = true
        Config->>Exporter: Check for traceExporter (OTLP endpoint)
        alt traceExporter exists
            Exporter->>Processors: Create TenantSpanProcessor
            Exporter->>Processors: Create BatchSpanProcessor (inline)
            Processors->>SDK: Provide configured span processors
            SDK->>SDK: Start SDK
            SDK-->>Logger: Tracing started
        else no traceExporter
            Logger-->>Config: Log warning (tracing enabled but no exporter)
            Config->>SDK: Skip SDK startup
        end
    end
Loading

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
@ferhatelmas ferhatelmas force-pushed the ferhat/otel-tracing-endpoint-case branch from 2e9c044 to 7b7fc02 Compare March 3, 2026 14:18
@ferhatelmas ferhatelmas merged commit f1b896b into master Mar 3, 2026
2 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/otel-tracing-endpoint-case branch March 3, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants