public void StartWithExplicitTimestamp() { var spanBuilderMock = GetDefaultSpanBuilderMock(); var shim = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo"); var startTimestamp = DateTimeOffset.UtcNow; shim.WithStartTimestamp(startTimestamp); shim.Start(); spanBuilderMock.Verify(x => x.SetStartTimestamp(startTimestamp), Times.Once); spanBuilderMock.Verify(x => x.StartSpan(), Times.Once); }
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); }
public void StartWithExplicitTimestamp() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); var startTimestamp = DateTimeOffset.UtcNow; shim.WithStartTimestamp(startTimestamp); shim.Start(); tracerMock.Verify(o => o.StartSpan("foo", 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == startTimestamp && !so.Links.Any())), Times.Once); }
public void Start() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // build var span = shim.Start() as SpanShim; // Just check the return value is a SpanShim and that the underlying OpenTelemetry Span. // There is nothing left to verify because the rest of the tests were already calling .Start() prior to verification. Assert.NotNull(span); Assert.Equal("foo", span.Span.Activity.OperationName); }
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_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 AsChildOf_WithNullSpan() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // Add a null parent shim.AsChildOf((global::OpenTracing.ISpan)null); // build var spanShim = (SpanShim)shim.Start(); Assert.Equal("foo", spanShim.Span.Activity.OperationName); Assert.Null(spanShim.Span.Activity.Parent); }
public void StartWithExplicitTimestamp() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); var startTimestamp = DateTimeOffset.Now; shim.WithStartTimestamp(startTimestamp); // build var spanShim = (SpanShim)shim.Start(); Assert.Equal(startTimestamp, spanShim.Span.Activity.StartTimeUtc); }
public void AsChildOf_WithNullSpan() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Add a null parent shim.AsChildOf((global::OpenTracing.ISpan)null); // build shim.Start(); tracerMock.Verify(o => o.StartSpan("foo", It.IsAny <ISpan>(), 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && !so.Links.Any())), Times.Once); }
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); }
public void AsChildOfWithSpanContext() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // Add a parent var spanContext = SpanContextShimTests.GetSpanContextShim(); var test = shim.AsChildOf(spanContext); // build var spanShim = (SpanShim)shim.Start(); Assert.NotNull(spanShim.Span.Activity.ParentId); }
public void AsChildOf_WithNullSpanContext() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // Add a null parent shim.AsChildOf((global::OpenTracing.ISpanContext)null); // build var spanShim = (SpanShim)shim.Start(); // should be no parent. Assert.Null(spanShim.Span.Activity.Parent); }
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); }
public void AsChildOf_WithNullSpan() { var spanBuilderMock = GetDefaultSpanBuilderMock(); var shim = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo"); // Add a null parent shim.AsChildOf((global::OpenTracing.ISpan)null); // build shim.Start(); spanBuilderMock.Verify(o => o.SetParent(It.IsAny <Trace.ISpan>()), Times.Never); spanBuilderMock.Verify(o => o.SetParent(It.IsAny <Trace.SpanContext>()), Times.Never); }
public void Start() { var spanMock = Defaults.GetOpenTelemetrySpanMock(); var tracerMock = GetDefaultTracerMock(spanMock); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // build var span = shim.Start() as SpanShim; // Just check the return value is a SpanShim and that the underlying OpenTelemetry Span. // There is nothing left to verify because the rest of the tests were already calling .Start() prior to verification. Assert.NotNull(span); Assert.Equal(spanMock, span.Span); }
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 IgnoreActiveSpan() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Add a parent. The shim requires that the ISpan implementation be a SpanShim shim.AsChildOf(new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object)); // Set to Ignore shim.IgnoreActiveSpan(); // build shim.Start(); tracerMock.Verify(o => o.StartRootSpan("foo", 0,
public void AsChildOf_WithSpan() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // Add a parent. var span = new SpanShim(tracer.StartSpan(SpanName1)); shim.AsChildOf(span); // build var spanShim = (SpanShim)shim.Start(); Assert.Equal("foo", spanShim.Span.Activity.OperationName); Assert.NotNull(spanShim.Span.Activity.ParentId); }
public void AsChildOfWithSpanContext() { var spanBuilderMock = GetDefaultSpanBuilderMock(); var shim = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo"); // Add a parent var spanContext = SpanContextShimTests.GetSpanContextShim(); shim.AsChildOf(spanContext); // build shim.Start(); spanBuilderMock.Verify(o => o.SetParent(spanContext.SpanContext), Times.Once); spanBuilderMock.Verify(o => o.SetParent(It.IsAny <Trace.ISpan>()), Times.Never); }
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 AsChildOf_WithSpan() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Add a parent. var span = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object); shim.AsChildOf(span); // build shim.Start(); tracerMock.Verify(o => o.StartSpan("foo", span.Span, 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && !so.Links.Any())), Times.Once); }
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); }
public void AsChildOfWithSpanContext() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Add a parent var spanContext = SpanContextShimTests.GetSpanContextShim(); shim.AsChildOf(spanContext); // build shim.Start(); tracerMock.Verify(o => o.StartSpan("foo", spanContext.SpanContext, 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && !so.Links.Any())), Times.Once); }
public void IgnoreActiveSpan() { var tracer = TracerProvider.Default.GetTracer(TracerName); var shim = new SpanBuilderShim(tracer, "foo"); // Add a parent. The shim requires that the ISpan implementation be a SpanShim shim.AsChildOf(new SpanShim(tracer.StartSpan(SpanName1))); // Set to Ignore shim.IgnoreActiveSpan(); // build var spanShim = (SpanShim)shim.Start(); Assert.Equal("foo", spanShim.Span.Activity.OperationName); }
public void AsChildOf_WithSpan() { var spanBuilderMock = GetDefaultSpanBuilderMock(); var shim = new SpanBuilderShim(GetDefaultTracer(spanBuilderMock), "foo"); // Add a parent. var span = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object); shim.AsChildOf(span); // build shim.Start(); spanBuilderMock.Verify(o => o.SetParent(span.Span), Times.Once); spanBuilderMock.Verify(o => o.SetParent(It.IsAny <Trace.SpanContext>()), Times.Never); }
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); }
public void IgnoreActiveSpan() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Add a parent. The shim requires that the ISpan implementation be a SpanShim shim.AsChildOf(new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object)); // Set to Ignore shim.IgnoreActiveSpan(); // build shim.Start(); tracerMock.Verify(o => o.StartRootSpan("foo", 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && !so.Links.Any())), Times.Once); }
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 AsChildOf_MultipleCallsWithSpanContext() { var tracerMock = GetDefaultTracerMock(); var shim = new SpanBuilderShim(tracerMock.Object, "foo"); // Multiple calls var spanContext1 = SpanContextShimTests.GetSpanContextShim(); var spanContext2 = SpanContextShimTests.GetSpanContextShim(); shim.AsChildOf(spanContext1); shim.AsChildOf(spanContext2); // build shim.Start(); tracerMock.Verify(o => o.StartSpan("foo", spanContext1.SpanContext, 0, It.Is <SpanCreationOptions>(so => so.StartTimestamp == default && so.Links.Single().Context.Equals(spanContext2.SpanContext))), Times.Once); }
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); }