Skip to content

fix(otel): address staging pr comments for trigger otel#4586

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/trigger-otel
May 14, 2026
Merged

fix(otel): address staging pr comments for trigger otel#4586
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/trigger-otel

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Address staging comments by reusing shared header extractor.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Typechecked locally

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 13, 2026 11:55pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 13, 2026

PR Summary

Medium Risk
Touches OTLP exporter header parsing used for telemetry authentication/routing; misparsing could silently break trace/log/metric export in some environments.

Overview
Consolidates OTLP header parsing into a shared parseOtlpHeaders helper (apps/sim/lib/monitoring/otlp.ts) and switches both instrumentation-node.ts and trigger.config.ts to use it.

The new parser is more defensive (trims whitespace, skips malformed/empty entries, and preserves raw values if URL-decoding fails), reducing config-related telemetry export failures.

Reviewed by Cursor Bugbot for commit 8ace24c. Bugbot is set up for automated code reviews on this repo. Configure here.

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR extracts the duplicated OTLP header-parsing logic from instrumentation-node.ts and trigger.config.ts into a single shared utility at lib/monitoring/otlp.ts, addressing a staging review comment about code reuse.

  • New shared utility (lib/monitoring/otlp.ts): combines the best of both previous implementations — the if (!raw) early-return guard, the outer trim() loop, and a try/catch around decodeURIComponent so malformed percent-encoding silently falls back to the raw value instead of throwing.
  • Bug fix in trigger.config.ts: the old local function called decodeURIComponent unconditionally, meaning malformed percent-encoding in GRAFANA_OTLP_HEADERS would throw a URIError at module load time and crash the Trigger.dev process before telemetry was even configured.
  • instrumentation-node.ts: behaviour is unchanged; the removed parseOtlpHeadersEnv was functionally identical to the new shared function.

Confidence Score: 5/5

Safe to merge — this is a focused deduplication that also closes a crash path in trigger.config.ts.

All three files are touched only to replace identical logic with the new shared utility. The shared implementation is strictly more defensive than either predecessor: it adds an early-return for empty input and wraps decodeURIComponent in a try/catch that the old trigger.config.ts version was missing. No new logic is introduced, no interfaces change, and the call-sites are identical.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/monitoring/otlp.ts New shared utility that consolidates OTLP header parsing; more defensive than either prior implementation with proper try/catch and early-return guard.
apps/sim/instrumentation-node.ts Drops local parseOtlpHeadersEnv and delegates to the new shared parseOtlpHeaders; call-site is unchanged, behavior is identical.
apps/sim/trigger.config.ts Removes local parseOtlpHeaders that called decodeURIComponent without try/catch (a crash risk on malformed percent-encoding at module load); now uses the hardened shared version.

Sequence Diagram

sequenceDiagram
    participant A as instrumentation-node.ts
    participant B as trigger.config.ts
    participant C as lib/monitoring/otlp.ts

    Note over A,B: Before PR — each file had its own parseOtlpHeaders

    A->>A: parseOtlpHeadersEnv(env var)
    B->>B: parseOtlpHeaders(grafanaHeaders) [no try/catch on decodeURIComponent]

    Note over A,B: After PR — both delegate to shared utility

    A->>C: parseOtlpHeaders(process.env.OTEL_EXPORTER_OTLP_HEADERS)
    C-->>A: "Record<string, string>"

    B->>C: parseOtlpHeaders(grafanaHeaders)
    C-->>B: "Record<string, string>"

    Note over C: try/catch on decodeURIComponent preserves raw value on URIError
Loading

Reviews (1): Last reviewed commit: "fix(otel): address staging pr comments f..." | Re-trigger Greptile

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8ace24c. Configure here.

@TheodoreSpeaks TheodoreSpeaks merged commit 4de955d into staging May 14, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/trigger-otel branch May 14, 2026 00:01
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.

1 participant