Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OtelCol exporters should should only initialise for the telemetry types for which they're configured #251

Closed
ptodev opened this issue Feb 7, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@ptodev
Copy link
Contributor

ptodev commented Feb 7, 2024

Request

If a River config file contains an otelcol.exporter such as otelcol.exporter.otlp, that exporter will always create the underlying Collector exporters for logs, metrics, and traces. For example, even if that exporter is only used for logs, it will still create the exporters for metrics and traces. The relevant code is in component/otelcol/exporter/exporter.go.

The code needs to be changed in such a way so that the component only starts the exporters which it is used for. For example, if only logs are forwarded to the exporter component, only the logs exporter should be created.

Maybe one way to solve this is to create lazy implementations of the interfaces of exporter.Traces, exporter.Metrics and exporter.Logs. Those lazy implementations would call functions like e.factory.CreateTracesExporter only when the Start function is called. Then have the code in component/otelcol/exporter/exporter.go use those lazy exporters instead of the result of e.factory.CreateTracesExporter directly. I'm not 100% sure whether this would work, but it's the most obvious approach that I can think of.

Use case

This change is necessary in order to support the load balancing exporter with metrics. The configuration for metrics is quite unique, and otelcol.exporter.loadbalancing can crash if it is configured to process a routing key of "trace ID" with a metrics exporter.

Related to grafana/agent#5684

@ptodev ptodev added the enhancement New feature or request label Feb 7, 2024
@rfratto
Copy link
Member

rfratto commented Feb 7, 2024

I don't understand why the current behavior is a problem; can you explain more?

Maybe one way to solve this is to create lazy implementations of the interfaces of exporter.Traces, exporter.Metrics and exporter.Logs.

One issue with this approach is that if you update your config to stop sending a particular telemetry type, the lazy implementation will still continue running, since components have no knowledge of other components wired to them.

@ptodev
Copy link
Contributor Author

ptodev commented Feb 15, 2024

I don't understand why the current behavior is a problem; can you explain more?

It is possible to configure an LB exporter with metrics-specific config. This can be done by using a rounting_key of metric. This will cause the traces and logs exporters to crash, even if the user only configured that LB exporter to accept metrics. Similarly, if rounting_key is traceID, then the metrics exporter will crash because it is not able to route according to traceID. The compatibility matrix is in the OTel LB exporter docs.

If a user wires a otelcol.exporter.loadbalancing to receive metrics but uses a rounting_key of traceID, then I think it's ok to crash the process. But it should happen immediately after startup and not after the first pieve of telemetry is received. This requirement also needs to be kept in mind in case we go with a "lazy" approach.

Copy link
Contributor

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it.
If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue.
The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity.
Thank you for your contributions!

@madaraszg-tulip
Copy link
Contributor

#2242 may fix this issue. Only exporters supported by routing_key are created, and experimental metrics support is added.

@ptodev
Copy link
Contributor Author

ptodev commented Dec 12, 2024

Closing this since we could use #2242 as a baseline for how we handle such cases in the future. Thank you, @madaraszg-tulip!

@ptodev ptodev closed this as completed Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants