Beispiel #1
0
        public void WithTag_KeyIsErrorBoolValue()
        {
            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new SpanBuilderShim(tracer, "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.Error.Key, true);

            // build
            var spanShim = (SpanShim)shim.Start();

            // Span status should be set
            Assert.Equal(Status.Unknown, spanShim.Span.Activity.GetStatus());
        }
        public void WithTag_KeyIsNullStringValue()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanBuilderShim(GetDefaultTracerMock(spanMock).Object, "foo");

            shim.WithTag((string)null, "unused");

            // build
            shim.Start();

            // Null key was ignored
            Assert.Empty(spanMock.Attributes);
        }
Beispiel #3
0
        public void WithTag_KeyIsNullStringValue()
        {
            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new SpanBuilderShim(tracer, "foo");

            shim.WithTag((string)null, "unused");

            // build
            var spanShim = (SpanShim)shim.Start();

            // Null key was ignored
            Assert.Empty(spanShim.Span.Activity.Tags);
        }
        public void WithTag_ValueIsNullStringValue()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanBuilderShim(GetDefaultTracerMock(spanMock).Object, "foo");

            shim.WithTag("foo", null);

            // build
            shim.Start();

            // Null value was turned into string.empty
            Assert.Equal("foo", spanMock.Attributes.First().Key);
            Assert.Equal(string.Empty, spanMock.Attributes.First().Value);
        }
Beispiel #5
0
        public void WithTag_ValueIsNullStringValue()
        {
            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new SpanBuilderShim(tracer, "foo");

            shim.WithTag("foo", null);

            // build
            var spanShim = (SpanShim)shim.Start();

            // Null value was turned into string.empty
            Assert.Equal("foo", spanShim.Span.Activity.Tags.First().Key);
            Assert.Equal(string.Empty, spanShim.Span.Activity.Tags.First().Value);
        }
Beispiel #6
0
        public void WithTag_KeyIsSpanKindStringValue()
        {
            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new SpanBuilderShim(tracer, "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.SpanKind.Key, global::OpenTracing.Tag.Tags.SpanKindClient);

            // build
            var spanShim = (SpanShim)shim.Start();

            // Not an attribute
            Assert.Empty(spanShim.Span.Activity.Tags);
            Assert.Equal("foo", spanShim.Span.Activity.OperationName);
            Assert.Equal(ActivityKind.Client, spanShim.Span.Activity.Kind);
        }
        public void WithTag_KeyIsErrorBoolValue()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanBuilderShim(GetDefaultTracerMock(spanMock).Object, "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.Error.Key, true);

            // build
            shim.Start();

            // Not an attribute
            Assert.Empty(spanMock.Attributes);

            // Span status should be set
            Assert.Equal(Status.Unknown, spanMock.GetStatus());
        }
        public void WithTag_KeyIsSpanKindStringValue()
        {
            var spanMock   = Defaults.GetOpenTelemetrySpanMock();
            var tracerMock = GetDefaultTracerMock(spanMock);
            var shim       = new SpanBuilderShim(tracerMock.Object, "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.SpanKind.Key, global::OpenTracing.Tag.Tags.SpanKindClient);

            // build
            shim.Start();

            // Not an attribute
            Assert.Empty(spanMock.Attributes);

            tracerMock.Verify(o => o.StartSpan("foo", It.IsAny <TelemetrySpan>(), SpanKind.Client, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && !so.Links.Any())), Times.Once);
        }
Beispiel #9
0
        public void WithTag_KeyisSpanKindStringValue()
        {
            var spanMock        = Defaults.GetOpenTelemetrySpanMock();
            var spanBuilderMock = GetDefaultSpanBuilderMock(spanMock);
            var shim            = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.SpanKind.Key, global::OpenTracing.Tag.Tags.SpanKindClient);

            // build
            shim.Start();

            // Not an attribute
            Assert.Empty(spanMock.Attributes);

            spanBuilderMock.Verify(o => o.SetSpanKind(Trace.SpanKind.Client), Times.Once);
        }
Beispiel #10
0
        public void WithTag_KeyisErrorStringValue()
        {
            var spanMock        = Defaults.GetOpenTelemetrySpanMock();
            var spanBuilderMock = GetDefaultSpanBuilderMock(spanMock);
            var shim            = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo");

            shim.WithTag(global::OpenTracing.Tag.Tags.Error.Key, "true");

            // build
            shim.Start();

            // Not an attribute
            Assert.Empty(spanMock.Attributes);

            // Span status should be set
            Assert.Equal(Trace.Status.Unknown, spanMock.Status);
        }
        public void WithTag_VariousValueTypes()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanBuilderShim(GetDefaultTracerMock(spanMock).Object, "foo");

            shim.WithTag("foo", "unused");
            shim.WithTag("bar", false);
            shim.WithTag("baz", 1);
            shim.WithTag("bizzle", 1D);
            shim.WithTag(new global::OpenTracing.Tag.BooleanTag("shnizzle"), true);
            shim.WithTag(new global::OpenTracing.Tag.IntOrStringTag("febrizzle"), "unused");
            shim.WithTag(new global::OpenTracing.Tag.StringTag("mobizzle"), "unused");

            // build
            shim.Start();

            // Just verify the count
            Assert.Equal(7, spanMock.Attributes.Count);
        }
Beispiel #12
0
        public void WithTag_VariousValueTypes()
        {
            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new SpanBuilderShim(tracer, "foo");

            shim.WithTag("foo", "unused");
            shim.WithTag("bar", false);
            shim.WithTag("baz", 1);
            shim.WithTag("bizzle", 1D);
            shim.WithTag(new global::OpenTracing.Tag.BooleanTag("shnizzle"), true);
            shim.WithTag(new global::OpenTracing.Tag.IntOrStringTag("febrizzle"), "unused");
            shim.WithTag(new global::OpenTracing.Tag.StringTag("mobizzle"), "unused");

            // build
            var spanShim = (SpanShim)shim.Start();

            // Just verify the count
            Assert.Equal(7, spanShim.Span.Activity.Tags.Count());
        }