Comments (8)
Thanks for the feedback, @toqueteos. We will look into improving usability in this area soon. In the meantime, note that passing a null SpanContext
to Tracer.StartActive
creates a span that is a child of the currently active span. null
is the default value for that optional parameter, so in most cases you can just call:
var scope = Tracer.StartActive(operationName);
from dd-trace-dotnet.
@HenryYuST: You need to fork the repo to create a PR. See the GitHub documentation on this topic. I recommend talking to the dev team to plan new features before doing any work, though.
Back to the original issue, the Tracer library treats propagated contexts differently that local ones. The best way to propagate a span's context across services (aka distributed tracing) it to pass the trace id and span id (which are available on Span
) to the remote process, and create a new SpanContext
there.
// locally
var traceId = span.TraceId;
var spanId = span.SpanId;
// pass those values to the remote process (e.g. in http headers)
// and create a new "propagated" context there
var propagatedContext = new SpanContext(traceId, spanId);
@nle-solutiontek: We need to consider the implications of making this property public
. Once it's done, it's part of the public API and harder to change without breaking changes. If we do this, we probably want to expose an ISpanContext
instead of the concrete SpanContext
type, for example.
from dd-trace-dotnet.
Hi folks,
There were no updates on this issue for a while. I will go ahead and close it, but please feel free to reopen if you feel this is still actionable.
In this context, please note that we are currently working on support for .NET native Activity APIs, which should certainly support this scenario.
from dd-trace-dotnet.
Good to know, thank you very much Lucas!
from dd-trace-dotnet.
@lucaspimentel any update on this issue?
from dd-trace-dotnet.
@lucaspimentel For the solution, is it possible to have more than one active spans at a given time? If you have more than one active spans, which parent span are you going to assign to the child span that you're creating?
from dd-trace-dotnet.
Correct me if I'm wrong but I think your suggestion does not work when we are tracing across 2 independent services. We would like to be able to see spans from different services in the same flame graph. So we are trying to create child spans using a span from a different service as the parent span.
We found out in order to be able to trace a message between two independent services, we need to pass SpanContext to the receiver so that the receiver can create a child span using the context from the sender.
After making the changes below to Span.cs, we were able to make it work. Would you consider making the following changes at
dd-trace-dotnet/src/Datadog.Trace/Span.cs
Line 70 in de87820
to
/// <summary>
/// Gets the span context.
/// </summary>
public SpanContext Context { get; }
I tried to create a pull request but did not have the permission to do so.
Thank you.
from dd-trace-dotnet.
@lucaspimentel is it possible to get this implemented? Changing from internal to public seems to work just fine
from dd-trace-dotnet.
Related Issues (20)
- DataDog tracer detects incorrect .NET 6 Runtime version HOT 2
- Sporadic TypeLoadException HOT 4
- 502 error on POST
- MQ integration prepends BOM to message body HOT 4
- Bundled Tracer fails to load with .NET 8 and COMPlus_EnableDiagnostics=0 HOT 11
- System.NullReferenceException in RedisExecuteAsyncIntegration.OnMethodBegin(RedisBase , Message& , ResultProcessor`1& , ServerEndPoint& ) HOT 2
- Support `Microsoft.Azure.WebJobs.Extensions.Kafka.KafkaTrigger` in Azure Functions
- Understand correct approach to encapsulating the `dd-trace-dotnet` sdk HOT 2
- Instrument Quartz.Net HOT 1
- Auto-instrumentation for Blazor HOT 4
- Support Span LInks HOT 3
- Tracer agent stops reporting APM data HOT 2
- OpSysTools::IsSafeToStartProfiler always returns false HOT 2
- CosmosDB autoinstumentation of addtional container methods
- Image "gcr.io/datadoghq/dd-lib-dotnet-init:latest" NotFound desc = failed to pull and unpack image "gcr.io/datadoghq/dd-lib-dotnet-init:latest": no match for platform in manifest: not found HOT 5
- Problem with Azure ServiceBus distributed trace HOT 4
- Tracer logs are written to disk instead of stdout/stderr in kubernetes
- dd-trace CLI does not respect the DD_CIVISIBILITY_CODE_COVERAGE_ENABLED env variable HOT 1
- Using native tracer on .NET 6+ app significantly impacts performance and scalability of Azure Function Isolated Worker w/ ASP.net Core Integration
- Optimise dependencies HOT 4
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 dd-trace-dotnet.