Problem:
OtlpGrpcClientOptions has only a = default constructor and it initializes all options to null or c++ default values. The exporter specific options classes read environment variables and set the otel-spec defined defaults. This makes it challenging to construct a standalone OtlpGrpcClient with spec-compliant defaults when sharing the client among multiple exporters.
Desired use case:
Construct a gRPC client and share it with all three signal exporters.
OtlpGrpcClientOptions client_opts; // this should read env vars or set spec default values
auto shared_client = OtlpGrpcClientFactory::Create(client_opts);
// use a new constructor of signal options classes copy from the shared client options
// signal specific constructors override options that are not fixed at client creation
OtlpGrpcExporterOptions trace_opts(client_opts);
OtlpGrpcMetricExporterOptions metric_opts(client_opts);
OtlpGrpcLogRecordExporterOptions log_opts(client_opts);
auto trace_exporter = OtlpGrpcExporterFactory::Create(trace_opts, shared_client);
auto metric_exporter = OtlpGrpcMetricExporterFactory::Create(metric_opts, shared_client);
auto log_exporter = OtlpGrpcLogRecordExporterFactory::Create(log_opts, shared_client);
Proposed change:
-
Add helpers in otlp_environment.h/cc, that read the OTLP signal independent environment variables (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TIMEOUT, ...) and fall back to spec defaults (endpoint=http://localhost:4317, ...) for all options needed by the grpc client.
-
Add a default constructor to OtlpGrpcClientOptions in a .cc file that uses those generic helpers to populate the options
-
Add a void* constructor to OtlpGrpcClientOptions that skips populating the options for use with the void* constructors of signal specific options classes.
-
Add constructors for each OtlpGrpcClientOptions derived class that takes a OtlpGrpcClientOptions instance and copies options fixed on client creation then overrides signal-specific options as required. See the table below for which options may be overridden when a shared client is used.
| gRPC Client Option |
Exporter Options can override with shared gRPC client? |
endpoint |
No |
| SSL fields (7) |
No |
credentials |
No |
user_agent |
No |
channel_arguments |
No |
max_threads |
No |
compression |
No |
| Retry policy fields (4) |
No |
timeout |
Yes |
metadata |
Yes |
max_concurrent_requests |
Yes |
Problem:
OtlpGrpcClientOptionshas only a= defaultconstructor and it initializes all options to null or c++ default values. The exporter specific options classes read environment variables and set the otel-spec defined defaults. This makes it challenging to construct a standaloneOtlpGrpcClientwith spec-compliant defaults when sharing the client among multiple exporters.Desired use case:
Construct a gRPC client and share it with all three signal exporters.
Proposed change:
Add helpers in
otlp_environment.h/cc, that read the OTLP signal independent environment variables (OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TIMEOUT, ...) and fall back to spec defaults (endpoint=http://localhost:4317, ...) for all options needed by the grpc client.Add a default constructor to
OtlpGrpcClientOptionsin a .cc file that uses those generic helpers to populate the optionsAdd a void* constructor to
OtlpGrpcClientOptionsthat skips populating the options for use with the void* constructors of signal specific options classes.Add constructors for each OtlpGrpcClientOptions derived class that takes a OtlpGrpcClientOptions instance and copies options fixed on client creation then overrides signal-specific options as required. See the table below for which options may be overridden when a shared client is used.
endpointcredentialsuser_agentchannel_argumentsmax_threadscompressiontimeoutmetadatamax_concurrent_requests