public void SimpleActionWithParameter() => AssertWith1TransactionAnd1Span(t => { t.CaptureSpan(SpanName, SpanType, s => { s.Should().NotBeNull(); WaitHelpers.Sleep2XMinimum(); }); });
public void SimpleActionWithReturnType_OnSubSpan() => AssertWith1TransactionAnd1SpanOnSubSpan(s => { var res = s.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); return(42); }); res.Should().Be(42); });
public void SimpleActionWithReturnType() => AssertWith1TransactionAnd1Span(t => { var res = t.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); return(42); }); Assert.Equal(42, res); });
public void SimpleActionWithReturnTypeAndParameter_OnSubSpan() => AssertWith1TransactionAnd1SpanOnSubSpan(t => { var res = t.CaptureSpan(SpanName, SpanType, s => { t.Should().NotBeNull(); WaitHelpers.Sleep2XMinimum(); return(42); }); res.Should().Be(42); });
public void SimpleActionWithException() => AssertWith1TransactionAnd1SpanAnd1Error(t => { Assert.Throws <InvalidOperationException>(() => { t.CaptureSpan(SpanName, SpanType, new Action(() => { WaitHelpers.Sleep2XMinimum(); throw new InvalidOperationException(ExceptionMessage); })); }); });
public void SimpleActionWithException_OnSubSpan() => AssertWith1TransactionAnd1SpanAnd1ErrorOnSubSpan(s => { Action act = () => { s.CaptureSpan(SpanName, SpanType, new Action(() => { WaitHelpers.Sleep2XMinimum(); throw new InvalidOperationException(ExceptionMessage); })); }; act.Should().Throw <InvalidOperationException>(); });
public void SimpleActionWithExceptionAndParameter() => AssertWith1TransactionAnd1SpanAnd1Error(t => { Action act = () => { t.CaptureSpan(SpanName, SpanType, new Action <ISpan>(s => { s.Should().NotBeNull(); WaitHelpers.Sleep2XMinimum(); throw new InvalidOperationException(ExceptionMessage); })); }; act.Should().Throw <InvalidOperationException>().WithMessage(ExceptionMessage); });
public void LabelsOnSpan() { var payloadSender = AssertWith1TransactionAnd1Span( t => { t.CaptureSpan(SpanName, SpanType, span => { WaitHelpers.Sleep2XMinimum(); span.SetLabel("foo", "bar"); }); }); //According to the Intake API labels are stored on the Context (and not on Spans.Labels directly). payloadSender.SpansOnFirstTransaction[0].Context.InternalLabels.Value.InnerDictionary["foo"].Value.Should().Be("bar"); }
public void SimpleActionWithReturnTypeAndException_OnSubSpan() => AssertWith1TransactionAnd1SpanAnd1ErrorOnSubSpan(s => { var alwaysThrow = new Random().Next(1) == 0; Func <int> act = () => s.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); if (alwaysThrow) //avoid unreachable code warning. { throw new InvalidOperationException(ExceptionMessage); } return(42); }); act.Should().Throw <InvalidOperationException>().WithMessage(ExceptionMessage); });
public void TagsOnSpan() { var payloadSender = AssertWith1TransactionAnd1Span( t => { t.CaptureSpan(SpanName, SpanType, span => { WaitHelpers.Sleep2XMinimum(); span.Tags["foo"] = "bar"; }); }); //According to the Intake API tags are stored on the Context (and not on Spans.Tags directly). payloadSender.SpansOnFirstTransaction[0].Context.Tags.Should().Contain("foo", "bar"); //Also make sure the tag is visible directly on Span.Tags. payloadSender.SpansOnFirstTransaction[0].Tags.Should().Contain("foo", "bar"); }
public void SimpleActionWithReturnTypeAndExceptionAndParameter_OnSubSpan() => AssertWith1TransactionAnd1SpanAnd1ErrorOnSubSpan(s1 => { Action act = () => { s1.CaptureSpan(SpanName, SpanType, s2 => { s2.Should().NotBeNull(); WaitHelpers.Sleep2XMinimum(); if (new Random().Next(1) == 0) //avoid unreachable code warning. { throw new InvalidOperationException(ExceptionMessage); } return(42); }); throw new Exception("CaptureSpan should not eat exception and continue"); }; act.Should().Throw <InvalidOperationException>().WithMessage(ExceptionMessage); });
public void SimpleActionWithReturnTypeAndException() => AssertWith1TransactionAnd1SpanAnd1Error(t => { Assert.Throws <InvalidOperationException>(() => { var result = t.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); if (new Random().Next(1) == 0) //avoid unreachable code warning. { throw new InvalidOperationException(ExceptionMessage); } return(42); }); Assert.True(false); //Should not be executed because the agent isn't allowed to catch an exception. Assert.Equal(42, result); //But if it'd not throw it'd be 42. }); });
public void SimpleAction() => AssertWith1TransactionAnd1Span(t => { t.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); }); });