private void TraceRequest( string method, string path, Uri uri, IOwinContext context, int responseCode, DateTimeOffset requestStartDate, TimeSpan duration) { var name = $"{method} {path}"; var telemetry = new RequestTelemetry( name, requestStartDate, duration, responseCode.ToString(), responseCode < 400) { Id = OperationIdContext.Get(), HttpMethod = method, Url = uri }; telemetry.Context.Operation.Name = name; foreach (var kvp in GetContextProperties(context)) { telemetry.Context.Properties.Add(kvp); } _client.TrackRequest(telemetry); }
public void Initialize(ITelemetry telemetry) { if (OperationIdContext.Get() != null) { telemetry.Context.Operation.Id = OperationIdContext.Get(); } }
private void TraceException(Exception e) { var telemetry = new ExceptionTelemetry(e); telemetry.Context.Operation.Id = OperationIdContext.Get(); _client.TrackException(telemetry); }
public override async Task Invoke(IOwinContext context) { var operationId = context.Get <string>(Consts.OperationIdContextKey); if (operationId != null) { OperationIdContext.Set(operationId); } await Next.Invoke(context); }
public override async Task Invoke(IOwinContext context) { InitializeOperationIdContext(context); try { await Next.Invoke(context); } finally { context.Set <string>(Consts.OperationIdContextKey, null); OperationIdContext.Clear(); } }
private void InitializeOperationIdContext(IOwinContext context) { string idContextKey; if (_configuration.ShouldTryGetIdFromHeader && TryGetIdFromHeader(context, out idContextKey)) { OperationIdContext.Set(idContextKey); } else { OperationIdContext.Create(); } context.Set(Consts.OperationIdContextKey, OperationIdContext.Get()); }
private void TraceRequest(string method, string path, Uri uri, int responseCode, DateTimeOffset requestStartDate, TimeSpan duration) { var name = $"{method} {path}"; var telemetry = new RequestTelemetry( name, requestStartDate, duration, responseCode.ToString(), responseCode < 400) { Id = OperationIdContext.Get(), HttpMethod = method, Url = uri }; telemetry.Context.Operation.Name = name; _client.TrackRequest(telemetry); }