Description
SInce we have IDisposable implemented for ISpan interface (PR #4627), is there any way to connect a parent of manually instrumented spans with a child span of automatically instrumented OTel span?
This is my current setup:
builder.Services.AddOpenTelemetry()
.WithTracing(tracerProviderBuilder =>
tracerProviderBuilder
.AddSource("MyProgram")
.AddAspNetCoreInstrumentation()
.AddRedisInstrumentation()
.AddHttpClientInstrumentation()
.AddGrpcClientInstrumentation()
.AddNpgsql()
.AddSentry()
);
builder.WebHost.UseSentry(options => {
options.SampleRate = (float?)1.0;
options.TracesSampleRate = 1.0;
options.SendDefaultPii = true;
options.UseOpenTelemetry();
options.DisableSentryHttpMessageHandler = true;
});
With this current setup, I always use ActivitySource on my application-level methods, like so:
public class PasswordManagementService() {
private static readonly ActivitySource ActivitySource = new("MyProgram");
public async Task ChangePassword(ChangePasswordRequest request, CancellationToken cancellationToken) {
using Activity? activity = ActivitySource.StartActivity();
// do things
// queries to PostgreSQL here
}
}
The span is connected, but sadly it won't connect the errors perfectly. What I want to do is to directly use the StartSpan() method from Sentry, while still having the trace of PostgreSQL query from OTel being a child of the said span. Therefore the code will become:
public class PasswordManagementService() {
public async Task ChangePassword(ChangePasswordRequest request, CancellationToken cancellationToken) {
using var span = SentrySdk.StartSpan(operation: "function", description: "ChangePassword");
// do things
// queries to PostgreSQL here (using OTel, as I want to capture it automatically)
}
}
Is there any workaround for this other than creating the span for PostgreSQL database operation manually?
Description
SInce we have
IDisposableimplemented forISpaninterface (PR #4627), is there any way to connect a parent of manually instrumented spans with a child span of automatically instrumented OTel span?This is my current setup:
With this current setup, I always use
ActivitySourceon my application-level methods, like so:The span is connected, but sadly it won't connect the errors perfectly. What I want to do is to directly use the
StartSpan()method from Sentry, while still having the trace of PostgreSQL query from OTel being a child of the said span. Therefore the code will become:Is there any workaround for this other than creating the span for PostgreSQL database operation manually?