public void ScopeManager_ActivatesWithFinishOnDispose() { var ddScopeManager = ((IDatadogTracer)_datadogTracer).ScopeManager; OpenTracingScopeManager otScopeManager = new OpenTracingScopeManager(ddScopeManager); var tracer = new OpenTracingTracer(_datadogTracer, otScopeManager); Span parentSpan = null; Span childSpan = null; using (IScope parentScope = tracer.BuildSpan("parent").StartActive(finishSpanOnDispose: true)) { parentSpan = ((OpenTracingSpan)parentScope.Span).Span; using (IScope childScope = tracer.BuildSpan("child").StartActive(finishSpanOnDispose: true)) { childSpan = ((OpenTracingSpan)childScope.Span).Span; Assert.True(childSpan.Context.ParentId == parentSpan.SpanId); Assert.False(childSpan.IsFinished); } Assert.True(childSpan.IsFinished); Assert.False(parentSpan.IsFinished); } Assert.True(parentSpan.IsFinished); }
public void Utf8Everywhere() { int agentPort = TcpPortProvider.GetOpenPort(); using (var agent = new MockTracerAgent(agentPort)) { var settings = new TracerSettings { Exporter = new ExporterSettings() { AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), }, TracerMetricsEnabled = false, }; var innerTracer = new Tracer(settings, agentWriter: null, sampler: null, scopeManager: null, statsd: null); var tracer = new OpenTracingTracer(innerTracer); var span = (OpenTracingSpan)tracer.BuildSpan("Aᛗᚪᚾᚾᚪ") .WithTag(DatadogTags.ResourceName, "η γλώσσα μου έδωσαν ελληνική") .WithTag(DatadogTags.ServiceName, "На берегу пустынных волн") .WithTag("யாமறிந்த", "ნუთუ კვლა") .Start(); span.Finish(); var spans = agent.WaitForSpans(1); var receivedSpan = spans.Should().ContainSingle().Subject; CompareSpans(receivedSpan, span); } }
public void CustomServiceName() { int agentPort = TcpPortProvider.GetOpenPort(); using (var agent = new MockTracerAgent(agentPort)) { var settings = new TracerSettings { Exporter = new ExporterSettings() { AgentUri = new Uri($"http://127.0.0.1:{agent.Port}"), }, TracerMetricsEnabled = false, }; var innerTracer = new Tracer(settings, agentWriter: null, sampler: null, scopeManager: null, statsd: null); var tracer = new OpenTracingTracer(innerTracer); var span = (OpenTracingSpan)tracer.BuildSpan("Operation") .WithTag(DatadogTags.ResourceName, "This is a resource") .WithTag(DatadogTags.ServiceName, "MyService") .Start(); span.Finish(); var spans = agent.WaitForSpans(1); var receivedSpan = spans.Should().ContainSingle().Subject; CompareSpans(receivedSpan, span); } }
public async void MinimalSpan() { var span = (OpenTracingSpan)_tracer.BuildSpan("Operation") .Start(); span.Finish(); // Check that the HTTP calls went as expected await _httpRecorder.WaitForCompletion(1); Assert.Single(_httpRecorder.Requests); Assert.Single(_httpRecorder.Responses); Assert.All(_httpRecorder.Responses, (x) => Assert.Equal(HttpStatusCode.OK, x.StatusCode)); var trace = _httpRecorder.Traces.Single(); MsgPackHelpers.AssertSpanEqual(span.DDSpan, trace.Single()); }
public void BuildSpan_NoParameter_DefaultParameters() { var builder = _tracer.BuildSpan("Op1"); var span = (OpenTracingSpan)builder.Start(); Assert.Contains(span.DDSpan.ServiceName, TestRunners.ValidNames); Assert.Equal("Op1", span.DDSpan.OperationName); }
public void Start_NoServiceName_DefaultServiceNameIsSet() { var span = (OpenTracingSpan)_tracer.BuildSpan(null).Start(); Assert.Equal(DefaultServiceName, span.DDSpan.ServiceName); }