opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

When invalid combination of clients are used return appropriate Result instead of panic

Open cijothomas opened this issue 9 months ago • 5 comments

Suggested here: https://github.com/open-telemetry/opentelemetry-rust/issues/2673#issuecomment-2672364656

It might be possible for the provider construction to check if an invalid pair of Processor+Exporter client is used and return an Error...As of now, wrong combinations are not detected until too late, where things panic.

cijothomas avatar Feb 20 '25 18:02 cijothomas

eg: provider.with_batch_exporter(exporter-with_unsupported_client_like_request) should return a Result. The Err should clearly indicate the reason for failure.

cijothomas avatar Feb 20 '25 18:02 cijothomas

I'm interested in this issue, but

provider.with_batch_exporter(exporter-with_unsupported_client_like_request) should return a Result.

Currently all with_xxx methods return Builder itself. Do you think we should change all methods (or at least with_batch_exporter's) signature to return Result?

Shunpoco avatar Mar 06 '25 20:03 Shunpoco

I was referring to the .build() method to detect invalid combination and return Result.

Related to this is https://github.com/open-telemetry/opentelemetry-rust/pull/2654 which only does Exporter specific one. This issue is about the overall provider..Some detailed analysis is to be done to find a good balance.

cijothomas avatar Mar 06 '25 20:03 cijothomas

Thanks! I will take a look at the PR and consider how to do it in providers.

Some detailed analysis is to be done to find a good balance

Do you already have any concerns to change build() to return Result?

Shunpoco avatar Mar 06 '25 21:03 Shunpoco

Do you already have any concerns to change build() to return Result?

No. I prefer build() returns Result. The part that needs design is what Error enum it would return. We probably need to create a new one, with the variants reflecting the possible ways it can fail. OR return string only as Error.

cijothomas avatar Mar 07 '25 01:03 cijothomas