-
Notifications
You must be signed in to change notification settings - Fork 775
/
Program.cs
37 lines (32 loc) · 1.1 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
namespace ExtendingTheSdk;
public class Program
{
private static readonly ActivitySource DemoSource = new("OTel.Demo");
public static void Main()
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new MySampler())
.AddSource("OTel.Demo")
.SetResourceBuilder(ResourceBuilder.CreateEmpty().AddDetector(new MyResourceDetector()))
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleActivityExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter()
.Build();
using (var foo = DemoSource.StartActivity("Foo"))
{
using (var bar = DemoSource.StartActivity("Bar"))
{
using (var baz = DemoSource.StartActivity("Baz"))
{
}
}
}
}
}