[email protected]:otlp> pwd
/home/malff/CODE/MARC_GITHUB/build-otelcpp-2/examples/otlp
[email protected]:otlp> env | grep OTLP
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=POISON
[email protected]: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.
Here,
example_otlp_metric_grpcis expected to use environment variableOTEL_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:
While this sounds like code reuse at first read, this inheritance is flawed:
_TRACES_environment variables, instead of_METRICS_Logs are also affected:
The options passed should be specific to the log signal, here the trace options are used instead.
OtlpGrpcExporterOptionsshould really be renamed to avoid causing confusion here.