How to correctly instrument library distributed as NuGet package? #3919
-
If var serviceName = "App";
var serviceVersion = "0.0.1";
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(serviceName)
.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService(serviceName: serviceName, serviceVersion: serviceVersion))
.AddConsoleExporter()
.Build();
using var appSource = new ActivitySource(serviceName, serviceVersion);
using var appActivity = appSource.StartActivity("App activity", ActivityKind.Producer);
if (appActivity?.IsAllDataRequested == true)
{
using var librarySource = new ActivitySource("Some Library name", serviceVersion);
using var childActivity = librarySource.StartActivity("Library activity", ActivityKind.Consumer, appActivity.Context);
childActivity?.AddEvent(new ActivityEvent("Test event"));
} The Should I somehow pass to the library the calling application |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The app owner has to do AddSource("Some Library name"). |
Beta Was this translation helpful? Give feedback.
The app owner has to do AddSource("Some Library name").
AddSource() supports wild card, so a "*" will listen to all sources in the process.