コード例 #1
0
        public static void SetTracing(IApmContext apmContext)
        {
            var clientName      = apmContext.ContainsKey(Constants.ClientNamePropertyKey) ? (string)apmContext[Constants.ClientNamePropertyKey] : null;
            var incomingTraceId = apmContext.ContainsKey(Constants.IncomingTraceIdPropertyKey) ? (string)apmContext[Constants.IncomingTraceIdPropertyKey] : null;
            var incomingSpanId  = apmContext.ContainsKey(Constants.IncomingSpanIdPropertyKey) ? (string)apmContext[Constants.IncomingSpanIdPropertyKey] : null;
            var incomingFlags   = apmContext.ContainsKey(Constants.IncomingFlagsPropertyKey) ? (string)apmContext[Constants.IncomingFlagsPropertyKey] : null;
            var incomingSampled = apmContext.ContainsKey(Constants.IncomingSampledPropertyKey) ? (string)apmContext[Constants.IncomingSampledPropertyKey] : null;

            SetTracing(apmContext, clientName, incomingTraceId, incomingSpanId, incomingFlags, incomingSampled);
        }
コード例 #2
0
        public void AddIncomingSpanId(HttpRequestMessage request, IApmContext apmContext)
        {
            object incomingSpanIdProperty;
            string incomingSpanId;

            if (request.Properties.TryGetValue(Constants.IncomingSpanIdPropertyKey, out incomingSpanIdProperty))
            {
                incomingSpanId = (string)incomingSpanIdProperty;
                apmContext[Constants.IncomingSpanIdPropertyKey] = incomingSpanId;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.IncomingSpanIdPropertyKey))
                {
                    incomingSpanId = (string)apmContext[Constants.IncomingSpanIdPropertyKey];
                    request.Properties[Constants.IncomingSpanIdPropertyKey] = incomingSpanId;
                }
                else
                {
                    incomingSpanId = string.Empty;
                    apmContext[Constants.IncomingSpanIdPropertyKey]         = incomingSpanId;
                    request.Properties[Constants.IncomingSpanIdPropertyKey] = incomingSpanId;
                }
            }
        }
コード例 #3
0
        public void AddIncomingFlags(HttpRequestMessage request, IApmContext apmContext)
        {
            object incomingFlagsProperty;
            var    incomingFlags = string.Empty;

            if (request.Properties.TryGetValue(Constants.IncomingFlagsPropertyKey, out incomingFlagsProperty))
            {
                incomingFlags = (string)incomingFlagsProperty;
                apmContext[Constants.IncomingSampledPropertyKey] = incomingFlags;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.IncomingSampledPropertyKey))
                {
                    incomingFlags = (string)apmContext[Constants.IncomingSampledPropertyKey];
                    request.Properties[Constants.IncomingSampledPropertyKey] = incomingFlags;
                }
                else
                {
                    incomingFlags = string.Empty;
                    apmContext[Constants.IncomingSampledPropertyKey]         = incomingFlags;
                    request.Properties[Constants.IncomingSampledPropertyKey] = incomingFlags;
                }
            }
        }
コード例 #4
0
        public void AddTraceId(HttpRequestMessage request, IApmContext apmContext)
        {
            object traceIdProperty;
            var    traceId = string.Empty;

            if (request.Properties.TryGetValue(Constants.TraceIdHeaderKey, out traceIdProperty))
            {
                traceId = (string)traceIdProperty;
                apmContext[Constants.TraceIdHeaderKey] = traceId;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.TraceIdHeaderKey))
                {
                    traceId = (string)apmContext[Constants.TraceIdHeaderKey];
                    request.Properties[Constants.TraceIdHeaderKey] = traceId;
                }
                else
                {
                    traceId = string.Empty;
                    apmContext[Constants.TraceIdHeaderKey]         = traceId;
                    request.Properties[Constants.TraceIdHeaderKey] = traceId;
                }
            }
        }
コード例 #5
0
        public void AddParentSpanId(HttpRequestMessage request, IApmContext apmContext)
        {
            object parentSpanIdProperty;
            var    parentSpanId = string.Empty;

            if (request.Properties.TryGetValue(Constants.ParentSpanIdHeaderKey, out parentSpanIdProperty))
            {
                parentSpanId = (string)parentSpanIdProperty;
                apmContext[Constants.ParentSpanIdHeaderKey] = parentSpanId;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.ParentSpanIdHeaderKey))
                {
                    parentSpanId = (string)apmContext[Constants.ParentSpanIdHeaderKey];
                    request.Properties[Constants.ParentSpanIdHeaderKey] = parentSpanId;
                }
                else
                {
                    parentSpanId = string.Empty;
                    apmContext[Constants.ParentSpanIdHeaderKey]         = parentSpanId;
                    request.Properties[Constants.ParentSpanIdHeaderKey] = parentSpanId;
                }
            }
        }
コード例 #6
0
        public void AddSampled(HttpRequestMessage request, IApmContext apmContext)
        {
            object sampledProperty;
            var    sampled = string.Empty;

            if (request.Properties.TryGetValue(Constants.SampledHeaderKey, out sampledProperty))
            {
                sampled = (string)sampledProperty;
                apmContext[Constants.SampledHeaderKey] = sampled;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.SampledHeaderKey))
                {
                    sampled = (string)apmContext[Constants.SampledHeaderKey];
                    request.Properties[Constants.SampledHeaderKey] = sampled;
                }
                else
                {
                    sampled = string.Empty;
                    apmContext[Constants.SampledHeaderKey]         = sampled;
                    request.Properties[Constants.SampledHeaderKey] = sampled;
                }
            }
        }
コード例 #7
0
        public void AddFlags(HttpRequestMessage request, IApmContext apmContext)
        {
            object flagsProperty;
            var    flags = string.Empty;

            if (request.Properties.TryGetValue(Constants.FlagsHeaderKey, out flagsProperty))
            {
                flags = (string)flagsProperty;
                apmContext[Constants.FlagsHeaderKey] = flags;
            }
            else
            {
                if (apmContext.ContainsKey(Constants.FlagsHeaderKey))
                {
                    flags = (string)apmContext[Constants.FlagsHeaderKey];
                    request.Properties[Constants.FlagsHeaderKey] = flags;
                }
                else
                {
                    flags = string.Empty;
                    apmContext[Constants.FlagsHeaderKey]         = flags;
                    request.Properties[Constants.FlagsHeaderKey] = flags;
                }
            }
        }
コード例 #8
0
        public void AddApplicationName(HttpRequestMessage request, IApmContext apmContext, string applicationName)
        {
            object applicationNameProperty;

            if (request.Properties.TryGetValue(Constants.ApplicationNamePropertyKey, out applicationNameProperty))
            {
                if (!apmContext.ContainsKey(Constants.ApplicationNamePropertyKey))
                {
                    apmContext[Constants.ApplicationNamePropertyKey] = (string)applicationNameProperty;
                }
            }
            else
            {
                if (!apmContext.ContainsKey(Constants.ApplicationNamePropertyKey))
                {
                    request.Properties[Constants.ApplicationNamePropertyKey] = applicationName;
                }
                else
                {
                    request.Properties[Constants.ApplicationNamePropertyKey] = apmContext[Constants.ApplicationNamePropertyKey];
                }
            }
        }
コード例 #9
0
        public void AddMethodIdentifier(HttpRequestMessage request, IApmContext apmContext)
        {
            object methodIdentifierProperty;

            if (request.Properties.TryGetValue(Constants.MethodIdentifierPropertyKey, out methodIdentifierProperty))
            {
                if (!apmContext.ContainsKey(Constants.MethodIdentifierPropertyKey))
                {
                    apmContext[Constants.MethodIdentifierPropertyKey] = (string)methodIdentifierProperty;
                }
            }
            else
            {
                request.Properties[Constants.MethodIdentifierPropertyKey] = apmContext[Constants.MethodIdentifierPropertyKey];
            }
        }
コード例 #10
0
        public void AddEventName(HttpRequestMessage request, IApmContext apmContext)
        {
            object eventNameProperty;

            if (request.Properties.TryGetValue(Constants.EventNamePropertyKey, out eventNameProperty))
            {
                if (!apmContext.ContainsKey(Constants.EventNamePropertyKey))
                {
                    apmContext[Constants.EventNamePropertyKey] = (string)eventNameProperty;
                }
            }
            else
            {
                request.Properties[Constants.EventNamePropertyKey] = apmContext[Constants.EventNamePropertyKey];
            }
        }
コード例 #11
0
        public void AddClientName(HttpRequestMessage request, IApmContext apmContext)
        {
            object clientNameProperty;
            var    clientName = string.Empty;

            if (request.Properties.TryGetValue(Constants.ClientNamePropertyKey, out clientNameProperty))
            {
                clientName = (string)clientNameProperty;
                if (!apmContext.ContainsKey(Constants.ClientNamePropertyKey))
                {
                    apmContext[Constants.ClientNamePropertyKey] = clientName;
                }
            }
            else
            {
                clientName = (string)apmContext[Constants.ClientNamePropertyKey];
                request.Properties[Constants.ClientNamePropertyKey] = clientName;
            }
        }