Exemplo n.º 1
0
        public void Inject(ITraceContext traceContext, C carrier)
        {
            _setter(carrier, _b3Propagation.TraceIdKey, traceContext.SerializeTraceId());
            _setter(carrier, _b3Propagation.SpanIdKey, traceContext.SerializeSpanId());
            if (traceContext.ParentSpanId != null)
            {
                // Cannot be null in theory, the root span must have been created on request receive hence further RPC calls are necessary children
                _setter(carrier, _b3Propagation.ParentSpanIdKey, traceContext.SerializeParentSpanId());
            }
            _setter(carrier, _b3Propagation.DebugKey, traceContext.SerializeDebugKey());

            // Add "Sampled" header for compatibility with Finagle
            if (traceContext.Sampled.HasValue)
            {
                _setter(carrier, _b3Propagation.SampledKey, traceContext.SerializeSampledKey());
            }
        }
Exemplo n.º 2
0
        static async Task ProduceMessage(ITraceContext traceContext, string text)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:51589")
            };

            var message = new Message
            {
                Text    = text,
                TraceId = traceContext.SerializeTraceId(),
                SpanId  = traceContext.SerializeSpanId(),
                Sampled = traceContext.SerializeSampledKey(),
                Flags   = long.Parse(traceContext.SerializeDebugKey())
            };
            var stringContent = JsonConvert.SerializeObject(message);

            await client.SendAsync(new HttpRequestMessage(HttpMethod.Post, "messages/push")
            {
                Content = new StringContent(stringContent, Encoding.UTF8, "application/json")
            });;
        }