Skip to content

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

Closed

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

Activity

  1. ghost added
    needs-area-label
    on Oct 20, 2023
  2. ghost added
    untriaged
    on Oct 20, 2023
  3. added
    enhancement
    and removed
    needs-area-label
    untriaged
    on Oct 23, 2023
  4. added this to the 9.0.0 milestone on Oct 23, 2023
  5. tommcdon commented on Oct 23, 2023

    @tommcdon
    Member

    Assigning to @noahfalk to help coordinate

  6. tarekgh commented on Oct 23, 2023

    @tarekgh
    Member

    This is a duplicate of #63651. @lmolkova can we close this and continue the discussion on the other one?

    CC @cijothomas @reyang

  7. removed
    enhancement
    on Oct 23, 2023
  8. 2 remaining items

  9. changed the title [-][Feature request]: Support SchemaUrl and instrumentation scope attributes for OpenTelemetry tracing and metrics[/-] [+][Feature request]: Support instrumentation scope attributes for OpenTelemetry tracing and metrics[/+] on Oct 23, 2023
  10. tarekgh commented on Oct 23, 2023

    @tarekgh
    Member

    Thanks @lmolkova for clarification. We already done #84321 in .NET 8.0. Is that what you are asking for? or you want to have the same for ActivitySource too?

  11. lmolkova commented on Oct 23, 2023

    @lmolkova
    Author

    Cool! Yes, I mean ActivitySource, great to know it's addressed on meters.

  12. changed the title [-][Feature request]: Support instrumentation scope attributes for OpenTelemetry tracing and metrics[/-] [+][Feature request]: Support instrumentation scope attributes on ActivitySource[/+] on Oct 23, 2023
  13. tarekgh commented on Oct 25, 2023

    @tarekgh
    Member
  14. added
    api-ready-for-review
    blocking
    on May 11, 2024
  15. terrajobst commented on May 21, 2024

    @terrajobst
    Contributor

    Video

    • We should make it simpler
      • Have one method with just the required parameter (name)
      • Have one method that takes all the optional parameters
      • We can't remove methods, but we can hide them and remove all optionality to avoid ambiguity
    namespace System.Diagnostics;
    
    public partial class ActivitySource
    {
        // Existing, left as-is
        // public ActivitySource(string name);
    
        // Existing, remove optionality and mark EB never
        [EditorBrowsable(EditorBrowsableState.Never)]
        public ActivitySource(string name, string? version);
    
        // New
        public ActivitySource(string name, string? version = "", IEnumerable<KeyValuePair<string, object?>>? tags = default);
    
        public IEnumerable<KeyValuePair<string, object?>>? Tags { get; }
    }
  16. added
    api-approved
    and removed
    api-ready-for-review
    on May 21, 2024
  17. added
    in-pr
    on May 24, 2024
  18. locked and limited conversation to collaborators on Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedapi-suggestionarea-System.Diagnostics.Activityblockingin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions