user22290484
user22290484

Reputation: 11

no-op exporter for metrics in open telemetry collector

I have a service that generates otel data (traces and metrics). When the service is deployed to prod env, the traces and metrics are exported to DataDog. However, for local testing (specifically traces), I am running otel collector (latest image) and that is exporting the traces over to jaeger (also running locally). Both the collector and jaeger are running in docker. I do not want prometheus to export metrics because I dont need to test the metrics part. So I wanted to drop the metrics from being exported in the otel colelctor. I looked for a no-op processor or a no-op exporter but cant seem to find one. I tried completely ignoring (not defining) metrics section in the pipelines portion of the otel collector config file. After I did that, my service is throwing errors that it cant export metrics. So really the only option seems to be not sending metrics as part of telemetry data from the service itself but I dont want to change that since its the same code that goes to prod.

What are my options?

Tried the following:

Upvotes: 1

Views: 3069

Answers (2)

Jan Garaj
Jan Garaj

Reputation: 28666

I would use the debug exporter, with right config, e.g.

receivers:
  ...

processors:
  ...

exporters:
  ...
  debug/noop:
    verbosity: normal
    sampling_initial: 0
    sampling_thereafter: 0

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [debug/noop]
    traces:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [otlp]
    logs:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [otlp]

BTW: there is nop exporter, but IMHO it is used only for a testing

Upvotes: 1

Matt Hensley
Matt Hensley

Reputation: 479

There is a filter process in contrib. From the README, it can:

The filterprocessor allows dropping spans, span events, metrics, datapoints, and logs from the collector.

You could add a filter that matches all metric names, causing all metrics to be dropped before being exported:

processors:
  filter/ottl:
    error_mode: ignore
    metrics:
      metric:
          - 'IsMatch(name, "*")'

Upvotes: 1

Related Questions