open-telemetry / opentelemetry-configuration

JSON Schema definitions for OpenTelemetry file configuration
Apache License 2.0
41 stars 17 forks source link

Prefer arrays of name value pairs over objects #115

Closed jack-berg closed 2 months ago

jack-berg commented 2 months ago

Resolves #72.

May also resolve https://github.com/open-telemetry/opentelemetry-specification/issues/2857.

This PR migrates .resource.attributes and *.otlp.headers to be key-value pairs instead of objects, and adds a modeling rule to follow this pattern for similar situations in the future. To repeat the reasoning from the modeling rule:

When a type requires a configurable list of name-value pairs (i.e. resource attributes, HTTP headers), model using an array of objects, each with name and value properties. While an arrays of name-value objects is slightly more verbose an object where each key-value is an entry, it is preferred because:

  • Avoids user input as keys, which ensures conformity with the snake_case properties rule.
  • Allows both the names and the values to be targets for [env var substitution].

The more I think about it, the more I think this the way the way to go. Note that this is how environment variables are specified in kubernetes manifests, so it shouldn't be particularly foreign to users.

We should get this change in sooner than later to minimize the number of users we expose to churn.

jack-berg commented 2 months ago

@marcalff, @codeboten - I've resolved merge conflicts and incorporated feedback. Can you take another look? Thanks.