Skip to content

Distributed tracing with open telemetry#100

Merged
elizabetheonoja-art merged 3 commits into
Utility-Protocol:mainfrom
gloskull:Distributed-Tracing-with-OpenTelemetry
Jul 18, 2026
Merged

Distributed tracing with open telemetry#100
elizabetheonoja-art merged 3 commits into
Utility-Protocol:mainfrom
gloskull:Distributed-Tracing-with-OpenTelemetry

Conversation

@gloskull

Copy link
Copy Markdown
Contributor

Motivation
Add end-to-end, OpenTelemetry-compatible W3C Trace Context propagation for off-chain services to improve observability and enable correlation across MQTT publishes, ingestion, and dashboard traces.
Ensure trace creation is safe and performant by validating incoming traceparent, rejecting all-zero ids, and generating local ids without depending on external collectors.
Surface simple health indicators in the dashboard (P99 latency, invalid contexts, exporter health) to meet the critical-path latency target and support canary/blue-green rollout decisions.
Description
Add meter-simulator/src/trace-context.js which provides parseTraceparent, createTraceContext, formatTraceparent, injectTraceContext, createBaggage, and calculateLatencyMs for W3C trace propagation and latency measurement.
Inject trace metadata into MQTT payloads by updating meter-simulator/src/mqtt-publisher.js to call injectTraceContext for usage, heartbeat, status, and to log publish-path latency; make service name configurable via observability.serviceName.
Expose observability configuration in meter-simulator/src/config.js and wire the service name into simulator entry points (simulate and send-reading) in meter-simulator/src/index.js.
Add Jest tests at meter-simulator/tests/trace-context.test.js covering traceparent creation/validation, parent-preservation, baggage encoding, and latency calculation, plus documentation docs/DISTRIBUTED_TRACING.md and a README observability section; update dashboard types/mock UI to show trace P99 and health signals.
Testing
Ran focused unit tests with npm test -- trace-context.test.js --runInBand, which passed (5/5 tests passed).
Performed syntax checks with node -c meter-simulator/src/mqtt-publisher.js and node -c meter-simulator/src/trace-context.js, which succeeded, and ran npx tsc --noEmit for dashboard type checks which succeeded.
Ran the full meter-simulator Jest suite (npm test -- --runInBand) and observed pre-existing unrelated failures in meter-device.test.js (fixture key size and timestamp/message-length expectations), which are not introduced by this change.
Attempted dashboard production build (npm run build) and it failed in this environment due to an external Google Fonts fetch error (network/font fetching issue), not code correctness.
Closes #63

@elizabetheonoja-art
elizabetheonoja-art merged commit 43de1b8 into Utility-Protocol:main Jul 18, 2026
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.

Distributed Tracing with OpenTelemetry and Trace Context Propagation

2 participants