Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(observability): a malformed OTEL_RESOURCE_ATTRIBUTES no longer stops startup #13469

Mergedyordis(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/13469/headmerged by juliusmarminge View on GitHub

  • With OTLP export configured, an OTEL_RESOURCE_ATTRIBUTES that cannot be percent-decoded (for example team=%zz) makes the exporter's own read of that variable die, so the server or desktop app fails to start over an optional tag.
  • An environment variable is often set machine-wide for other tools, so T3 Code should not refuse to start over it. The kill switch already treats bad values this way: ignore them and warn once at startup.
  • The variable is read with the same Config.Record schema the exporters use, so "accepted" means exactly what they would have accepted, and a list they would have died on is ignored as a whole with a warning naming it.
  • This is the resource-attribute slice of #12621, split out to be small enough to review on its own.

Summary by CodeRabbit

  • New Features
    • OpenTelemetry resource attributes can now be configured through OTEL_RESOURCE_ATTRIBUTES and applied to application telemetry, including logs, traces, and metrics.
    • Percent-encoded keys and values are supported. Invalid attribute settings fall back to an empty set and produce a warning.
    • These attributes are available in both desktop and server telemetry, keeping resource metadata consistent across supported application signals.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 9a8ed8e

      Macroscope's review found this PR approvable — This is a focused observability startup fix that sanitizes malformed OTEL_RESOURCE_ATTRIBUTES values while preserving existing behavior when the variable is unset or valid. Server and desktop integrations are limited to existing telemetry layers, with tests covering the new parsing and fallback behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 0d047dee-6a82-4734-b0ff-bb050008b8a6

      📥 Commits

      Reviewing files that changed from the base of the PR and between f26ee083fe41720207fb10616359500dcecc19d3 and c507b5c9025f8e2cc70a8c390b5366d08eb67fa3.

      📒 Files selected for processing (4)
      • apps/desktop/src/app/DesktopObservability.ts
      • apps/server/src/observability/Layers/Observability.ts
      • packages/shared/src/otelEnvironment.test.ts
      • packages/shared/src/otelEnvironment.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The shared OTel environment now parses OTEL_RESOURCE_ATTRIBUTES and provides accepted attributes through a config layer. Desktop and server observability compositions apply that layer, and tests cover parsing and exporter configuration reads.

      Changes

      OTel Resource Attributes

      Layer / File(s)Summary
      Parse and provide resource attributes
      packages/shared/src/otelEnvironment.ts, packages/shared/src/otelEnvironment.test.ts
      OtelEnvironment now exposes decoded resource attributes and includes warnings for malformed values. resourceAttributesLayer provides accepted attributes through OTEL_RESOURCE_ATTRIBUTES. Tests cover unset, encoded, and malformed values, plus exporter reads.
      Provide attributes to observability layers
      apps/desktop/src/app/DesktopObservability.ts, apps/server/src/observability/Layers/Observability.ts
      Desktop endpoint resolution carries resource attributes in both branches. Desktop and server layer compositions provide those attributes to observability layers.

      Estimated code review effort: 2 (Simple) | ~15 minutes

      Sequence Diagram(s)

      sequenceDiagram
        participant OtelEnvironment
        participant DesktopObservability
        participant ServerObservability
        participant OtlpResource
        OtelEnvironment->>DesktopObservability: parsed resourceAttributes
        DesktopObservability->>OtlpResource: provide resourceAttributesLayer
        ServerObservability->>OtlpResource: provide configured resourceAttributesLayer

      Suggested reviewers: juliusmarminge, bahlo

      Merge Risk: ⚪ Minimal · up to c507b

      The change appears ready to merge after normal checks: malformed resource attributes are ignored with a warning, while accepted attributes remain available to telemetry exporters.

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly identifies the main fix: malformed OTEL_RESOURCE_ATTRIBUTES values no longer prevent startup.
      Description check✅ PassedThe description explains what changed, why the change is needed, and the intended behavior. It does not use the template headings or include the checklist, but the required information is mostly prese…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge reviewed

    5. juliusmarminge reviewed

      @@ -64,3 +67,20 @@
      6467 const T3CODE_TRUE = ["true", "yes", "on", "1", "y"];
      6568 const T3CODE_FALSE = ["false", "no", "off", "0", "n"];
      6669
      70+const RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES";
      71+
      72+interface ResourceAttributes {
      73+ readonly value: Readonly<Record<string, string>>;
      74+ readonly warning?: string;
      75+}
      76+
      77+// The schema Effect's OTLP exporters read this variable with.
      78+const resourceAttributes = Config.Record(
      79+ Schema.StringFromUriComponent,
      80+ Schema.StringFromUriComponent,
      81+ RESOURCE_ATTRIBUTES,
      82+).pipe(
      83+ Config.map((value): ResourceAttributes => ({ value })),
      84+ Config.orElse(() =>
      85+ Config.String(RESOURCE_ATTRIBUTES).pipe(
      86+ // The value is left out because attributes can carry credentials.

      nit: seems like a usecase for Config.Redacted then, no?

    6. juliusmarminge merged this87d8428

    7. juliusmarminge closed this

Sign in to join this conversation.