Skip to content

Conversation

@pengweiqhca
Copy link
Contributor

@pengweiqhca pengweiqhca commented Nov 1, 2025

Fixes #3371
Design discussion issue #

Changes

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@pengweiqhca pengweiqhca requested a review from a team as a code owner November 1, 2025 13:56
@github-actions github-actions bot requested a review from matt-hensley November 1, 2025 13:56
@github-actions github-actions bot added the comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis label Nov 1, 2025
@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.92%. Comparing base (ab01922) to head (0d70b9e).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3372      +/-   ##
==========================================
+ Coverage   70.78%   70.92%   +0.14%     
==========================================
  Files         440      430      -10     
  Lines       17245    17194      -51     
==========================================
- Hits        12207    12195      -12     
+ Misses       5038     4999      -39     
Flag Coverage Δ
unittests-Instrumentation.Cassandra ?
unittests-Instrumentation.StackExchangeRedis 71.80% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...dis/StackExchangeRedisConnectionInstrumentation.cs 95.83% <100.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="OpenTelemetry.Api.ProviderBuilderExtensions" />
<PackageReference Include="OpenTelemetry" />
Copy link
Member

Choose a reason for hiding this comment

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

I am concerned about this change. During stabilization effort, this package was removed (at least from HttpClient). We still do not have good solution to make similar things referencing only OpenTelemetry/Api package.

@open-telemetry/dotnet-maintainers, do you see any better option here (even long term, by adding this functionality on API level)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Brought this up at the .NET SIG on Nov 4 2025. Maintainers are looking at moving this functionality out of the SDK package.

Suppression is not currently part of the spec but is useful enough to find a better solution, even though it would technically make the API out of compliance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kielek Use Func<bool> to replace Sdk.SuppressInstrumentatio?

@Kielek
Copy link
Member

Kielek commented Nov 20, 2025

@matt-hensley, @pengweiqhca,

I have discussed this problem internally with @pellared. There is another option you can consider and it should met OpenTelemetry design.

The correct way to determine if you need to create span is Sampler. You could try to write your own and inject it into the OpenTelemetry tracer. What is more some attributes should be available for Sampler to allow making this decision:
https://github.com/open-telemetry/semantic-conventions/blob/d48be4318100be7a8899b713c07db0471b5b1b3d/docs/database/redis.md

What do you think about this solution?

Historically, Sdk.SuppressInstrumentation was designed mostly for Exporters (OTLP) to avoid instrumentation for calls during this process.

@pengweiqhca
Copy link
Contributor Author

pengweiqhca commented Nov 20, 2025

@Kielek I know Sampler and am already using it, but it’s not suitable for my scenario.

for (var index = 0; index < xxx; index++)
{
    using var activity = ActivitySource.StartActivity();

    // I only want to get the full trace the first time and ignore it afterward, but Redis can't be suppressed.
    using var scope = index == 0 ? null : SuppressInstrumentationScope.Begin();

    // database, redis, http, etc.
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] [Instrumentation.StackExchangeRedis] should support Sdk.SuppressInstrumentation.

3 participants