Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OTLP protocol configurability to autoconfigure #3522

Merged
merged 1 commit into from
Aug 23, 2021

Conversation

jack-berg
Copy link
Member

Related to this open spec issue.

A note on the implementation: I was getting annoyed with how repetitive the configuration was for OTLP exporters. The extraction of config properties for OTLP grpc traces / metrics exporters is mostly the same. Adding support for protocol configurability of protocol means more copy / pasta or adding some abstraction. Went with adding an abstraction.

I initially added a OtlpExporterBuilder interface located in :exporters:otlp:common with methods common across all the OTLP exporters, but ran into all sorts of NoClassDefFoundError errors I couldn't get past. The solution I landed is to have a method that accepts a bunch of consumers which are invoked after config properties are extracted. Its pretty clean IMO, with one downside being a method that accepts 6 arguments.

@jkwatson
Copy link
Contributor

Thanks for this @jack-berg

Can you separate this into 2 PRs: 1 for the new experimental env vars, and 1 for the refactoring?

@jack-berg
Copy link
Member Author

Can you separate this into 2 PRs: 1 for the new experimental env vars, and 1 for the refactoring?

Sure. Just to clarify, the preference is to add the new experimental env vars, with the repetitious reading of config properties in one PR. Then in a followup PR, abstract away the repetitious reading of config properties.

@jkwatson
Copy link
Contributor

Can you separate this into 2 PRs: 1 for the new experimental env vars, and 1 for the refactoring?

Sure. Just to clarify, the preference is to add the new experimental env vars, with the repetitious reading of config properties in one PR. Then in a followup PR, abstract away the repetitious reading of config properties.

Or, in the other order...whichever works best for you. :)

@jack-berg
Copy link
Member Author

I've rebased onto main which has the refactor, and added the experimental prefix!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@@ -38,7 +40,7 @@ static SpanExporter configureExporter(String name, ConfigProperties config) {

switch (name) {
case "otlp":
return configureOtlpSpans(config);
return configureOtlp(config);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

builder::addHeader,
builder::setTimeout,
builder::setTrustedCertificates);
OtlpConfigUtil.configureOtlpExporterBuilder(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OtlpConfigUtil calls here and in SpanExporterConfiguration make me wish for a Builder interface that would contain required 4 methods and allow us to remove the duplication. But this is out of scope of this change, so entirely up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually went down that road first and added the builder interface to :exporters:otlp:common. The problem was that I was stuck getting NoClassDefFoundError at runtime when the OtlpExporterBuilder interface is referenced. The pattern in the autoconfigure module of using ClasspathUtil.checkClassExists(...) seems to be deterministic at runtime in that java doesn't try to load the class until after the ClasspathUtil.checkClassExists call. But for some reason I couldn't figure out, that behavior wasn't the same with OtlpExporterBuilder.

class OtlpConfigUtilTest {

@Test
void getOtlpProtocolDefault() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants