public void ZPagesExporter_CustomActivityProcessor()
        {
            const string          ActivitySourceName    = "zpages.test";
            Guid                  requestId             = Guid.NewGuid();
            TestActivityProcessor testActivityProcessor = new TestActivityProcessor();

            bool startCalled = false;
            bool endCalled   = false;

            testActivityProcessor.StartAction =
                (a) =>
            {
                startCalled = true;
            };

            testActivityProcessor.EndAction =
                (a) =>
            {
                endCalled = true;
            };

            var openTelemetrySdk = Sdk.CreateTracerProvider(b => b
                                                            .AddActivitySource(ActivitySourceName)
                                                            .UseZPagesExporter(
                                                                processorConfigure: p => p.AddProcessor((next) => testActivityProcessor)));

            var source   = new ActivitySource(ActivitySourceName);
            var activity = source.StartActivity("Test Zipkin Activity");

            activity?.Stop();

            Assert.True(startCalled);
            Assert.True(endCalled);
        }
예제 #2
0
        public void CheckingCustomActivityProcessor()
        {
            const string          ActivitySourceName    = "zpages.test";
            Guid                  requestId             = Guid.NewGuid();
            TestActivityProcessor testActivityProcessor = new TestActivityProcessor();

            bool startCalled = false;
            bool endCalled   = false;

            testActivityProcessor.StartAction =
                (a) =>
            {
                startCalled = true;
            };

            testActivityProcessor.EndAction =
                (a) =>
            {
                endCalled = true;
            };

            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                                       .AddSource(ActivitySourceName)
                                       .AddProcessor(testActivityProcessor)
                                       .AddZPagesExporter()
                                       .Build();

            using var source   = new ActivitySource(ActivitySourceName);
            using var activity = source.StartActivity("Test Zipkin Activity");
            activity?.Stop();

            Assert.True(startCalled);
            Assert.True(endCalled);

            ZPagesActivityTracker.Reset();
        }