Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Sentry/IScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public interface IScopeObserver
/// Sets the user information.
/// </summary>
void SetUser(SentryUser? user);

/// <summary>
/// Sets the current trace
/// </summary>
void SetTrace(SentryId traceId, SpanId parentSpanId);
}
2 changes: 1 addition & 1 deletion src/Sentry/Internal/Hub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public TransactionContext ContinueTrace(
string? operation = null)
{
var propagationContext = SentryPropagationContext.CreateFromHeaders(_options.DiagnosticLogger, traceHeader, baggageHeader);
ConfigureScope(scope => scope.PropagationContext = propagationContext);
ConfigureScope(scope => scope.SetPropagationContext(propagationContext));

return new TransactionContext(
name: name ?? string.Empty,
Expand Down
5 changes: 5 additions & 0 deletions src/Sentry/Internal/ScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public void SetUser(SentryUser? user)
}
}

public void SetTrace(SentryId traceId, SpanId parentSpanId)
{
throw new NotImplementedException();
}

public abstract void SetUserImpl(SentryUser user);

public abstract void UnsetUserImpl();
Expand Down
11 changes: 10 additions & 1 deletion src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public ITransactionTracer? Transaction
}
}

internal SentryPropagationContext PropagationContext { get; set; }
internal SentryPropagationContext PropagationContext { get; private set; }

internal SessionUpdate? SessionUpdate { get; set; }

Expand Down Expand Up @@ -376,6 +376,15 @@ public void UnsetTag(string key)
/// </summary>
public void AddAttachment(SentryAttachment attachment) => _attachments.Add(attachment);

internal void SetPropagationContext(SentryPropagationContext propagationContext)
{
PropagationContext = propagationContext;
if (Options.EnableScopeSync)
{
Options.ScopeObserver?.SetTrace(propagationContext.TraceId, propagationContext.SpanId);
}
}

/// <summary>
/// Resets all the properties and collections within the scope to their default values.
/// </summary>
Expand Down
Loading