private DistributedTraceInformation CorrelateFromMessage <T>(GrainMessage <T> message)
        {
            var dti = new DistributedTraceInformation();

            dti.ParentSpanId = long.Parse(message.Headers[TracingConstants.ExternalParentSpanIdHeader]);
            dti.TraceId      = long.Parse(message.Headers[TracingConstants.ExternalTraceIdHeader]);
            return(dti);
        }
Exemple #2
0
        private static DistributedTraceInformation ExtractCorrelation(Message msg)
        {
            if (!msg.Headers.ContainsKey(TracingConstants.ExternalTraceIdHeader) ||
                !msg.Headers.ContainsKey(TracingConstants.ExternalParentSpanIdHeader))
            {
                return(null);
            }

            DistributedTraceInformation info = new DistributedTraceInformation();

            info.ParentSpanId = SpanIdUtil.FromExternalSpanId(msg.Headers[TracingConstants.ExternalParentSpanIdHeader]);
            info.TraceId      = SpanIdUtil.FromExternalSpanId(msg.Headers[TracingConstants.ExternalTraceIdHeader]);
            return(info);
        }
Exemple #3
0
        public static DistributedTraceInformation GetCorrelationFromCurrentContext()
        {
            // in our example we never leave the scope of our test-application, so the distribution
            // shown here is artificial. In real-world scenarios, you would put the
            var context = CustomSpan.GetCurrentContext();

            if (context != null)
            {
                var dti = new DistributedTraceInformation();
                dti.ParentSpanId = context.GetSpanId();
                dti.TraceId      = context.GetTraceId();
                return(dti);
            }

            return(null);
        }
Exemple #4
0
        public static DistributedTraceInformation GetDisInfo(PubsubMessage msg)
        {
            DistributedTraceInformation disInfo = new DistributedTraceInformation();

            string traceId  = string.Empty;
            string parentId = string.Empty;

            if (msg.Attributes.TryGetValue(TracingConstants.ExternalTraceIdHeader, out traceId))
            {
                disInfo.TraceId = TraceIdUtil.GetLongFromHex(traceId);
            }

            if (msg.Attributes.TryGetValue(TracingConstants.ExternalParentSpanIdHeader, out parentId))
            {
                disInfo.ParentSpanId = TraceIdUtil.GetLongFromHex(parentId);
            }

            return(disInfo);
        }
        public static DistributedTraceInformation GetDisInfo(Message msg)
        {
            DistributedTraceInformation disInfo = new DistributedTraceInformation();

            if (msg == null)
            {
                return(disInfo);
            }

            if (msg.MessageAttributes.TryGetValue(TracingConstants.ExternalTraceIdHeader, out MessageAttributeValue traceIdAttributeValue))
            {
                disInfo.TraceId = TraceIdUtil.GetLongFromHex(traceIdAttributeValue.StringValue);
            }

            if (msg.MessageAttributes.TryGetValue(TracingConstants.ExternalParentSpanIdHeader, out MessageAttributeValue parentIdAttributeValue))
            {
                disInfo.ParentSpanId = TraceIdUtil.GetLongFromHex(parentIdAttributeValue.StringValue);
            }

            return(disInfo);
        }