Esempio n. 1
0
        public void Export_Span_Format()
        {
            var span = new SpanBuilder("test-span", new SimpleSpanProcessor(new NoopSpanExporter()),
                                       TraceConfig.Default).StartSpan();

            span.PutHttpHostAttribute("http://example.com", 80);
            span.PutHttpMethodAttribute("POST");
            span.PutHttpPathAttribute("path");
            span.PutHttpRawUrlAttribute("https://example.com?q=*");
            span.PutHttpRequestSizeAttribute(long.MinValue);
            span.PutHttpResponseSizeAttribute(long.MaxValue);
            span.PutHttpRouteAttribute("route");
            span.PutHttpStatusCode((int)HttpStatusCode.Accepted, "Accepted");
            span.PutHttpUserAgentAttribute("google");

            var convertedSpan = SpanExtensions.ToSpan(span as Span, "test-project");

            Assert.NotNull(convertedSpan);
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/host"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/method"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/status_code"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/route"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/user_agent"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/request_size"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/response_size"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/url"));
            Assert.True(convertedSpan.Attributes.AttributeMap.ContainsKey("/http/path"));
        }