Skip to content

Commit

Permalink
DO.NOT.MERGE: Backporting fix for 3.41.x release (#3077)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes authored Jan 24, 2024
1 parent 44d54e9 commit 696e6fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.41.4

### 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
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<Version>3.41.3</Version>
<Version>3.41.4</Version>
<LangVersion>11</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory).assets\Sentry.snk</AssemblyOriginatorKeyFile>
Expand Down
7 changes: 6 additions & 1 deletion src/Sentry.OpenTelemetry/SentrySpanProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

Expand Down
8 changes: 5 additions & 3 deletions test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object> { { "foo", "bar" }, { "http.url", _fixture.Options.Dsn } };
var tags = new Dictionary<string, object> { { "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);
Expand Down

0 comments on commit 696e6fd

Please sign in to comment.