Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void Initialize(ITelemetry telemetry)
 {
     if (OperationIdContext.Get() != null)
     {
         telemetry.Context.Operation.Id = OperationIdContext.Get();
     }
 }
Exemplo n.º 3
0
        private void TraceException(Exception e)
        {
            var telemetry = new ExceptionTelemetry(e);

            telemetry.Context.Operation.Id = OperationIdContext.Get();

            _client.TrackException(telemetry);
        }
Exemplo n.º 4
0
        public override async Task Invoke(IOwinContext context)
        {
            var operationId = context.Get <string>(Consts.OperationIdContextKey);

            if (operationId != null)
            {
                OperationIdContext.Set(operationId);
            }

            await Next.Invoke(context);
        }
Exemplo n.º 5
0
        public override async Task Invoke(IOwinContext context)
        {
            InitializeOperationIdContext(context);

            try
            {
                await Next.Invoke(context);
            }
            finally
            {
                context.Set <string>(Consts.OperationIdContextKey, null);
                OperationIdContext.Clear();
            }
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        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);
        }