Skip to content

[Feature request]: Support instrumentation scope attributes on ActivitySource #93795

Closed
@lmolkova

Description

@lmolkova

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; }
    }

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.ActivityblockingMarks issues that we want to fast track in order to unblock other important workin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions