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

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

            _client.TrackException(telemetry);
        }
示例#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);
        }
示例#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();
            }
        }
示例#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());
        }
示例#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);
        }