public static TracerProvider EnableTracing(Jaeger config) { TracerProvider tracing = null; if (config.Enabled) { tracing = Sdk.CreateTracerProviderBuilder() .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("p2g")) .AddHttpClientInstrumentation(config => { config.RecordException = true; config.Enrich = (activity, name, rawEventObject) => { activity.SetTag(TagKey.App, TagValue.P2G); activity.SetTag("SpanId", activity.SpanId); activity.SetTag("TraceId", activity.TraceId); }; }) .AddSource("P2G") .AddJaegerExporter(o => { o.AgentHost = config.AgentHost; o.AgentPort = config.AgentPort.GetValueOrDefault(); }) .Build(); Log.Information("Tracing started and exporting to: http://{@Host}:{@Port}", config.AgentHost, config.AgentPort); } return(tracing); }
public Observability() { Prometheus = new Prometheus(); Jaeger = new Jaeger(); }