Skip to content

feat: fix OTel tracing and add observability metrics/spans - #8

Merged
orvice merged 1 commit into
icebase:mainfrom
orxbot:agent/cursor-sonnet/683ad955161d
Oct 25, 2026
Merged

orvice merged 1 commit into
icebase:mainfrom
orxbot:agent/cursor-sonnet/683ad955161d

Conversation

@orxbot

@orxbot orxbot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Findings (existing integration)

  • Prometheus metrics (/metrics, :9090) and an OTLP/gRPC tracer already existed, but were undocumented.
  • Bug: enabling tracing (MU_TRACING_ENABLED=true) failed at startup with conflicting Schema URL (resource merge of SDK default + semconv v1.24). Tracing could never actually run.
  • Other gaps: MU_TRACING_ENDPOINT default overrode OTEL_EXPORTER_OTLP_*; a real SDK provider was installed even when disabled; no sample-rate validation; MU API client calls, upload flush and backend operations were not traced; no API / outbox / freshness metrics.

Changes

  • Tracing: fixed resource creation; disabled = untouched no-op provider; parent-based sampler; sample-rate/exporter validation; MU_TRACING_EXPORTER=stdout for collector-less debugging; URL or host:port endpoints, falls back to OTEL_EXPORTER_OTLP_*; OTel errors routed to slog; service.version / mu.node_id resource attributes.
  • Spans: MU.<rpc> client spans (sanitized errors only, status code, request id) with W3C traceparent propagation to the MU API; App.flushTraffic; per-backend attributes (sync.users_*, traffic.*); error status on root spans; trace_id/span_id in MU API request failed logs.
  • Metrics: mu_api_requests_total, mu_api_request_duration_seconds, mu_job_last_success_timestamp_seconds, mu_traffic_outbox_{batches,logs}, mu_backend_user_operations_total, mu_build_info; metrics server now logs the listen error.
  • Docs: README Observability section (env vars, metric table, span tree, alert examples, Collector config).

Verification

  • go vet ./..., go test -race ./... pass locally (new tests for tracing init/regression, client spans + propagation + observer, app spans and outbox/backend metrics).
  • Smoke-run of the binary with MU_TRACING_EXPORTER=stdout: spans nested correctly and /metrics exposed the new series.
  • Docker is unavailable in the dev environment; the Docker workflow and golangci-lint (not runnable locally) are left to PR CI.

Note: metrics remain Prometheus-based (scrape directly or via Collector prometheus receiver); no OTLP metrics exporter was added.

Made with Cursor

…ics and spans

- Fix tracing init failing with conflicting semconv schema URL when enabled
- No-op when disabled; honor OTEL_EXPORTER_OTLP_* env; add stdout exporter
- Validate sample rate, parent-based sampling, propagate W3C trace context
- Client spans/observer for MU API calls, trace_id in failure logs
- Spans for flush/backends; metrics for API requests, outbox, job freshness,
  backend user operations, build info
- Document metrics, traces and collector setup

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
@orvice
orvice merged commit 855737a into icebase:main Oct 25, 2026
3 checks passed
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