Skip to content

Evaluate reuse of machinery's OpenTelemetry log export to complete native OTEL support (logs, metrics, traces) #549

Description

@gbartolini

Context

Klio already exports metrics and traces via OpenTelemetry (core/internal/opentelemetry), enabled by the standard OTEL_* environment variables. Logs are the missing signal: they only go to stdout/stderr, so collecting them still requires a node-level DaemonSet or a sidecar.

CloudNativePG hit the same limitation and tracked it in cloudnative-pg/cloudnative-pg#11085 ("Support Otel Log streaming w/o daemonset"). The framework to address it landed in the shared logging library as cloudnative-pg/machinery#343 ("feat(log): export the log records via OpenTelemetry"). Klio already depends on github.com/cloudnative-pg/machinery (currently v0.6.1) for its logging, so it is a natural candidate for reuse.

Note that machinery#343 has not been merged yet, and it should not be merged until Klio confirms that the framework works for it too. Klio is therefore a gating consumer: this evaluation should run against the open PR, and any change Klio needs should be raised on the PR before it lands, not as a follow-up that would force an API change in a released machinery version.

What machinery#343 introduces

From the open PR (to be confirmed against the final code, as the API may still change):

  • An optional WithOpenTelemetry() argument to Flags.ConfigureLogging.
  • Activation via the standard OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_EXPORTER_OTLP_LOGS_ENDPOINT variables. Protocol is http/protobuf unless grpc is requested.
  • A zap core teed with the existing core, inside the duplicate-message sampler, so stdout and OTLP receive the same records at the same level. The log destination is unchanged.
  • Structured fields are exported as attributes using the same keys as the JSON output. The custom debug and trace levels map to DEBUG severity.
  • Batched background export, dropping records rather than blocking when the collector falls behind.
  • ShutdownOpenTelemetry to flush queued records before exit.
  • ForwardToOpenTelemetry, which exports JSON records written by spawned processes while preserving their original time, level and logger name.

Goal

Verify whether this framework can be reused as is by Klio, so that logs, metrics and traces are all exported natively through OTEL, with no DaemonSet or sidecar needed for any of the three signals.

Out of scope

  • Redesigning the existing metrics catalogue or tracing spans.
  • Any change to the stdout log format.

Acceptance criteria

  • A written conclusion (in this issue or a short design note) on whether machinery's framework is reusable as is, or which upstream changes are needed.
  • An explicit confirmation (or list of blocking concerns) posted on feat(log): export the log records via OpenTelemetry machinery#343 before it is merged.
  • If reusable: a follow-up PR bumping machinery to the release containing the change, enabling log export behind the existing OTEL_* configuration, with unit coverage and an e2e or manual verification against an OTel Collector.
  • Docs showing a single configuration that enables logs, metrics and traces together.

Related

Activity

  1. added this to the 0.1.0 milestone on Oct 31, 2026
  2. added
    enhancement
    on Oct 31, 2026
  3. armru commented on Nov 3, 2026

    @armru
    Member

    Machinery's framework is reusable with one additive upstream change,
    WithOpenTelemetryLoggerProvider, now in cloudnative-pg/machinery#343.
    With WithOpenTelemetry() alone the logs would leave through a provider
    of their own, without the resource Klio builds for its traces and metrics
    (OTEL_RESOURCE_DETECTORS and the k8s.* attributes from POD_NAME)
    and ignoring OTEL_LOGS_EXPORTER. With the new option Klio builds the
    log provider like the other two and passes it to machinery.

    The operator moves to the logging of machinery as well, so its standard
    output becomes JSON. The implementation is in #562.

  4. added 3 commits that reference this issue on Nov 5, 2026
    ff54901
    99fc1aa
    e1db566
  5. added 4 commits that reference this issue on Nov 24, 2026
    cd66fc3
    4b62793
    cea811a
    a17428b
  6. added a commit that references this issue on Nov 24, 2026
    fcb09d4
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

    enhancement

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions