Skip to content

[#548] Move OTel sample from JS repository#571

Merged
MattB-msft merged 3 commits into
mainfrom
southworks/add/otel-sample-js
May 15, 2026
Merged

[#548] Move OTel sample from JS repository#571
MattB-msft merged 3 commits into
mainfrom
southworks/add/otel-sample-js

Conversation

@ceciliaavila
Copy link
Copy Markdown
Collaborator

Fixes #548

This pull request introduces a new OpenTelemetry (OTel) instrumented agent sample for Node.js, called OTelAgent, to the samples directory. The sample demonstrates how to integrate OpenTelemetry tracing, metrics, and logs into a Microsoft 365 Agent, and export telemetry to the .NET Aspire Dashboard. The changes include all source code, configuration, documentation, and build scripts needed to run and understand the sample.

Addition of OTelAgent sample:

  • Added a new sample, OTelAgent, with its own directory, demonstrating end-to-end OpenTelemetry instrumentation in a Node.js Microsoft 365 Agent. The sample includes custom spans, counters, histograms, and enrichment for HTTP operations. (samples/nodejs/README.md, samples/nodejs/otel/README.md) [1] [2]

Source code and instrumentation:

  • Implemented the core agent logic in agent.ts, including message handling, welcome messages, and telemetry events for both. (samples/nodejs/otel/src/agent.ts)
  • Added agentTelemetry.ts to define and export custom OpenTelemetry metrics and tracers used by the agent. (samples/nodejs/otel/src/agentTelemetry.ts)
  • Created instrumentation.ts to configure and initialize the OpenTelemetry SDK, supporting both OTLP and console exporters, and handling graceful shutdown. (samples/nodejs/otel/src/instrumentation.ts)

Configuration and build:

  • Provided a template environment file (env.TEMPLATE) with all necessary configuration keys for authentication and telemetry export. (samples/nodejs/otel/env.TEMPLATE)
  • Added a dedicated package.json with all dependencies and build/start scripts for the sample. (samples/nodejs/otel/package.json)
  • Included a tsconfig.json for TypeScript compilation targeting Node.js. (samples/nodejs/otel/tsconfig.json)

Testing

This image shows the traces exported by the sample.
image

@github-actions github-actions Bot added the Samples Changes to Samples label May 14, 2026
@ceciliaavila ceciliaavila requested a review from benbrown May 14, 2026 18:35
@MattB-msft MattB-msft merged commit d17c2ff into main May 15, 2026
7 checks passed
@MattB-msft MattB-msft deleted the southworks/add/otel-sample-js branch May 15, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Samples Changes to Samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move OTel sample from JS repository

2 participants