Otel.Configuration.Schema (otel v0.2.0)

Copy Markdown View Source

JSON Schema validation of post-substitution declarative configuration models against the opentelemetry-configuration v1.0.0 schema.

Implements the schema-validation half of spec configuration/sdk.md §Parse: "Parse SHOULD return an error if [...] the parsed file content does not conform to the configuration model schema."

Pipeline used by Otel.Configuration:

File.read!(path)
|> Otel.Configuration.Substitution.substitute!()
|> Otel.Configuration.Parser.parse_string!()
|> Otel.Configuration.Schema.validate!()

Substitution MUST run first — the schema expects native types (boolean, integer, etc.) that only become available after ${VAR:-default} is resolved and the YAML parser re-interprets the substituted text.

Schema source

The schema is bundled at priv/schemas/v1.0.0/opentelemetry_configuration.json and read + decoded + JSONSchex-compiled on every validate!/1 call. Vendored to keep validation working without CI / production submodule fetches; sync process documented alongside the file.

No caching by design. Otel.Configuration.load!/0 is called once per VM at SDK boot, so the per-call cost (~8ms file read + JSON.decode + JSONSchex.compile) is paid exactly once and never matters. Avoiding caches keeps the function pure (deterministic, no shared state, no test-ordering fragility, no permanent BEAM bloat from a giant embedded binary literal).

v1.0.0 is the first stable schema release per its versioning policy; minor versions add only backwards-compatible properties.

Library

Uses jsonschex — the only Elixir JSON Schema validator that supports Draft 2020-12 (the draft the OTel schema declares via its $schema field). Other Elixir validators are pinned to Draft 4/6/7 and would need a schema rewrite to work.

*/development properties

The schema accepts */development-suffixed properties as valid per the opentelemetry-configuration versioning policy — they are explicitly outside the stability guarantees but still part of the schema. This module does not warn about them; the Stable-only filtering policy is the Otel.Configuration.Composer's responsibility (separate PR), since composition is where mapping to SDK components happens and development-only types either resolve to a built-in or are rejected at that layer.

Public API

FunctionRole
validate!/1SDK (Parse helper) — validate parsed model, raise on schema error

References

  • Schema: apps/otel_config/priv/schemas/v1.0.0/opentelemetry_configuration.json
  • Spec Parse: opentelemetry-specification/specification/configuration/sdk.md §Parse

Summary

Functions

Validates model against the bundled v1.0.0 schema.

Functions

validate!(model)

@spec validate!(model :: map()) :: :ok

Validates model against the bundled v1.0.0 schema.

Returns :ok on success. Raises ArgumentError with a formatted list of validation errors (path + rule) on failure.