Skip to content

[EXPORTER] OTLP/GRPC Exporter options for metrics/logs do not honor _METRICS_/_LOGS_ environment variables. #1845

@marcalff

Description

@marcalff
malff@localhost.localdomain:otlp> pwd
/home/malff/CODE/MARC_GITHUB/build-otelcpp-2/examples/otlp
malff@localhost.localdomain:otlp> env | grep OTLP
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=POISON
malff@localhost.localdomain:otlp> ./example_otlp_metric_grpc
[Error] File: /home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter.cc:75[OTLP METRIC GRPC Exporter] Export() failed: DNS resolution failed for POISON:80: C-ares status is not ARES_SUCCESS qtype=AAAA name=POISON is_balancer=0: Domain name not found

Here, example_otlp_metric_grpc is expected to use environment variable OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.

Instead, it uses environment variable OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, as proven with the poisoned value set.

The root cause is:

struct OtlpGrpcMetricExporterOptions : public OtlpGrpcExporterOptions

While this sounds like code reuse at first read, this inheritance is flawed:

  • OtlpGrpcExporterOptions is poorly named, it is dedicated to the trace signal
  • the constructor for OtlpGrpcMetricExporterOptions will lookup _TRACES_ environment variables, instead of _METRICS_

Logs are also affected:

OtlpGrpcLogRecordExporterFactory::Create(
      const OtlpGrpcExporterOptions &options)

The options passed should be specific to the log signal, here the trace options are used instead.

OtlpGrpcExporterOptions should really be renamed to avoid causing confusion here.

Metadata

Metadata

Assignees

Labels

area:exporter:otlpOpenTelemetry Protocol (OTLP) ExporterbugSomething isn't workingdo-not-stalespec-complianceNot compliant to OpenTelemetry specs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions