open-telemetry / open-telemetry/opentelemetry-cpp
Update OtlpGrpcClientOptions to populate options for gRPC client sharing
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
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
OtlpGrpcClientOptionsin a .cc file that uses those generic helpers to populate the options -
Add 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.
| 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 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with otlp_environment.h/cc and the OtlpGrpcClientOptions and signal-specific option classes described in the issue. Trace how current exporter options read environment variables, then implement and verify the shared-client constructors and option-copying behavior against the override table, including the listed OTLP defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, grpc
- Domain
- backend-api-design, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100