Comments (11)
@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.
from opentelemetry-dotnet-contrib.
The best we can do is to document this behaviour. Tagging this as a documentation issue.
from opentelemetry-dotnet-contrib.
@mitoihs You can use a diff. sampler other than the default ParentBased sampler. This should give you the required solution for you.
from opentelemetry-dotnet-contrib.
Did some investigation, the reason the HttpClient span does not show up without adding the ASP.NET Core instrumentation is because the ParentBasedSampler
always makes a NotRecord
decision.
-
It does have a parent (the ASP.NET Core HTTP IN activity), so
parentContext.SpanId != default
here
https://github.com/open-telemetry/opentelemetry-dotnet/blob/32fb7c12f1269147bea1080f04ea4ba489aa0f63/src/OpenTelemetry/Trace/ParentBasedSampler.cs#L43-L49 -
The parent's
TraceFlags
do not indicateRecorded
here
https://github.com/open-telemetry/opentelemetry-dotnet/blob/32fb7c12f1269147bea1080f04ea4ba489aa0f63/src/OpenTelemetry/Trace/ParentBasedSampler.cs#L51-L55 -
So the sampling decision always falls through to here
https://github.com/open-telemetry/opentelemetry-dotnet/blob/32fb7c12f1269147bea1080f04ea4ba489aa0f63/src/OpenTelemetry/Trace/ParentBasedSampler.cs#L69-L70
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 ParentBasedSampler
...
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.
from opentelemetry-dotnet-contrib.
Same issue reported differently:
As reported in gitter channel this is an issue if you try to start own activity inside an AspNetCore application without enabling the AspNetCoreInstrumentation.
from opentelemetry-dotnet-contrib.
I've just hit that issue. I just need to trace my custom Activities
(effectively I have AddSource
in place of AddHttpClientInstrumentation
of the example) and don't care about AspNetCoreInstrumentation
but still, I can't turn it off or nothing is logged. I've tried to turn it on and filter everything out (.AddAspNetCoreInstrumentation(c => c.Filter = ctx => false)
) but it's not working in that case also. That's sad. Is there a way to "turn on" tracing in ASP .NET Core without listening to "built-in" activities?
from opentelemetry-dotnet-contrib.
@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.
from opentelemetry-dotnet-contrib.
The demos could default to AlwaysOnSampler ?
from opentelemetry-dotnet-contrib.
In the actual demo AddAspNetCoreInstrumentation
is added so it actually works fine. We were just messing with it to capture some screenshots and disabled AddAspNetCoreInstrumentation
temporarily thinking that would cause just the custom stuff to show in the console when in reality it caused everything to disappear 😆
from opentelemetry-dotnet-contrib.
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.
from opentelemetry-dotnet-contrib.
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?)
from opentelemetry-dotnet-contrib.
Related Issues (20)
- [Resources.Azure] Rename `AddAppServiceDetector` to `AddAzureAppServiceDetector` HOT 1
- Rename `OpenTelemetry.Instrumentation.StackExchangeRedis` to a more generic name HOT 1
- [HttpClient] add {target} to span name
- RuntimeInstrumentationOptions has no properties HOT 1
- AWS X-Ray traces without span info
- [ConfluentKafka] Implement a process span to ease connecting traces
- Add unit tests to ConfluentKafka instrumentration
- Add instructions to configure ConfluentKafka instrumentation HOT 2
- Add CoreWCF Instrumentation HOT 1
- Migrate semantic conventions generation to Weaver
- Activity.DisplayName is overwritten by instrumentation libraries HOT 10
- Missing documentation for `OTEL_DOTNET_EXPERIMENTAL_OWIN_DISABLE_URL_QUERY_REDACTION` HOT 5
- [Instrumentation.StackExchangeRedis] Vunerability warning due to transitive dependency HOT 1
- AWS Instrumenting doesn't work when AWS DynamoDb Client is created in a DI class
- Make DisableUrlQueryRedaction option in OpenTelemetry.Instrumentation.Http public HOT 2
- Add additional os.types HOT 1
- Populate additional os fields HOT 1
- Provide OS Platform HOT 2
- `OTEL_DOTNET_EXPERIMENTAL_{component}_DISABLE_URL_QUERY_REDACTION` is not honored via `Configuration` for `Owin` and `AspNet` instrumentations HOT 6
- Registering instrumentation libraries more than once adds duplicate Activity listeners
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentelemetry-dotnet-contrib.