internal static object Run(string accessToken)
        {
            var exporter = new LightStepTraceExporter(
                new LightStepTraceExporterOptions
            {
                AccessToken = accessToken,
                ServiceName = "lightstep-test",
            });

            // Create a tracer.
            using (var tracerFactory = TracerFactory.Create(builder => builder.AddProcessorPipeline(c => c.SetExporter(exporter))))
            {
                var tracer = tracerFactory.GetTracer("lightstep-test");
                using (tracer.WithSpan(tracer.StartSpan("Main")))
                {
                    tracer.CurrentSpan.SetAttribute("custom-attribute", 55);
                    Console.WriteLine("About to do a busy work");
                    for (int i = 0; i < 10; i++)
                    {
                        DoWork(i, tracer);
                    }
                }

                Thread.Sleep(10000);
                return(null);
            }
        }
Beispiel #2
0
        internal static object Run(string accessToken)
        {
            var exporter = new LightStepTraceExporter(
                new LightStepTraceExporterOptions
            {
                AccessToken = accessToken,
                ServiceName = "tracing-to-lightstep-service",
            });

            var tracerFactory = new TracerFactory(new BatchingSpanProcessor(exporter));
            var tracer        = tracerFactory.GetTracer(string.Empty);

            using (tracer.WithSpan(tracer.SpanBuilder("Main").StartSpan()))
            {
                tracer.CurrentSpan.SetAttribute("custom-attribute", 55);
                Console.WriteLine("About to do a busy work");
                for (int i = 0; i < 10; i++)
                {
                    DoWork(i, tracer);
                }
            }
            Thread.Sleep(10000);
            // 5. Gracefully shutdown the exporter so it'll flush queued traces to LightStep.
            exporter.ShutdownAsync(CancellationToken.None).GetAwaiter().GetResult();
            return(null);
        }
Beispiel #3
0
        internal static object Run(string accessToken)
        {
            var exporter = new LightStepTraceExporter(
                new LightStepTraceExporterOptions
            {
                AccessToken = accessToken,
                ServiceName = "tracing-to-lightstep-service",
            }, Tracing.SpanExporter);

            exporter.Start();

            var traceConfig   = Tracing.TraceConfig;
            var currentConfig = traceConfig.ActiveTraceParams;
            var newConfig     = currentConfig.ToBuilder().SetSampler(Samplers.AlwaysSample).Build();

            traceConfig.UpdateActiveTraceParams(newConfig);

            var tracer = Tracing.Tracer;

            using (tracer.WithSpan(tracer.SpanBuilder("Main").StartSpan()))
            {
                tracer.CurrentSpan.SetAttribute("custom-attribute", 55);
                Console.WriteLine("About to do a busy work");
                for (int i = 0; i < 10; i++)
                {
                    DoWork(i);
                }
            }
            Thread.Sleep(10000);
            // 5. Gracefully shutdown the exporter so it'll flush queued traces to Zipkin.
            Tracing.SpanExporter.Dispose();

            return(null);
        }