Add propagation to filtered out events from HttpClient (#1707)
* Add propagation to filtered out events * Fix HttpInstrumentationEventSource.cs * Added CHANGELOG.md Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
9e9987a3a3
commit
05bba18f4d
|
|
@ -6,6 +6,12 @@
|
|||
description/reason phrase for outgoing http spans.
|
||||
([#1579](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1579))
|
||||
|
||||
* Moved the DiagnosticListener filtering logic from HttpClientInstrumentation
|
||||
ctor to OnStartActivity method of HttpHandlerDiagnosticListener.cs; Updated
|
||||
the logic of OnStartActivity to inject propagation data into Headers for
|
||||
filtered out events as well.
|
||||
([#1707](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1707))
|
||||
|
||||
## 1.0.0-rc1.1
|
||||
|
||||
Released 2020-Nov-17
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace OpenTelemetry.Instrumentation.Http
|
|||
/// <param name="options">Configuration options for HTTP client instrumentation.</param>
|
||||
public HttpClientInstrumentation(ActivitySourceAdapter activitySourceAdapter, HttpClientInstrumentationOptions options)
|
||||
{
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options, activitySourceAdapter), (activityName, arg1, arg2) => options?.EventFilter(activityName, arg1) ?? true);
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options, activitySourceAdapter), null);
|
||||
this.diagnosticSourceSubscriber.Subscribe();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,29 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
return;
|
||||
}
|
||||
|
||||
var textMapPropagator = Propagators.DefaultTextMapPropagator;
|
||||
|
||||
if (!(this.httpClientSupportsW3C && textMapPropagator is TraceContextPropagator))
|
||||
{
|
||||
textMapPropagator.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageContextPropagation.HeaderValueSetter);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (this.options.EventFilter(activity.OperationName, request) == false)
|
||||
{
|
||||
HttpInstrumentationEventSource.Log.RequestIsFilteredOut(activity.OperationName);
|
||||
activity.IsAllDataRequested = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HttpInstrumentationEventSource.Log.RequestFilterException(ex);
|
||||
activity.IsAllDataRequested = false;
|
||||
return;
|
||||
}
|
||||
|
||||
activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method);
|
||||
|
||||
this.activitySource.Start(activity, ActivityKind.Client, ActivitySource);
|
||||
|
|
@ -106,13 +129,6 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
HttpInstrumentationEventSource.Log.EnrichmentException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
var textMapPropagator = Propagators.DefaultTextMapPropagator;
|
||||
|
||||
if (!(this.httpClientSupportsW3C && textMapPropagator is TraceContextPropagator))
|
||||
{
|
||||
textMapPropagator.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageContextPropagation.HeaderValueSetter);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStopActivity(Activity activity, object payload)
|
||||
|
|
|
|||
|
|
@ -93,5 +93,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
{
|
||||
this.WriteEvent(5, exception);
|
||||
}
|
||||
|
||||
[Event(6, Message = "Request is filtered out.", Level = EventLevel.Verbose)]
|
||||
public void RequestIsFilteredOut(string eventName)
|
||||
{
|
||||
this.WriteEvent(6, eventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue