Hey SigNoz Team, I've a question about spans an c...
# support
b
Hey SigNoz Team, I've a question about spans an correlation-ids. In our infrastructure a middleware generates a correlation-id with the first request. This correlation-id is the same for all further internal reuests (http and message-broker/rabbitmq). So if an error occured, we can track it down to that correlation id. Is it possible to aggregate a span in a way, that it contains everything that belongs to one correlation-id? E.g. we make a request from /auth/register to /internal/auth/register-company and the second endpoints throws an error, that the span contains the entire call-trace?
1
p
thanks @Benedikt for the question. @Srikanth Chekuri do you have more insights on this? @Chenna Benedikt's stack is C# and asp.net core - which is the same as you were working with. Are there any .NET specific thinsg here which he should take care of?
b
Our code is open-source too at most points. If you want, I can give you access 🙂 Thanks for your fast replies, very nice here!
s
@Benedikt Did you already have instrumentation setup for you code?
b
yes:
here we are register everything
s
Nice, One of the capabilities is that you can customize the trace id (by default random). You could implement the custom id generator and use the correlation as trace id. And then SigNoz will show you the full stack trace info
b
The correlation-id is valid for the entire request-scope
that sounds great!
As far as I understand everything, this will be done by adding a new processor?
s
No, just the id generator should be fine. Let me take a look at your code and come back where you can hook in this.
a
@Benedikt apart from the way Srikanth is suggesting, any reason to stick to existing correlation-id? TraceId was created for this purpose only - to stitch together spans. As an example, opentelemetry is going deeper into every system/stack that you use. Starting from frontend to db to queues and going forward new softwares come integrated with otel traces. I hope you do not get into some conflict later due to use of your own correlation id. Though for the time being, it might be okay to replace the id generator for compatibility.
s
@Benedikt Unfortunately the .NET SDK doesn't support the IdGenerator yet. So you either need to create your own extension or as Ankit mentioned just use the default randomly generated trace id.
b
Sorry for the late repsonse, I've had to join some meetings. Using an existing trace id might be an option too. I only need to pass it to the next service some how. Is it possible to store it in the http-header?
Therefore I need to add it to my current IRequestContext. Should work as well
s
The trace context (usually w3c header) is propagated automatically as long as you have SDK and instrumentation setup properly. Did you try using the auto instrumentation?
b
so, if I create a request inside a controller, the trace-id is passed?
s
Yes, it should be propagated to downstream services.
b
Ok, I will try this:
Copy code
client.DefaultRequestHeaders.Add("trace-id", $"{requestContext.CorrelationId}");
ok, it seems like i need to set the entire traceparent
Ok, I could solve this problem easily with AddProcessor, this problem here is, that it does not recognize DI for scoped services
I will try to add this, maybe this is a good solution for others too
s
I am not sure what you are trying to do but context propagation doesn't require a processor. What will this processor do?
b
The processor is invokes when starting an activity
inside this I can set the trace-id, span-id etc...
so setting it to the correlation-id was a try
s
inside this I can set the trace-id, span-id etc...
I am trying to say this manual step is not needed. The auto instrumentation should take care of it.
b
Ok, but I get a new span-id and trace-id on every request. Maybe I'm doing something else wrong
You had right
got it!
thanks!
I had to use:
Copy code
.AddHttpClientInstrumentation(o =>
                       {
                           o.RecordException = true;
                       });
s
Awesome