Skip to content

Consumer integration

Consumers declare telemetry>=0.1,<0.2 as a normal dependency. Local sibling development may use an editable uv source:

[project]
dependencies = ["telemetry>=0.1,<0.2"]

[project.optional-dependencies]
observability = ["telemetry[opentelemetry]>=0.1,<0.2"]

[tool.uv.sources]
telemetry = { path = "../telemetry", editable = true }

The source override is a development convenience, not published dependency metadata. CI and release qualification build a wheel from the telemetry checkout and install that wheel into the consumer environment.

Each consumer:

  1. owns a closed typed telemetry vocabulary;
  2. builds one immutable TelemetrySchema from that vocabulary;
  3. constructs one TelemetryRuntime at each process composition root;
  4. adapts domain values to platform envelopes without exposing platform or OpenTelemetry types to domain logic;
  5. calls framework/engine instrumentation only for resources it owns; and
  6. flushes and shuts down the runtime within its configured bound.

Configuration values are validated at dataclass construction, including their runtime types. Collector endpoints use http only for insecure local/test operation and https for secure operation. gRPC endpoints have no path; HTTP/protobuf endpoints may have a common base path and the runtime appends the signal path. Endpoint credentials, query strings, fragments, dot segments, per-signal paths, and invalid ports are rejected before provider construction.

Secret references use SecretSource.ENVIRONMENT with an uppercase environment-variable name or SecretSource.FILE with a bounded path. OTLP application headers are limited to authorization and x-api-key. Client-key references name a key file for both protocols: a file reference is the path, and an environment reference resolves to the path. Named logging profiles must exist; console_enabled and console_format control only the console handler owned by the runtime.

Metric identifiers and dimensions must be registered by the consumer schema. Identifiers such as request, account, catalog, product, job, or snapshot IDs belong in approved trace/log correlation, never metric dimensions.

Schema outcomes and safety compatibility

Operation outcomes and failure categories are closed schema vocabulary. Every consumer-specific outcome must appear in operation_outcomes; error_outcomes must be a subset and must include the registered failure outcome used for exceptional completion. A failure category is optional, but when present it must be registered and accompany an error outcome. success, failure, and unavailable are the default operation outcomes; consumers must explicitly add values such as accepted or rejected and register their bounded failure categories.

Attribute values are limited to strings, booleans, signed 64-bit integers, finite floats, and tuples of bounded strings. Boolean attributes remain booleans; metric observations reject booleans rather than interpreting them as the integers zero or one. Attribute input constructed from an iterable must contain unique keys. Validation errors identify the violated contract without echoing the rejected name or value.

The hardening of Consumer Integration contract 1 intentionally rejects these version-0 inputs:

  • duplicate iterable attribute keys that previously kept the last value;
  • free-form operation outcomes or failure categories;
  • mutable schema collections supplied in place of tuples and frozenset values;
  • unsafe attribute-name spellings that normalize to a platform-forbidden privacy or metric-identity family; and
  • unsupported, non-finite, oversized, or over-capacity values and schema vocabularies.

Existing safe names and bounded values retain their behavior. Consumers migrating from version-0 input behavior must register outcomes and failure categories and correct rejected inputs; they must not catch validation errors and emit the rejected values through another telemetry channel.

Commerce Recommendations is the first consumer. Its adapter and schema live in src/recommendations/observability; the reusable provider and Collector implementation live here.