Esempio n. 1
0
        public static void Main()
        {
            var resource = Resources.CreateServiceResource("my-service", "roleinstance1", "my-namespace");

            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                                       .SetResource(resource)
                                       .AddSource("Demo.DemoServer")
                                       .AddSource("Demo.DemoClient")
                                       .AddAzureMonitorTraceExporter(o => {
                o.ConnectionString = $"InstrumentationKey=Ikey;";
            })
                                       .Build();

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

                System.Console.WriteLine("Press ENTER to stop.");
                System.Console.ReadLine();
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            var resourceAttributes = new Dictionary <string, object> {
                { "service.name", "my-service" }, { "service.namespace", "my-namespace" }, { "service.instance.id", "my-instance" }
            };
            var resourceBuilder = ResourceBuilder.CreateDefault().AddAttributes(resourceAttributes);

            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                                       .SetResourceBuilder(resourceBuilder)
                                       .AddSource("Demo.DemoServer")
                                       .AddSource("Demo.DemoClient")
                                       .AddAzureMonitorTraceExporter(o => {
                o.ConnectionString = $"InstrumentationKey=Ikey;";
            })
                                       .Build();

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

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