Description
When creating a tracer (ActivitySource
) users should be able to specify a set of instrumentation scope attributes - https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#get-a-tracer.
See open-telemetry/opentelemetry-dotnet#4316 for the context.
Instrumentation scope attributes can be used to reduce instrumentation overhead and reduce the over-the-wire size of attributes.
For example, Azure SDK provides Azure resource provider namespace is used by Azure Monitor (and can be used by other backends) to show icons, find corresponding resources in Azure, and allow navigating to them, etc. this value is constant for a given tracer and should be passed as an instr scope attribute rather than span attribute.
.NET does not allow to provide such attributes as of today.
proposal added by @tarekgh
Proposal
namespace System.Diagnostics;
public sealed class ActivitySource : IDisposable
{
public ActivitySource(string name, string? version = "") { ... }
+ public ActivitySource(string name, string? version, IEnumerable<KeyValuePair<string, object?>>? tags) { ... }
+ public IEnumerable<KeyValuePair<string, object?>>? Tags { get; }
}
Alternative Proposal
namespace System.Diagnostics;
public class ActivitySourceOptions
{
public ActivitySourceOptions(string name) { }
public string Name { get; set; }
public string? Version { get; set; }
public IEnumerable<KeyValuePair<string, object?>>? Tags { get; set; }
}
public sealed class ActivitySource : IDisposable
{
...
public ActivitySource(ActivitySourceOptions options) { ... }
public IEnumerable<KeyValuePair<string, object?>>? Tags { get; }
}