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);
        }
Exemple #2
0
        public OpenTracingTracerTests()
        {
            var writerMock    = new Mock <IAgentWriter>();
            var datadogTracer = new Tracer(writerMock.Object);

            _tracer = new OpenTracingTracer(datadogTracer);
        }
        public OpenTracingSendTracesToAgent()
        {
            var uri = new Uri("http://localhost:8126");

            _httpRecorder = new RecordHttpHandler();
            _tracer       = OpenTracingTracerFactory.CreateTracer(uri, null, _httpRecorder);
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        public OpenTracingSpanBuilderTests()
        {
            var writerMock    = new Mock <IAgentWriter>(MockBehavior.Strict);
            var datadogTracer = new Tracer(writerMock.Object, defaultServiceName: DefaultServiceName);

            _tracer = new OpenTracingTracer(datadogTracer);
        }
Exemple #7
0
        public OpenTracingScopeTests()
        {
            var settings    = new TracerSettings();
            var writerMock  = new Mock <IAgentWriter>();
            var samplerMock = new Mock <ISampler>();

            _datadogTracer = new Tracer(settings, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null);
            _tracer        = new OpenTracingTracer(_datadogTracer);
        }
Exemple #8
0
        public OpenTracingTracerTests()
        {
            var settings    = new TracerSettings();
            var writerMock  = new Mock <ITraceWriter>();
            var samplerMock = new Mock <ISampler>();

            var datadogTracer = new Tracer(settings, plugins: null, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null);

            _tracer = new OpenTracingTracer(datadogTracer);
        }
        public OpenTracingSpanTests()
        {
            var settings    = new TracerSettings();
            var writerMock  = new Mock <IAgentWriter>();
            var samplerMock = new Mock <ISampler>();

            var datadogTracer = new Tracer(settings, writerMock.Object, samplerMock.Object, null);

            _tracer = new OpenTracingTracer(datadogTracer);
        }
Exemple #10
0
        public OpenTracingSendTracesToAgent()
        {
            var settings = new TracerSettings();

            _httpRecorder = new RecordHttpHandler();
            var api         = new ZipkinApi(settings, _httpRecorder);
            var agentWriter = new AgentWriter(api, statsd: null, synchronousSend: false);

            var tracer = new Tracer(settings, agentWriter, sampler: null, scopeManager: null, statsd: null);

            _tracer = new OpenTracingTracer(tracer);
        }
        public OpenTracingSpanBuilderTests()
        {
            var settings = new TracerSettings
            {
                ServiceName = DefaultServiceName
            };

            var writerMock = new Mock<ITraceWriter>(MockBehavior.Strict);
            var samplerMock = new Mock<ISampler>();

            var datadogTracer = new Tracer(settings, plugins: null, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null);
            _tracer = new OpenTracingTracer(datadogTracer);
        }
Exemple #12
0
        public OpenTracingSendTracesToAgent()
        {
            var settings = new TracerSettings();

            var endpoint = new Uri("http://localhost:8126");

            _httpRecorder = new RecordHttpHandler();
            var api         = new Api(endpoint, _httpRecorder);
            var agentWriter = new AgentWriter(api);

            var tracer = new Tracer(settings, agentWriter, sampler: null, scopeManager: null);

            _tracer = new OpenTracingTracer(tracer);
        }
Exemple #13
0
        public OpenTracingSendTracesToAgent()
        {
            var settings = new TracerSettings();

            var endpoint = new Uri("http://localhost:8126");

            _httpRecorder = new RecordHttpHandler();
            var api         = new Api(endpoint, apiRequestFactory: null, statsd: null);
            var agentWriter = new AgentWriter(api, new NullMetrics());

            var tracer = new Tracer(settings, plugins: null, agentWriter, sampler: null, scopeManager: null, statsd: null);

            _tracer = new OpenTracingTracer(tracer);
        }