Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2122abb
Added support to send OTEL traces via OTLP
jamescrosswell Feb 9, 2026
a2fb0e4
Added OTEL propagation context to link OTEL spans to events etc.
jamescrosswell Feb 9, 2026
442fc7d
Disable Sentry tracing instrumentation if OTEL is enabled
jamescrosswell Feb 10, 2026
08d8711
Revert to classic extension methods
jamescrosswell Feb 10, 2026
907850b
Added option to disable sentry tracing
jamescrosswell Feb 12, 2026
6f8312d
Added some new tests... found some new issues
jamescrosswell Feb 12, 2026
8fbbf89
Merge remote-tracking branch 'origin/main' into oltp-integration
jamescrosswell Feb 15, 2026
1ea156a
Prevent Hub.GetBaggage from throwing an exception
jamescrosswell Feb 18, 2026
83f9097
Fix tests
jamescrosswell Feb 18, 2026
ee67a6e
Bump to Otel 1.15.0 to address IL3050 error for AOT compilation
jamescrosswell Feb 18, 2026
d1597d8
changelog
jamescrosswell Feb 18, 2026
c8856a6
Fixed package downgrades
jamescrosswell Feb 18, 2026
5ee6455
Fixed failing tests on .NET Framework
jamescrosswell Feb 19, 2026
46eb4d6
Merge branch 'main' into oltp-integration
jamescrosswell Feb 19, 2026
af2457b
Format code
getsentry-bot Feb 19, 2026
ed9e04d
Moved to a separate NuGet package
jamescrosswell Feb 19, 2026
304c5bc
.
jamescrosswell Feb 19, 2026
4537ac9
.
jamescrosswell Feb 19, 2026
d2406ef
Updated Samples
jamescrosswell Feb 19, 2026
f1550ca
Review feedback
jamescrosswell Apr 27, 2026
467b107
Consistently long argument names
jamescrosswell Apr 28, 2026
918d400
Renamed AddSentryOtlp to AddSentryOtlpExporter
jamescrosswell Apr 28, 2026
db181ad
Removed unused code
jamescrosswell Apr 28, 2026
c3d8cc7
Apply suggestions from code review
jamescrosswell Apr 28, 2026
1dcd704
Typos and redundant usings
jamescrosswell Apr 28, 2026
92b2e0f
Merge remote-tracking branch 'origin/main' into oltp-integration
jamescrosswell Apr 28, 2026
11831c1
Revoved manual changelog entry
jamescrosswell Apr 28, 2026
758f2a1
Fix build error
jamescrosswell Apr 28, 2026
ba1489c
Revert unnecessary version bumps
jamescrosswell Apr 28, 2026
7967973
Address naming conflicts
jamescrosswell Apr 28, 2026
861ee93
Tests for UseOtlp
jamescrosswell Apr 28, 2026
fa48e02
Renamed package Sentry.OpenTelemetry.Exporter
jamescrosswell Apr 28, 2026
f1a6617
IsAotCompatible unconditional
jamescrosswell Apr 28, 2026
b6819b7
Remove workaround for Roslyn analyser bug (resolved)
jamescrosswell Apr 28, 2026
d35af03
Drop minimum OTEL version from 1.10.0 to 10.6.0
jamescrosswell Apr 28, 2026
f55ded4
Revert "Drop minimum OTEL version from 1.10.0 to 10.6.0"
jamescrosswell Apr 29, 2026
aff8691
Added IExternalPropagationContext
jamescrosswell Apr 29, 2026
9789b53
Redundant comment
jamescrosswell Apr 29, 2026
3130084
Simplified package reference
jamescrosswell Apr 29, 2026
154d394
Format code
getsentry-bot Apr 29, 2026
74cd8c0
Review feedback
jamescrosswell Apr 29, 2026
f83616f
Add custom collector url to AddSentryOtlpExporter
jamescrosswell Apr 29, 2026
f40de80
Tidy up
jamescrosswell Apr 29, 2026
d321b3f
Format code
getsentry-bot Apr 29, 2026
26ca204
Tests for ActivityExtensions
jamescrosswell Apr 29, 2026
6b60977
Tests for collectorUrl
jamescrosswell Apr 29, 2026
9fef303
New hub tests
jamescrosswell Apr 29, 2026
db9885f
Parse sample rand and sample rate from OTEL TraceStateString
jamescrosswell Apr 29, 2026
114127f
Format code
getsentry-bot Apr 29, 2026
acf14a4
Removed redundant guard
jamescrosswell Apr 29, 2026
dc518b5
Fixed inversions
jamescrosswell Apr 29, 2026
dad9e18
Handle possible whitespace in TraceStateString
jamescrosswell Apr 29, 2026
df952a0
Add additional headers to OTLP client requests
jamescrosswell Apr 29, 2026
f06a9ee
Deal with edge case on the rv being 0
jamescrosswell Apr 29, 2026
534a7b7
Apply suggestions from code review
jamescrosswell May 4, 2026
dde314d
Merge remote-tracking branch 'origin/main' into oltp-integration
jamescrosswell May 4, 2026
e35fe31
perf: use ReadOnlySpan<char> in OtelPropagationContext to avoid heap …
jamescrosswell May 4, 2026
45d8082
Fix race on DSC
jamescrosswell May 5, 2026
17e5e64
Merge remote-tracking branch 'origin/oltp-integration' into oltp-inte…
jamescrosswell May 5, 2026
ddfb765
fix: snapshot Activity.Current in OtelPropagationContext to prevent T…
jamescrosswell May 5, 2026
e057d69
fix: fall through to scope PropagationContext in GetBaggage when no a…
jamescrosswell May 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions samples/Sentry.Samples.OpenTelemetry.AspNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

var builder = WebApplication.CreateBuilder(args);

// Read the Sentry DSN from the environment variable, if it's not already set in code.
#if SENTRY_DSN_DEFINED_IN_ENV
var dsn = Environment.GetEnvironmentVariable("SENTRY_DSN") ?? throw new InvalidOperationException("SENTRY_DSN environment variable is not set");
#else
var dsn = SamplesShared.Dsn;
#endif

// OpenTelemetry Configuration
// See https://opentelemetry.io/docs/instrumentation/net/getting-started/
builder.Services.AddOpenTelemetry()
Expand All @@ -20,8 +27,8 @@
// The two lines below take care of configuring sources for ASP.NET Core and HttpClient
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
// Finally we configure OpenTelemetry to send traces to Sentry
.AddSentry()
// Finally, we configure OpenTelemetry to send traces to Sentry
.AddSentry(dsn)
Comment thread
Flash0ver marked this conversation as resolved.
Outdated
);

builder.WebHost.UseSentry(options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.OpenTelemetry/Sentry.OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<!-- Version 1.6.0 is the minimum version that does not have trim warnings -->
<PackageReference Include="OpenTelemetry" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.6.0" />
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry.OpenTelemetry/SentryOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static void UseOpenTelemetry(
/// <summary>
/// <para>Configures Sentry to use OpenTelemetry for distributed tracing.</para>
/// <para>
/// Note: if you are using this method to configure Sentry to work with OpenTelemetry you will also have to call
/// <see cref="TracerProviderBuilderExtensions.AddSentry"/> when building your <see cref="TracerProviderBuilder"/>
/// Note: if you are using this method to configure Sentry to work with OpenTelemetry, you will also have to call
/// TracerProviderBuilderExtensions.AddSentry when building your <see cref="TracerProviderBuilder"/>
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
/// to ensure OpenTelemetry sends trace information to Sentry.
/// </para>
/// </summary>
Expand Down
88 changes: 68 additions & 20 deletions src/Sentry.OpenTelemetry/TracerProviderBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Exporter;
using OpenTelemetry.Trace;
using Sentry.Extensibility;

Expand All @@ -11,27 +12,74 @@ namespace Sentry.OpenTelemetry;
/// </summary>
public static class TracerProviderBuilderExtensions
{
/// <summary>
/// Ensures OpenTelemetry trace information is sent to Sentry.
/// </summary>
/// <param name="tracerProviderBuilder"><see cref="TracerProviderBuilder"/>.</param>
/// <param name="defaultTextMapPropagator">
/// <para>The default TextMapPropagator to be used by OpenTelemetry.</para>
/// <para>
/// If this parameter is not supplied, the <see cref="SentryPropagator"/> will be used, which propagates the
/// baggage header as well as Sentry trace headers.
/// </para>
/// <para>
/// The <see cref="SentryPropagator"/> is required for Sentry's OpenTelemetry integration to work but you
/// could wrap this in a <see cref="CompositeTextMapPropagator"/> if you needed other propagators as well.
/// </para>
/// </param>
/// <returns>The supplied <see cref="TracerProviderBuilder"/> for chaining.</returns>
public static TracerProviderBuilder AddSentry(this TracerProviderBuilder tracerProviderBuilder, TextMapPropagator? defaultTextMapPropagator = null)
extension(TracerProviderBuilder tracerProviderBuilder)
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
{
defaultTextMapPropagator ??= new SentryPropagator();
Sdk.SetDefaultTextMapPropagator(defaultTextMapPropagator);
return tracerProviderBuilder.AddProcessor(ImplementationFactory);
/// <summary>
/// Ensures OpenTelemetry trace information is sent to Sentry.
/// </summary>
/// <param name="defaultTextMapPropagator">
/// <para>The default TextMapPropagator to be used by OpenTelemetry.</para>
/// <para>
/// If this parameter is not supplied, the <see cref="SentryPropagator"/> will be used, which propagates the
/// baggage header as well as Sentry trace headers.
/// </para>
/// <para>
/// The <see cref="SentryPropagator"/> is required for Sentry's OpenTelemetry integration to work but you
/// could wrap this in a <see cref="CompositeTextMapPropagator"/> if you needed other propagators as well.
/// </para>
/// </param>
/// <returns>The supplied <see cref="TracerProviderBuilder"/> for chaining.</returns>
public TracerProviderBuilder AddSentry(TextMapPropagator? defaultTextMapPropagator = null)
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
{
defaultTextMapPropagator ??= new SentryPropagator();
Sdk.SetDefaultTextMapPropagator(defaultTextMapPropagator);
return tracerProviderBuilder.AddProcessor(ImplementationFactory);
}

/// <summary>
/// Ensures OpenTelemetry trace information is sent to the Sentry OTLP endpoint.
/// </summary>
/// <param name="dsnString">The DSN for your Sentry project</param>
/// <param name="defaultTextMapPropagator">
/// <para>The default TextMapPropagator to be used by OpenTelemetry.</para>
/// <para>
/// If this parameter is not supplied, the <see cref="SentryPropagator"/> will be used, which propagates the
/// baggage header as well as Sentry trace headers.
/// </para>
/// <para>
/// The <see cref="SentryPropagator"/> is required for Sentry's OpenTelemetry integration to work but you
/// could wrap this in a <see cref="CompositeTextMapPropagator"/> if you needed other propagators as well.
/// </para>
/// </param>
/// <returns>The supplied <see cref="TracerProviderBuilder"/> for chaining.</returns>
public TracerProviderBuilder AddSentry(string dsnString, TextMapPropagator? defaultTextMapPropagator = null)
{
if (string.IsNullOrWhiteSpace(dsnString))
{
throw new ArgumentException("OTLP endpoint must be provided", nameof(dsnString));
}

defaultTextMapPropagator ??= new SentryPropagator();
Sdk.SetDefaultTextMapPropagator(defaultTextMapPropagator);

if (Dsn.TryParse(dsnString) is not { } dsn)
{
return tracerProviderBuilder;
}

tracerProviderBuilder.AddOtlpExporter(options =>
{
options.Endpoint = dsn.GetOtlpTracesEndpointUri();
options.Protocol = OtlpExportProtocol.HttpProtobuf;
options.HttpClientFactory = () =>
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Sentry-Auth", $"sentry sentry_key={dsn.PublicKey}");
return client;
};
});
return tracerProviderBuilder.AddProcessor(ImplementationFactory);
}
}

internal static BaseProcessor<Activity> ImplementationFactory(IServiceProvider services)
Expand Down
2 changes: 2 additions & 0 deletions src/Sentry/Dsn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ private Dsn(

public Uri GetEnvelopeEndpointUri() => new(ApiBaseUri, "envelope/");

public Uri GetOtlpTracesEndpointUri() => new(ApiBaseUri, "integration/otlp/v1/traces");

public override string ToString() => Source;

public static bool IsDisabled(string? dsn) =>
Expand Down
Loading