open-telemetry / opentelemetry-proto

OpenTelemetry protocol (OTLP) specification and Protobuf definitions
https://opentelemetry.io/docs/specs/otlp/
Apache License 2.0
576 stars 253 forks source link

Schema support for span with key-value attributes #482

Closed TedaLIEz closed 1 year ago

TedaLIEz commented 1 year ago

Hi OTel team,

I am currently exploring the traces API in OTel, and have found that the Span class is important in traces. However, this class is designed with a key-value based API that requires us to assign properties via key-value pairs. This approach makes it difficult for us to maintain the schema of our telemetry in our code. Previously, we were able to define events in a protocol schema file (such as Protocol Buffer) and use the generated code file throughout our codebase.

I am wondering if OTel provides a similar solution that would allow us to:

  1. Maintain our event schema with an IDL and organize them effectively.
  2. Generate code based on these IDL files and use it in our code.
  3. Build events based on 2 and convert them to Spans easily.

I would appreciate any ideas or suggestions you may have. Thank you!

tigrannajaryan commented 1 year ago

However, this class is designed with a key-value based API that requires us to assign properties via key-value pairs.

This is exactly the design of OTLP.

I am wondering if OTel provides a similar solution that would allow us to:

  1. Maintain our event schema with an IDL and organize them effectively.
  2. Generate code based on these IDL files and use it in our code.
  3. Build events based on 2 and convert them to Spans easily.

A protocol with stronger-typed attributes for spans is probably possible but that would be a different protocol, I don't think it can be supported in OTLP.

tigrannajaryan commented 1 year ago

Closing this as "won't fix" since out of scope and conflicts with the current design of OTLP.