GithubHelp home page GithubHelp logo

Comments (8)

lucaspimentel avatar lucaspimentel commented on June 7, 2024 3

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.

lucaspimentel avatar lucaspimentel commented on June 7, 2024 1

@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.

macrogreg avatar macrogreg commented on June 7, 2024 1

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.

toqueteos avatar toqueteos commented on June 7, 2024

Good to know, thank you very much Lucas!

from dd-trace-dotnet.

stevenhaohuitan avatar stevenhaohuitan commented on June 7, 2024

@lucaspimentel any update on this issue?

from dd-trace-dotnet.

stevenhaohuitan avatar stevenhaohuitan commented on June 7, 2024

@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.

HenryYuST avatar HenryYuST commented on June 7, 2024

@lucaspimentel

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

internal SpanContext Context { get; }

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.

nle-solutiontek avatar nle-solutiontek commented on June 7, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.