Skip to content

Comments

Add OpenTelemetry distributed tracing example for Azure Managed DTS#95

Merged
torosent merged 14 commits intomainfrom
torosent/add-otel
Feb 6, 2026
Merged

Add OpenTelemetry distributed tracing example for Azure Managed DTS#95
torosent merged 14 commits intomainfrom
torosent/add-otel

Conversation

@torosent
Copy link
Member

@torosent torosent commented Feb 5, 2026

Summary

What changed?

  • Added a new distributed-tracing.ts example in examples/azure-managed/ that demonstrates end-to-end OpenTelemetry distributed tracing with the Durable Task JavaScript SDK
  • Added a docker-compose.yml that starts the DTS Emulator (mcr.microsoft.com/dts/emulator:latest) and Jaeger for local trace visualization
  • Added .env.emulator with pre-configured connection string for the local emulator
  • Added a comprehensive README.md with step-by-step setup instructions for both emulator and cloud scenarios
  • Renamed connection string env var from AZURE_DTS_CONNECTION_STRING to DURABLE_TASK_SCHEDULER_CONNECTION_STRING across examples and E2E tests
  • Fixed type annotation issue with Task<Promise<T>> vs Task<T> in index.ts fan-out example

Why is this change needed?

  • Users need a working example showing how to enable and visualize distributed traces for durable orchestrations
  • The SDK already supports OpenTelemetry tracing (via optional peer dependency), but there was no example demonstrating how to set it up with a trace collector
  • The DTS Emulator Docker image enables local development without an Azure subscription

Issues / work items

  • Related: Distributed tracing support for JavaScript SDK

Project checklist

  • Release notes are not required for the next release
  • Backport is not required
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • No breaking changes. Only additions (new example files) and env var rename in examples/tests.

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot (VS Code agent mode)
  • AI-assisted areas/files: distributed-tracing.ts, docker-compose.yml, .env.emulator, README.md
  • What you changed after AI output: Reviewed and verified all OTel SDK usage, connection string patterns, and DTS emulator image reference

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Existing unit tests pass. This PR adds example code only (no new unit tests needed).

Manual validation (only if runtime/behavior changed)

  • Environment (OS, Node.js version, components): macOS, Node.js 22, Docker
  • Steps + observed results:
    1. docker compose up -d — DTS Emulator + Jaeger started
    2. cp .env.emulator .env — configured for local emulator
    3. npm run example -- ./examples/azure-managed/distributed-tracing.ts — both orchestrations completed
    4. Opened Jaeger UI at http://localhost:16686 — traces visible under service durabletask-js-tracing-example

Notes for reviewers

  • The OTel packages (@opentelemetry/sdk-node, etc.) are not added to package.json — they are installed ad-hoc with npm install --no-save as documented in the README, keeping the repo dependency footprint small.
  • The DTS Emulator image is mcr.microsoft.com/dts/emulator:latest with Authentication=None for local dev.

- Add trace-helper functions to manage OpenTelemetry spans for orchestrations, activities, and timers.
- Introduce methods to start spans for new orchestrations, orchestration executions, task scheduling, and event handling.
- Implement span error handling and status management.
- Create protobuf messages for orchestration trace context.
- Add tests to validate tracing functionality, including span creation, attribute verification, and error handling.
…Durable Task Scheduler

- Update environment variable names for connection strings in examples and tests
- Introduce distributed tracing example with OpenTelemetry integration
- Create Docker Compose setup for local testing with DTS Emulator and Jaeger
- Update README files to reflect new configuration and usage instructions
…orker

- Added structured logging capabilities to ConsoleLogger and NoOpLogger.
- Implemented logEvent method in ConsoleLogger and NoOpLogger to handle structured log events.
- Introduced emitLog utility to centralize logging logic for structured and non-structured loggers.
- Created centralized log definitions for Durable Task Client and Worker, aligning with .NET SDK event IDs and message templates.
- Added various logging functions for orchestration and activity lifecycle events in the worker.
- Implemented error handling utilities for safe error message extraction.
- Updated tests to cover new structured logging functionality and ensure proper logging behavior.
@torosent torosent marked this pull request as ready for review February 6, 2026 04:53
Copilot AI review requested due to automatic review settings February 6, 2026 04:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds OpenTelemetry distributed tracing support to the Durable Task JavaScript SDK for Azure Managed DTS. It enables end-to-end trace visualization across orchestration scheduling, execution, activities, sub-orchestrations, and timers through W3C Trace Context propagation.

Changes:

  • Added comprehensive OpenTelemetry tracing infrastructure with optional peer dependency on @opentelemetry/api
  • Introduced structured logging system with event IDs and categories matching .NET SDK conventions
  • Renamed environment variable from AZURE_DTS_CONNECTION_STRING to DURABLE_TASK_SCHEDULER_CONNECTION_STRING across examples and tests
  • Added distributed tracing example with DTS Emulator and Jaeger visualization setup

Reviewed changes

Copilot reviewed 40 out of 41 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/durabletask-js/src/tracing/* New tracing infrastructure including constants, trace context utilities, and helper functions for span creation
packages/durabletask-js/src/worker/* Integration of tracing spans and structured logging into worker execution flow
packages/durabletask-js/src/client/* Integration of tracing spans and structured logging into client operations
packages/durabletask-js/src/types/logger.type.ts Added StructuredLogger interface and createLogEventHandler for structured logging
packages/durabletask-js/src/utils/* New utility functions for error handling and log emission
packages/durabletask-js/test/* Comprehensive test coverage for tracing and logging features
examples/azure-managed/distributed-tracing.ts New example demonstrating OpenTelemetry tracing with Jaeger
examples/azure-managed/docker-compose.yml Docker setup for DTS Emulator and Jaeger
test/e2e-azuremanaged/*.spec.ts Updated E2E tests with new connection string environment variable
packages/durabletask-js/package.json Added OpenTelemetry as optional peer dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@torosent torosent merged commit 26879a8 into main Feb 6, 2026
10 checks passed
@torosent torosent deleted the torosent/add-otel branch February 6, 2026 21:04
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