https://signoz.io logo
#support
Title
# support
b

Benedikt

06/07/2022, 11:47 AM
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

Pranay

06/07/2022, 11:52 AM
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

Benedikt

06/07/2022, 11:53 AM
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

Srikanth Chekuri

06/07/2022, 11:54 AM
@Benedikt Did you already have instrumentation setup for you code?
b

Benedikt

06/07/2022, 11:54 AM
yes:
here we are register everything
s

Srikanth Chekuri

06/07/2022, 11:56 AM
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

Benedikt

06/07/2022, 11:56 AM
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

Srikanth Chekuri

06/07/2022, 11:57 AM
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

Ankit Nayan

06/07/2022, 12:17 PM
@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

Srikanth Chekuri

06/07/2022, 12:32 PM
@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

Benedikt

06/07/2022, 2:23 PM
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

Srikanth Chekuri

06/07/2022, 2:31 PM
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

Benedikt

06/07/2022, 2:31 PM
so, if I create a request inside a controller, the trace-id is passed?
s

Srikanth Chekuri

06/07/2022, 2:32 PM
Yes, it should be propagated to downstream services.
b

Benedikt

06/07/2022, 3:05 PM
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

Srikanth Chekuri

06/07/2022, 4:16 PM
I am not sure what you are trying to do but context propagation doesn't require a processor. What will this processor do?
b

Benedikt

06/07/2022, 4:16 PM
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

Srikanth Chekuri

06/07/2022, 4:17 PM
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

Benedikt

06/07/2022, 4:23 PM
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

Srikanth Chekuri

06/07/2022, 7:43 PM
Awesome
2 Views