skywalking

.Net Core how to get traceId Skywalking


I'm using SkyAPM.Agent.AspNetCore 1.1.0, and I need to get the trace id in my code and do something.

However, I didn't find enough information anywhere. Any suggestion?


Solution

  • Seems I found the solution from the source code.
    First inject the IEntrySegmentContextAccessor in the constuctor, then get the traceId by _entrySegmentContextAccessor.Context.TraceId