From 71c7762f77b1695870e01edfb02994d4ca2d2bde Mon Sep 17 00:00:00 2001 From: pengweiqhca Date: Thu, 6 Jun 2024 10:48:04 +0800 Subject: [PATCH 1/3] Fix table format error. --- src/OpenTelemetry.Resources.Gcp/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Resources.Gcp/README.md b/src/OpenTelemetry.Resources.Gcp/README.md index 5424920160..af45be5fd7 100644 --- a/src/OpenTelemetry.Resources.Gcp/README.md +++ b/src/OpenTelemetry.Resources.Gcp/README.md @@ -46,8 +46,8 @@ which Google Cloud Platform environment an application is running in. ### Google Kubernetes Engine -|-------------------------|-----------------------| | Attribute | Value | +|-------------------------|-----------------------| | cloud.provider | gcp | | cloud.platform | gcp_kubernetes_engine | | cloud.account.id | auto | @@ -59,16 +59,16 @@ which Google Cloud Platform environment an application is running in. ### Google App Engine -|-------------------------|----------------| | Attribute | Value | +|-------------------------|----------------| | cloud.provider | gcp | | cloud.platform | gcp_app_engine | | cloud.account.id | auto | ### Google Cloud Run -|-------------------------|---------------| | Attribute | Value | +|-------------------------|---------------| | cloud.provider | gcp | | cloud.platform | gcp_cloud_run | | cloud.account.id | auto | @@ -77,8 +77,8 @@ which Google Cloud Platform environment an application is running in. ### Google Compute Engine -|-------------------------|--------------------| | Attribute | Value | +|-------------------------|--------------------| | cloud.provider | gcp | | cloud.platform | gcp_compute_engine | | cloud.account.id | auto | From d5942f2b0c90008e51d609593f03b252ac01c468 Mon Sep 17 00:00:00 2001 From: pengweiqhca Date: Sat, 1 Nov 2025 21:54:30 +0800 Subject: [PATCH 2/3] [StackExchangeRedis] Support Sdk.SuppressInstrumentation. Fix #3371 --- ....Instrumentation.StackExchangeRedis.csproj | 4 +- ...kExchangeRedisConnectionInstrumentation.cs | 2 +- ...kExchangeRedisCallsInstrumentationTests.cs | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index c05922ba21..e6c5137a1d 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -28,9 +28,7 @@ - - - + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisConnectionInstrumentation.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisConnectionInstrumentation.cs index f96e808e06..d8b20dd72f 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisConnectionInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisConnectionInstrumentation.cs @@ -82,7 +82,7 @@ public StackExchangeRedisConnectionInstrumentation( var parent = Activity.Current; // If no parent use the default session. - if (parent == null || parent.IdFormat != ActivityIdFormat.W3C) + if (parent == null || parent.IdFormat != ActivityIdFormat.W3C || Sdk.SuppressInstrumentation) { return this.defaultSession; } diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index 94e51bd9f5..d8e6cd2284 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -199,6 +199,43 @@ public async Task ProfilerSessionUsesTheSameDefault() Assert.Equal(second, third); } + [Fact] + public void ProfilerSessionUsesTheSameDefaultWhenSuppressInstrumentationScopeHasBegan() + { + var connectionOptions = new ConfigurationOptions + { + AbortOnConnectFail = false, + ConnectRetry = 0, + ConnectTimeout = 1_000, + }; + connectionOptions.EndPoints.Add("localhost:6379"); + + var connection = ConnectionMultiplexer.Connect(connectionOptions); + + using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, name: null, new StackExchangeRedisInstrumentationOptions()); + var profilerFactory = instrumentation.GetProfilerSessionsFactory(); + var first = profilerFactory(); + + // start a root level activity + using var rootActivity = new Activity("Parent") + .SetParentId(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded) + .Start(); + + Assert.NotNull(rootActivity.Id); + + // get an initial profiler from root activity + Activity.Current = rootActivity; + var second = profilerFactory(); + ProfilingSession? third; + using (SuppressInstrumentationScope.Begin()) + { + third = profilerFactory(); + } + + Assert.NotEqual(first, second); + Assert.Equal(first, third); + } + [Trait("CategoryName", "RedisIntegrationTests")] [SkipUnlessEnvVarFoundTheory(RedisEndPointEnvVarName)] [InlineData("value1")] From 0d70b9e67fccc34ad59bfb653e2cf191ae0028a8 Mon Sep 17 00:00:00 2001 From: pengweiqhca Date: Sat, 1 Nov 2025 21:58:15 +0800 Subject: [PATCH 3/3] Add `CHANGELOG` --- .../CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index 792c5bed9c..492798cc47 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Support `Sdk.SuppressInstrumentation`/`SuppressInstrumentationScope`. + ([#3372](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3372)) + ## 1.13.0-beta.1 Released 2025-Oct-22