public void SetTagIntTagValue() { var spanMock = Defaults.GetOpenTelemetrySpanMock(); var shim = new SpanShim(spanMock); Assert.Throws <ArgumentNullException>(() => shim.SetTag((IntTag)null, 1)); shim.SetTag(new IntTag("foo"), 1); Assert.Single(spanMock.Attributes); Assert.Equal("foo", spanMock.Attributes.First().Key); Assert.Equal(1, (long)spanMock.Attributes.First().Value); }
public void SetTagIntOrStringTagValue() { var spanMock = Defaults.GetOpenTelemetrySpanMock(); var shim = new SpanShim(spanMock); Assert.Throws <ArgumentNullException>(() => shim.SetTag((IntOrStringTag)null, "foo")); shim.SetTag(new IntOrStringTag("foo"), 1); shim.SetTag(new IntOrStringTag("bar"), "baz"); Assert.Equal(2, spanMock.Attributes.Count); Assert.Equal("foo", spanMock.Attributes.First().Key); Assert.Equal(1, (long)spanMock.Attributes.First().Value); Assert.Equal("bar", spanMock.Attributes.Last().Key); Assert.Equal("baz", (string)spanMock.Attributes.Last().Value); }
public void SetTagBooleanTagValue() { var spanMock = Defaults.GetOpenTelemetrySpanMock(); var shim = new SpanShim(spanMock); Assert.Throws <ArgumentNullException>(() => shim.SetTag((BooleanTag)null, true)); shim.SetTag(new BooleanTag("foo"), true); shim.SetTag(new BooleanTag(global::OpenTracing.Tag.Tags.Error.Key), true); Assert.Single(spanMock.Attributes); Assert.Equal("foo", spanMock.Attributes.First().Key); Assert.True((bool)spanMock.Attributes.First().Value); // A boolean tag named "error" is a special case that must be checked Assert.Equal(Status.Unknown, spanMock.Status); shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false); Assert.Equal(Status.Ok, spanMock.Status); }