Пример #1
0
        public static void Main()
        {
            OpenTelemetry.Sdk.CreateTracerProvider(builder => builder
                                                   .AddActivitySource("Samples.SampleServer")
                                                   .AddActivitySource("Samples.SampleClient")
                                                   .UseAzureMonitorTraceExporter(o => {
                o.ConnectionString = "ConnectionString";
            }));

            using (var sample = new InstrumentationWithActivitySource())
            {
                sample.Start();

                System.Console.WriteLine("Press ENTER to stop.");
                System.Console.ReadLine();
            }
        }
Пример #2
0
        public static void Main()
        {
            var resource = OpenTelemetry.Resources.Resources.CreateServiceResource("my-service", "roleinstance1", "my-namespace");

            using var tracerProvider = OpenTelemetry.Sdk.CreateTracerProviderBuilder()
                                       .SetResource(resource)
                                       .AddSource("Samples.SampleServer")
                                       .AddSource("Samples.SampleClient")
                                       .AddAzureMonitorTraceExporter(o => {
                o.ConnectionString = $"InstrumentationKey=Ikey;";
            })
                                       .Build();

            using (var sample = new InstrumentationWithActivitySource())
            {
                sample.Start();

                System.Console.WriteLine("Press ENTER to stop.");
                System.Console.ReadLine();
            }
        }