Update JS otel sample to use parent-sampler filtering - #719
Open
Cecilia Avila (ceciliaavila) wants to merge 4 commits into
Open
Update JS otel sample to use parent-sampler filtering#719Cecilia Avila (ceciliaavila) wants to merge 4 commits into
Cecilia Avila (ceciliaavila) wants to merge 4 commits into
Conversation
Copilot started reviewing on behalf of
Cecilia Avila (ceciliaavila)
September 4, 2026 14:54
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The lockfile changes introduce non-reproducible/local-path entries and a Node engine requirement mismatch (Node 22+) versus the sample’s documented Node 20+ prerequisite.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Node.js OpenTelemetry sample to replace env-var-based span-category disabling with a programmatic sampler that filters out selected span names (notably storage operations), aligning with the deprecation of AGENTS_TELEMETRY_DISABLED_SPAN_CATEGORIES in the SDK.
Changes:
- Added a custom
SpanNameFilteringSamplerin the OTel SDK bootstrap and configured it to drop storage spans (STORAGE_READ/WRITE/DELETE). - Added
@microsoft/agents-telemetrydependency to consume shared span-name constants. - Removed the deprecated
AGENTS_TELEMETRY_DISABLED_SPAN_CATEGORIESentry from the sample.envtemplate.
File summaries
| File | Description |
|---|---|
| samples/nodejs/otel/src/instrumentation.ts | Introduces and wires a custom sampler to filter out selected span names before export. |
| samples/nodejs/otel/package.json | Adds @microsoft/agents-telemetry dependency for SpanNames. |
| samples/nodejs/otel/package-lock.json | Updates lockfile to include the new dependency and refreshes transitive dependency resolutions. |
| samples/nodejs/otel/env.TEMPLATE | Removes the deprecated telemetry span-category env var from the template. |
Review details
Files not reviewed (1)
- samples/nodejs/otel/package-lock.json: Generated file
- Files reviewed: 3/4 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: #1282
Description
This pull request updates the OpenTelemetry Node.js sample to introduce a custom sampler that filters out specific span categories (such as storage operations) from telemetry data. It removes the
AGENTS_TELEMETRY_DISABLED_SPAN_CATEGORIESenvironment variable from the .env template as it is now deprecated in the SDK.Key changes:
Telemetry Sampling Improvements:
SpanNameFilteringSamplerclass ininstrumentation.tsto filter out spans by name, preventing certain categories (like storage operations) from being recorded or exported. This sampler is now used in place of the defaultAlwaysOnSamplerand is configured to filter out storage-related spans (STORAGE_READ,STORAGE_WRITE,STORAGE_DELETE).Configuration Cleanup:
AGENTS_TELEMETRY_DISABLED_SPAN_CATEGORIESenvironment variable from the template inenv.TEMPLATE, as span filtering is now handled programmatically via the custom sampler.Testing
These images show the spans registered with the two methods: First, using the deprecated

AGENTS_TELEMETRY_DISABLED_SPAN_CATEGORIESenv variable; Second image, using the parent sampler filter.