Skip to content

Allow overriding telemetry providers #4970

Open
@mx-psi

Description

@mx-psi

Is your feature request related to a problem? Please describe.

When embedding the OpenTelemetry Collector on an existing application, said application may have an existing telemetry system for logging, metrics and/or tracing. With the current API, while some features of the telemetry may be configurable through the configuration provider (e.g. one can enable/disable the metrics telemetry), the telemetry can't be easily integrated into existing systems.

Currently, the logging features can be overriden since one can pass LoggingOptions,

// LoggingOptions provides a way to change behavior of zap logging.
LoggingOptions []zap.Option
which effectively allows one to change the zap.Core and have arbitrary logging, but the metrics and traces providers cannot be modified apart from the config exposed in the YAML.

Describe the solution you'd like

A new TelemetryFactory can be passed to CollectorSettings. This provider would have a type similar to:

type TelemetryFactory func(*config.ServiceTelemetry) telemetry.TelemetrySettings

A default TelemetryFactory is provided for distributions that want to keep the current behavior or build upon the current behavior. This factory can take options such as zap.Logger options.

The LoggingOptions field is eventually removed, since it's superseded by the default factory.

Describe alternatives you've considered

CollectorSettings could instead have new MetricsOptions and TracingOptions of some kind, although this seems more restrictive.

Additional context

I think this will allow creating the telemetry providers at the same point in the initialization as today, but care should be taken to ensure that this can be done as soon as possible.

The factory for telemetry settings should be extendable in the future for new types of telemetry that OpenTelemetry may add. This is effectively the same problem as the one we have with component factories, and we can apply the same solution here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions