Skip to content

Instantly share code, notes, and snippets.

@MihaZupan
Created July 13, 2021 20:52
Show Gist options
  • Save MihaZupan/c01a2689f5ec85e95682830fb0df8e17 to your computer and use it in GitHub Desktop.
Save MihaZupan/c01a2689f5ec85e95682830fb0df8e17 to your computer and use it in GitHub Desktop.
DistributedContextPropagator.Current = new SkipHttpClientActivityPropagator();
public sealed class SkipHttpClientActivityPropagator : DistributedContextPropagator
{
private readonly DistributedContextPropagator _originalPropagator = Current;
public override IReadOnlyCollection<string> Fields => _originalPropagator.Fields;
public override void Inject(Activity? activity, object? carrier, PropagatorSetterCallback? setter)
{
if (activity?.OperationName == "System.Net.Http.HttpRequestOut")
{
activity = activity.Parent;
}
_originalPropagator.Inject(activity, carrier, setter);
}
public override void ExtractTraceIdAndState(object? carrier, PropagatorGetterCallback? getter, out string? traceId, out string? traceState) =>
_originalPropagator.ExtractTraceIdAndState(carrier, getter, out traceId, out traceState);
public override IEnumerable<KeyValuePair<string, string?>>? ExtractBaggage(object? carrier, PropagatorGetterCallback? getter) =>
_originalPropagator.ExtractBaggage(carrier, getter);
}
@paku-he
Copy link

paku-he commented Apr 29, 2024

@wkoeter would you be able to provide more details ?
What do you mean that this workaround caused application map incomplete ?

I would appreciate your expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment