From 483a39d3e1b805c53d8c6ee40dd3ede62a273aae Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Mon, 22 Jan 2024 14:45:04 +0100 Subject: [PATCH 1/4] backporting fix --- CHANGELOG.md | 8 ++++++++ src/Sentry.OpenTelemetry/SentrySpanProcessor.cs | 7 ++++++- .../SentrySpanProcessorTests.cs | 8 +++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ad0db763..117a06088d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Unreleased + +### Fixes + +### Fixes + +- Fixed an issue when using the SDK together with Open Telemetry `1.5.0` and newer where the SDK would create transactions for itself. The fix is backwards compatible. ([#3001](https://github.com/getsentry/sentry-dotnet/pull/3001)) + ## 3.41.3 ### Fixes diff --git a/src/Sentry.OpenTelemetry/SentrySpanProcessor.cs b/src/Sentry.OpenTelemetry/SentrySpanProcessor.cs index dcdff5fe05..77c34293fc 100644 --- a/src/Sentry.OpenTelemetry/SentrySpanProcessor.cs +++ b/src/Sentry.OpenTelemetry/SentrySpanProcessor.cs @@ -117,7 +117,12 @@ public override void OnEnd(Activity data) // Make a dictionary of the attributes (aka "tags") for faster lookup when used throughout the processor. var attributes = data.TagObjects.ToDictionary(); - if (attributes.TryGetTypedValue("http.url", out string? url) && (_options?.IsSentryRequest(url) ?? false)) + var url = + attributes.TryGetTypedValue(OtelSemanticConventions.AttributeUrlFull, out string? tempUrl) ? tempUrl + : attributes.TryGetTypedValue(OtelSemanticConventions.AttributeHttpUrl, out string? fallbackUrl) ? fallbackUrl // Falling back to pre-1.5.0 + : null; + + if (!string.IsNullOrEmpty(url) && (_options?.IsSentryRequest(url) ?? false)) { _options?.DiagnosticLogger?.LogDebug($"Ignoring Activity {data.SpanId} for Sentry request."); diff --git a/test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs b/test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs index 4a7f87e757..5596cafe7a 100644 --- a/test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs +++ b/test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs @@ -378,14 +378,16 @@ public void OnEnd_FinishesTransaction() } } - [Fact] - public void OnEnd_IsSentryRequest_DoesNotFinishTransaction() + [Theory] + [InlineData(OtelSemanticConventions.AttributeUrlFull)] + [InlineData(OtelSemanticConventions.AttributeHttpUrl)] + public void OnEnd_IsSentryRequest_DoesNotFinishTransaction(string urlKey) { // Arrange _fixture.Options.Instrumenter = Instrumenter.OpenTelemetry; var sut = _fixture.GetSut(); - var tags = new Dictionary { { "foo", "bar" }, { "http.url", _fixture.Options.Dsn } }; + var tags = new Dictionary { { "foo", "bar" }, { urlKey, _fixture.Options.Dsn } }; var data = Tracer.StartActivity(name: "test operation", kind: ActivityKind.Internal, parentContext: default, tags)!; data.DisplayName = "test display name"; sut.OnStart(data); From bbddc76312857ebc1aed0b4f1d7d74af6477abca Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Tue, 23 Jan 2024 11:45:21 +0100 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 117a06088d..c11ab32f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,6 @@ ### Fixes -### Fixes - - Fixed an issue when using the SDK together with Open Telemetry `1.5.0` and newer where the SDK would create transactions for itself. The fix is backwards compatible. ([#3001](https://github.com/getsentry/sentry-dotnet/pull/3001)) ## 3.41.3 From 2493ada264d121203e5413951fc192443f97a345 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Tue, 23 Jan 2024 12:51:49 +0100 Subject: [PATCH 3/4] ported CI android fixed --- .github/actions/environment/action.yml | 9 +++++++++ .github/workflows/build.yml | 9 +++++++++ .github/workflows/device-tests-android.yml | 6 ------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index 095ff89560..3a8f31d389 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -11,6 +11,15 @@ runs: echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $GITHUB_ENV echo "DOTNET_NOLOGO=1" >> $GITHUB_ENV + # Needed for Android SDK setup step + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f # v3.2.0 + - name: Set Java Version uses: actions/setup-java@v3 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53d360977e..4da94c9ad2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,15 @@ jobs: env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + # Needed for Android SDK setup step + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f # v3.2.0 + - name: Test run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" diff --git a/.github/workflows/device-tests-android.yml b/.github/workflows/device-tests-android.yml index 20835f9460..86e0d18b15 100644 --- a/.github/workflows/device-tests-android.yml +++ b/.github/workflows/device-tests-android.yml @@ -23,12 +23,6 @@ jobs: with: submodules: recursive - - name: Set Java Version - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '11' - - name: Build Native Dependencies uses: ./.github/actions/buildnative From e2a358fc772d47768f385553c29577685d7a9b04 Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Tue, 23 Jan 2024 13:30:58 +0000 Subject: [PATCH 4/4] release: 3.41.4 --- CHANGELOG.md | 2 +- Directory.Build.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c11ab32f87..022a7e4d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 3.41.4 ### Fixes diff --git a/Directory.Build.props b/Directory.Build.props index 1a8cdfeb65..761205aa0f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 3.41.3 + 3.41.4 11 true $(MSBuildThisFileDirectory).assets\Sentry.snk