Replies: 1 comment 1 reply
-
Can you provide more context? My best guess is that you're creating an activity before the audit scope is initialized. If that's the case, you would see the same trace ID but different span IDs for each audit scope. I ran the following test, and it behaved as expected: ActivitySource.AddActivityListener(new ActivityListener()
{
ShouldListenTo = f => true,
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData
});
Audit.Core.Configuration.Setup().UseInMemoryProvider();
var auditScopeFactory = new AuditScopeFactory();
using (var scope = auditScopeFactory.Create(new AuditScopeOptions() { IncludeActivityTrace = true, StartActivityTrace = true , ExtraFields = new { test = 1 }}))
{
Debug.WriteLine($"{scope.Event.Activity.TraceId}");
}
using (var scope = auditScopeFactory.Create(new AuditScopeOptions() { IncludeActivityTrace = true, StartActivityTrace = true, ExtraFields = new { test = 2 } }))
{
Debug.WriteLine($"{scope.Event.Activity.TraceId}");
} I see different trace ids for each scope. If I first create an activity and then create the audit scopes, this is the outcome: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I set StartActivityTrace=true in my auditScope with following code, I thought there is a new activity for each auditScope block. However the audit log "activity" shows the same trace_id and span_id for different auditScope blocks. I use Audt.NET 27.5.0 and NET8.
using (var auditScope = _auditScopeFactory.Create(new AuditScopeOptions()
{
EventType = "event1",
TargetGetter = () => order,
StartActivityTrace = true
}))
{
// my code
}
Beta Was this translation helpful? Give feedback.
All reactions