public HttpCoreDiagnosticSourceListener( TelemetryConfiguration configuration, bool setComponentCorrelationHttpHeaders, IEnumerable <string> correlationDomainExclusionList, bool injectLegacyHeaders, bool injectRequestIdInW3CMode, HttpInstrumentationVersion instrumentationVersion) { this.client = new TelemetryClient(configuration); this.client.Context.GetInternalContext().SdkVersion = SdkVersionUtils.GetSdkVersion("rdd" + RddSource.DiagnosticSourceCore + ":"); this.configuration = configuration; this.applicationInsightsUrlFilter = new ApplicationInsightsUrlFilter(configuration); this.setComponentCorrelationHttpHeaders = setComponentCorrelationHttpHeaders; this.correlationDomainExclusionList = correlationDomainExclusionList ?? Enumerable.Empty <string>(); this.injectLegacyHeaders = injectLegacyHeaders; this.httpInstrumentationVersion = instrumentationVersion != HttpInstrumentationVersion.Unknown ? instrumentationVersion : this.GetInstrumentationVersion(); this.injectRequestIdInW3CMode = injectRequestIdInW3CMode; this.subscriber = new HttpCoreDiagnosticSourceSubscriber( this, this.applicationInsightsUrlFilter, this.httpInstrumentationVersion); }
private HttpCoreDiagnosticSourceListener CreateHttpListener(HttpInstrumentationVersion instrumentationVersion) { return(new HttpCoreDiagnosticSourceListener( this.configuration, setComponentCorrelationHttpHeaders: true, correlationDomainExclusionList: new string[0], injectLegacyHeaders: false, injectRequestIdInW3CMode: true, instrumentationVersion)); }
internal HttpCoreDiagnosticSourceSubscriber( HttpCoreDiagnosticSourceListener listener, ApplicationInsightsUrlFilter applicationInsightsUrlFilter, HttpInstrumentationVersion httpInstrumentationVersion) { this.httpDiagnosticListener = listener; this.applicationInsightsUrlFilter = applicationInsightsUrlFilter; this.httpInstrumentationVersion = httpInstrumentationVersion; try { this.listenerSubscription = DiagnosticListener.AllListeners.Subscribe(this); } catch (Exception ex) { DependencyCollectorEventSource.Log.HttpCoreDiagnosticSubscriberFailedToSubscribe(ex.ToInvariantString()); } SubscriptionManager.Attach(this.httpDiagnosticListener); }
private HttpInstrumentationVersion GetInstrumentationVersion() { HttpInstrumentationVersion version = HttpInstrumentationVersion.Unknown; var httpClientAssembly = typeof(HttpClient).GetTypeInfo().Assembly; var httpClientVersion = httpClientAssembly.GetName().Version; string httpClientInformationalVersion = httpClientAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty; if (httpClientInformationalVersion.StartsWith("3.", StringComparison.Ordinal)) { version = HttpInstrumentationVersion.V3; } else if (httpClientVersion.Major == 4 && httpClientVersion.Minor == 2) { // .NET Core 3.0 has the same version of http client lib as 2.* // but AssemblyInformationalVersionAttribute is different. version = HttpInstrumentationVersion.V2; } else if (httpClientVersion.Major == 4 && httpClientVersion.Minor < 2) { version = HttpInstrumentationVersion.V1; } else { // fallback to V3 assuming unknown SDKs are from future versions version = HttpInstrumentationVersion.V3; } DependencyCollectorEventSource.Log.HttpCoreDiagnosticListenerInstrumentationVersion( (int)version, httpClientVersion.Major, httpClientVersion.Minor, httpClientInformationalVersion); return(version); }