-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding only HttpClient instrumentation to ASP.NET Core app does not work #1779
Comments
Did some investigation, the reason the HttpClient span does not show up without adding the ASP.NET Core instrumentation is because the
I guess this behavior is expected, but it does seem a bit unintuitive. That is, as a user I explicitly decide I only want HttpClient instrumentation, but that does not prevent ASP.NET Core from creating activities which will often be the root activity in a trace and influence downstream sampling decisions. I suppose a work around would be to not use the I also can see an argument that it is an unlikely scenario that someone wants to use OpenTelemetry with their ASP.NET Core and not enable ASP.NET Core instrumentation. |
Same issue reported differently: |
@alanwest The root of the issue is some libraries (eg: Asp.Net Core) is creating activity irrespective of whether Otel asked is to do so. This is a "by design" behaviour for Asp.Net Core. Will try to see if Asp.Net Core has plans to disable this feature by default. |
The best we can do is to document this behaviour. Tagging this as a documentation issue. |
I've just hit that issue. I just need to trace my custom |
@mitoihs You can use a diff. sampler other than the default ParentBased sampler. This should give you the required solution for you. |
@cartersocha and I just ran into this too. In a demo we have something like... builder.Services.AddOpenTelemetryTracing(options =>
{
options
.SetResourceBuilder(resourceBuilder)
.AddSource("MyCustomSource") // Collect all traces from "MyCustomSource"
//.AddAspNetCoreInstrumentation() // Not enabling AspNetCore instrumentation
.AddConsoleExporter();
});
public Task<SupportCase?> GetAsync(string id)
{
using Activity? activity = MyCustomSource.StartActivity(nameof(GetAsync), ActivityKind.Client); // <- Returns null Activity
if (activity?.IsAllDataRequested == true)
{
activity.SetTag("entityId", id);
}
// Some logic here.
} The Activity from MyCustomSource is always null because the parent Activity created by AspNetCore has Recorded = false. Just documenting this, not sure if we should/could do anything about it. |
The demos could default to AlwaysOnSampler ? |
In the actual demo |
I don't think we're going to do anything with this @alanwest @CodeBlanch ? if not, we should close this as not planned rather than keeping it open. |
We haven't done the documentation to call this out : #1779 (comment) Maybe worth keeping it until someone helps add the documentation. (If we go native instrumentation route, then also this could be an issue?) |
Bug Report
If you only add HttpClient instrumentation to an ASP.NET Core app, no spans from HttpClient are collected.
The issue is not specific to HttpClient instrumentation. I have also reproduced this when adding only Grpc.Net.Client instrumentation.
Reproduce
Update
See my analysis below for the reason why this occurs. Some thoughts come to my mind on how best to address this issue.
ParentBasedSampler
.The text was updated successfully, but these errors were encountered: