Skip to content

feat(observability): export Trigger.dev telemetry to Grafana Cloud OTLP#4583

Merged
TheodoreSpeaks merged 4 commits into
stagingfrom
feat/trigger-grafana-metrics
May 13, 2026
Merged

feat(observability): export Trigger.dev telemetry to Grafana Cloud OTLP#4583
TheodoreSpeaks merged 4 commits into
stagingfrom
feat/trigger-grafana-metrics

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • Wire OTLP HTTP exporters for traces, logs, and metrics from the Trigger.dev runtime to Grafana Cloud
  • Auth uses Basic with Grafana Cloud instance ID + API token, computed once and reused across the three exporters
  • Gated behind GRAFANA_OTLP_ENDPOINT, GRAFANA_INSTANCE_ID, GRAFANA_API_TOKEN; all three must be set together or all unset (partial config throws at startup, fail-fast)
  • Env-splitting handled by Trigger's built-in ctx.environment.type resource attribute — no extra env var needed

Type of Change

  • New feature

Testing

  • Tested manually: bun run type-check clean, bun run lint clean
  • No new tests — config glue
  • After merge: set the three env vars in Trigger.dev dashboard per environment, then verify signals land in Tempo/Loki/Mimir filtered by ctx.environment.type

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)

Wire OTLP HTTP exporters for traces, logs, and metrics from the
Trigger.dev runtime to Grafana Cloud. Auth uses Basic with instance ID
and API token. Gated behind GRAFANA_OTLP_ENDPOINT, GRAFANA_INSTANCE_ID,
and GRAFANA_API_TOKEN — all three must be set together or all unset;
partial config throws at startup.
@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:05pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 13, 2026

PR Summary

Medium Risk
Adds optional OTLP exporting (traces/logs/metrics) for Trigger.dev with fail-fast startup validation; misconfiguration can prevent background job runtime from starting. Low code footprint but touches observability plumbing and introduces new OpenTelemetry exporter dependencies.

Overview
Adds an optional Grafana Cloud OTLP telemetry pipeline for the Trigger.dev runtime, exporting traces, logs, and metrics over OTLP/HTTP when configured.

Introduces new env vars (GRAFANA_OTLP_ENDPOINT, GRAFANA_OTLP_HEADERS, GRAFANA_DEPLOYMENT_ENVIRONMENT) with fail-fast validation (all-or-nothing) and OTEL-spec header parsing, and wires the resulting exporters/resource into trigger.config.ts. Updates apps/sim dependencies/lockfile to include the OTLP log and metric HTTP exporters.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR wires three OTLP HTTP exporters (traces, logs, metrics) from the Trigger.dev runtime to Grafana Cloud, gated behind three env vars with a fail-fast guard that throws at startup if only a subset is configured.

  • trigger.config.ts: Reads GRAFANA_OTLP_ENDPOINT, GRAFANA_INSTANCE_ID, and GRAFANA_API_TOKEN at module load, computes a Basic auth header once, and conditionally spreads a telemetry object into defineConfig.
  • env.ts: Registers the three new vars as optional Zod-validated entries under the existing "Monitoring & Analytics" section.
  • package.json: Adds @opentelemetry/exporter-logs-otlp-http and @opentelemetry/exporter-metrics-otlp-proto; the latter uses Protobuf encoding while the other two exporters use JSON-over-HTTP.

Confidence Score: 4/5

Safe to merge; the change is additive and fully inert when the three env vars are absent.

The logic is straightforward config-glue with a solid partial-config guard. The only notable oddity is that the metrics exporter uses Protobuf encoding while traces and logs use JSON-over-HTTP, which introduces a minor inconsistency in the signal pipeline and an extra package dependency.

apps/sim/trigger.config.ts and apps/sim/package.json — specifically the choice of exporter-metrics-otlp-proto vs the HTTP/JSON variant used for the other two exporters.

Important Files Changed

Filename Overview
apps/sim/trigger.config.ts Adds Grafana Cloud OTLP telemetry wiring with fail-fast partial-config guard; metrics uses proto encoding while logs/traces use HTTP JSON, which is a minor inconsistency.
apps/sim/lib/core/config/env.ts Adds three optional Grafana env vars with appropriate Zod validators; placement and style match existing patterns.
apps/sim/package.json Adds exporter-logs-otlp-http and exporter-metrics-otlp-proto; the proto package is inconsistent with the HTTP/JSON encoding used for traces and logs.

Sequence Diagram

sequenceDiagram
    participant T as Trigger.dev Runtime
    participant TC as trigger.config.ts
    participant TE as OTLPTraceExporter (HTTP/JSON)
    participant LE as OTLPLogExporter (HTTP/JSON)
    participant ME as OTLPMetricExporter (HTTP/Proto)
    participant G as Grafana Cloud OTLP Gateway

    TC->>TC: "Read GRAFANA_* env vars"
    alt Partially configured
        TC-->>TC: throw Error (fail-fast)
    else Fully configured
        TC->>TC: Compute Basic auth header
        TC->>TE: new OTLPTraceExporter
        TC->>LE: new OTLPLogExporter
        TC->>ME: new OTLPMetricExporter
    end

    T->>TE: Export spans
    TE->>G: POST /v1/traces (application/json)
    T->>LE: Export logs
    LE->>G: POST /v1/logs (application/json)
    T->>ME: Export metrics
    ME->>G: POST /v1/metrics (application/x-protobuf)
Loading

Reviews (1): Last reviewed commit: "feat(observability): export Trigger.dev ..." | Re-trigger Greptile

Comment thread apps/sim/trigger.config.ts Outdated
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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2892b4f. Configure here.

Comment thread apps/sim/trigger.config.ts
@TheodoreSpeaks TheodoreSpeaks merged commit ed39edb into staging May 13, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the feat/trigger-grafana-metrics branch May 13, 2026 23:38
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