-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathOtelPropagationContext.cs
More file actions
28 lines (23 loc) · 1.07 KB
/
OtelPropagationContext.cs
File metadata and controls
28 lines (23 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Sentry.Extensibility;
using Sentry.Internal;
namespace Sentry.OpenTelemetry;
internal class OtelPropagationContext : IPropagationContext
{
public DynamicSamplingContext? DynamicSamplingContext { get; private set; }
public SentryId TraceId => Activity.Current?.TraceId.AsSentryId() ?? default;
public SpanId SpanId => Activity.Current?.SpanId.AsSentrySpanId() ?? default;
public SpanId? ParentSpanId => Activity.Current?.ParentSpanId.AsSentrySpanId();
/// <summary>
/// Warning: this method may throw an exception if Activity.Current is null.
/// This method should not be used when instrumenting with OTEL.
/// </summary>
public DynamicSamplingContext GetOrCreateDynamicSamplingContext(SentryOptions options, IReplaySession replaySession)
{
if (DynamicSamplingContext is null)
{
options.LogDebug("Creating the Dynamic Sampling Context from the Propagation Context.");
DynamicSamplingContext = this.CreateDynamicSamplingContext(options, replaySession);
}
return DynamicSamplingContext;
}
}