Skip to content

Add schema URL support #63651

Closed
Closed

Description

@tarekgh

https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/schemas

Telemetry sources such as instrumented applications and consumers of telemetry such as observability backends sometimes make implicit assumptions about the emitted telemetry. They assume that the telemetry will contain certain attributes or otherwise have a certain shape and composition of data. Essentially there is a coupling between 3 parties: OpenTelemetry semantic conventions, telemetry sources and telemetry consumers. The coupling complicates the independent evolution of these 3 parties. The 3 parties should be able to evolve independently over time and Telemetry Schemas are central to how we make this possible.

Proposal

namespace System.Diagnostics
{
    public sealed class ActivitySource : IDisposable
    {
        public ActivitySource(string name, string? version = "") { ... }
+       public ActivitySource(string name, string? version, string? telemetrySchemaUrl) { ... }
+       public string? TelemetrySchemaUrl { get; }
    }
}

namespace System.Diagnostics.Metrics
{
    public class Meter : IDisposable
    {
        public Meter(string name) { }
        public Meter(string name, string? version)  { }
+       public Meter(string name, string? version, string? telemetrySchemaUrl)  { }
+       public string? TelemetrySchemaUrl { get; }
    }
}

Usage

    private static ActivitySource s_source = new ActivitySource("MyLibrary.MyFeature", "2.0", "https://opentelemetry.io/schemas/1.2.0");
    private static Meter s_meter = new Meter("MyLibrary.MyFeature", "2.0", "https://opentelemetry.io/schemas/1.2.0");

Activity

  1. added this to the 7.0.0 milestone on Jan 11, 2022
  2. ghost added
    untriaged
    on Jan 11, 2022
  3. removed
    untriaged
    on Jan 11, 2022
  4. added
    api-needs-work
    on Feb 4, 2022
  5. tarekgh commented on Feb 7, 2022

    @tarekgh
    MemberAuthor

    We are going to wait for finalizing the semantic convention discussion on OpenTelemetry side to know if there will be any effect on this current proposal. We expect to have the feedback by the end of March or early April.

    CC @cijothomas @reyang @denisivan0v

  6. modified the milestones: 7.0.0, Future on Apr 14, 2022
  7. CodeBlanch commented on Jul 20, 2022

    @CodeBlanch
    Contributor

    Just looking at open-telemetry/opentelemetry-dotnet#3445. There are cases where instrumentation does not own the ActivitySource being used (ex AspNetCore, HttpClient). In those cases it might be helpful to make some of this data settable?

    namespace System.Diagnostics
    {
        public sealed class ActivitySource : IDisposable
        {
            public ActivitySource(string name, string? version = "") { ... }
    +       public ActivitySource(string name, string? version, string? telemetrySchemaUrl) { ... }
            public string? Version { 
              get;
    +         set;
            }
    +       public string? TelemetrySchemaUrl { get; set; }
        }
    }

    That would allow (for example) OpenTelemetry instrumentation augmenting the sources to pass along its version + schema url for the schema being augmented.

    Breaks if users have multiple augmenting libraries/schemas, but may not be a concern?

  8. danelson commented on Sep 5, 2023

    @danelson

    @tarekgh I am curious if this was revisited at all with some of the changes made for .NET 8 (e.g. https://github.com/lmolkova/semantic-conventions/blob/dotnet8-metrics/docs/dotnet/dotnet-http-metrics.md). There was a comment that mentioned staying compatible with OTel but I am a bit concerned that this will be hard for consumers to manage if there are additional changes without the existence of schema URL. Do you have any idea when I might be able to expect this change?

    Speaking from someone whose organization sticks to mainly LTS releases, if this does not make .NET 8 then it becomes hard to manage across various language SDKs.

  9. tarekgh commented on Sep 5, 2023

    @tarekgh
    MemberAuthor

    @danelson the semantic convention discussion came very late in the 8.0 after passing the point of adding a new API. This is something we can consider for our next release.

    CC @reyang @noahfalk @CodeBlanch

  10. modified the milestones: Future, 9.0.0 on Sep 5, 2023
  11. 6 remaining items

  12. cijothomas commented on Apr 9, 2024

    @cijothomas
    Contributor

    OpenTelemetry Semantic Conventions for HTTP Spans are stable.

    But that is not relevant to this issue right?

    https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/telemetry-stability.md is still experimental, though that does not have to prevent us from adding schema_url support.

  13. lmolkova commented on May 1, 2024

    @lmolkova

    @tarekgh is it in scope for .NET 9? thanks!

  14. tarekgh commented on May 1, 2024

    @tarekgh
    MemberAuthor
  15. lmolkova commented on May 2, 2024

    @lmolkova

    So none of the .NET instrumentation can change after they are declared stable until at least .NET 10? Sounds like we're going to break this rule a lot.

  16. modified the milestones: Future, 10.0.0 on Jan 15, 2025
  17. lmolkova commented on Jan 23, 2025

    @lmolkova

    Adding some context on how SchemaURL is useful:

    SchemaURL looks like this: https://opentelemetry.io/schemas/1.29.0 and has two major parts:

    • opentelemetry.io represents the authority - who owns the schema. I can easily envision https://aka.ms/otel/azure/sdk/schemas/1.42.0 and would publish one for Azure SDK in the future.
    • 1.29.0 represents SemVer version. We should be able to evolve it and add stability suffix

    The schema URL is useful even without the content behind it - it can be treated as an opaque string, or string with specific format containing authority and version.
    The content provided under this URL is evolving, it has a huge potential, but de-facto is not used today.


    1. As a user I want to know what schema certain library/app/component emits. It maybe OTel semconv,
      custom schema created by my company, etc. It helps me with:

      • knowing the source of telemetry schema (otel, my company, someone else)
      • knowing the version when debugging telemetry-related issues.
      • knowing when things are updated and get notified (e.g. via an alert) so I can adjust my dashboards and queries
    2. As a client library or a service that emits telemetry, I need a way to tell my users which telemetry schema my component follows.
      I can document it, but auto-updates happen and it could be hard to determine what version is used in runtime.
      If I publish my own conventions, I'm making it explicit to my users.

      I can additionally communicate stability level of the conventions by including GA/preview in the SemVer version (https://opentelemetry.io/schemas/1.29.0-dev).
      I can document that users can rely on this field when writing queries/alerts if it indicates stable version and following SemVer compatibility.

    3. As a telemetry backend (processor, exporter) I may need to map otel attributes from otel schema to my own. To perform such mapping, in a general case, I need to understand if the data follows the schema I support. If it does, I can write mappings for
      specific version and/or optimize them based on it.

    4. As a future-proof and very advanced telemetry backend, I want to use the schema definition provided on this URL to upgrade/downgrade that telemetry to the version I work best with. This is still in flight.


    What happens without SchemaURL:

    • As a user, I need to look into each of my libs docs (for current version) to learn which conventions they emit.

    • If telemetry changes (e.g. new attribute pops up) it's hard for me to understand if it has changed because my app started doing something new or lib changed and now follows updated telemetry schema

    • As a backend, if I want to support multiple unstable versions, I have to support all combinations of attributes/metrics in each versions. I have no means to fail fast and drop/optimize things I don't support yet or anymore.

      Imagine you're writing a backend and receive a request. You probably can serve it, but you need to explore the body to guess which API version client was following.
      It all works reasonably well until you need to upgrade, route based on version, apply different logic, etc.

    We have a lot of breaking changes in experimental semconv - there is a big need for schema transformation that depends on schema url - people are building it.

    It's expected that we'll evolve areas of OTel Semconv like GenAI after they stabilize and have v2+ in years to come. Upgrade without versioning is hard or impossible. Versioning helps backends to handle it almost gracefully


    Schema URL is

  18. added
    api-ready-for-review
    and removed
    api-needs-work
    on Feb 24, 2025
  19. bartonjs commented on Feb 25, 2025

    @bartonjs
    Member

    Video

    • Instead of adding new parameters on ActivitySource constructors, we added an Options type to make it more like Meter, and added the ability to set the value only on the options types.
    namespace System.Diagnostics
    {
        public sealed partial class ActivitySource
        {
            public ActivitySource(ActivitySourceOptions options);
            
            public string? TelemetrySchemaUrl { get; }
        }
    
        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 string? TelemetrySchemaUrl { get; set; }
        }
    }
    
    namespace System.Diagnostics.Metrics
    {
        public partial class Meter : IDisposable
        {
            public string? TelemetrySchemaUrl { get; }
        }
    
        public partial class MeterOptions
        {
            public string? TelemetrySchemaUrl { get; set; }
        }
    }
  20. added
    api-approved
    and removed
    api-ready-for-review
    on Feb 25, 2025
  21. added
    in-pr
    on Mar 1, 2025
  22. locked and limited conversation to collaborators on Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedarea-System.Diagnostics.Activityfeature-requestin-pr

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions