private void SetAppIdInResponseHeader(HttpContext httpContext, RequestTelemetry requestTelemetry) { if (this.injectResponseHeaders) { IHeaderDictionary responseHeaders = httpContext.Response?.Headers; if (responseHeaders != null && !string.IsNullOrEmpty(requestTelemetry.Context.InstrumentationKey) && (!responseHeaders.ContainsKey(RequestResponseHeaders.RequestContextHeader) || HttpHeadersUtilities.ContainsRequestContextKeyValue( responseHeaders, RequestResponseHeaders.RequestContextTargetKey))) { if (this.lastIKeyLookedUp != requestTelemetry.Context.InstrumentationKey) { var appIdResolved = this.applicationIdProvider?.TryGetApplicationId(requestTelemetry.Context.InstrumentationKey, out this.lastAppIdUsed); if (appIdResolved.HasValue && appIdResolved.Value) { this.lastIKeyLookedUp = requestTelemetry.Context.InstrumentationKey; } } HttpHeadersUtilities.SetRequestContextKeyValue( responseHeaders, RequestResponseHeaders.RequestContextTargetKey, this.lastAppIdUsed); } } }
private void SetAppIdInResponseHeader(HttpContext httpContext, RequestTelemetry requestTelemetry) { if (this.injectResponseHeaders) { IHeaderDictionary responseHeaders = httpContext.Response?.Headers; if (responseHeaders != null && !string.IsNullOrEmpty(requestTelemetry.Context.InstrumentationKey) && (!responseHeaders.ContainsKey(RequestResponseHeaders.RequestContextHeader) || HttpHeadersUtilities.ContainsRequestContextKeyValue(responseHeaders, RequestResponseHeaders.RequestContextTargetKey))) { string applicationId = null; if (this.applicationIdProvider?.TryGetApplicationId(requestTelemetry.Context.InstrumentationKey, out applicationId) ?? false) { HttpHeadersUtilities.SetRequestContextKeyValue(responseHeaders, RequestResponseHeaders.RequestContextTargetKey, applicationId); } } } }
private void SetAppIdInResponseHeader(HttpContext httpContext, RequestTelemetry requestTelemetry) { IHeaderDictionary responseHeaders = httpContext.Response?.Headers; if (responseHeaders != null && !string.IsNullOrEmpty(requestTelemetry.Context.InstrumentationKey) && (!responseHeaders.ContainsKey(RequestResponseHeaders.RequestContextHeader) || HttpHeadersUtilities.ContainsRequestContextKeyValue(responseHeaders, RequestResponseHeaders.RequestContextTargetKey))) { string correlationId = null; if (this.correlationIdLookupHelper.TryGetXComponentCorrelationId(requestTelemetry.Context.InstrumentationKey, out correlationId)) { HttpHeadersUtilities.SetRequestContextKeyValue(responseHeaders, RequestResponseHeaders.RequestContextTargetKey, correlationId); } } }