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

re-use sdk logic for configuring otlp exporters #10292

Merged
merged 9 commits into from
Feb 6, 2024

Conversation

zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Jan 19, 2024

@zeitlinger zeitlinger self-assigned this Jan 20, 2024
@zeitlinger zeitlinger marked this pull request as ready for review January 22, 2024 17:22
@zeitlinger zeitlinger requested a review from a team as a code owner January 22, 2024 17:22
Comment on lines 88 to 91
public Map<String, String> getMap(String name) {
// maps from config properties are not supported by Environment, so we have to fake it
Copy link
Member

Choose a reason for hiding this comment

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

can the same approach used above in getDuration be used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No - maps are not exposed via environment at all - spring recommends that you only use configuration properties for new applications.

Copy link
Member

Choose a reason for hiding this comment

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

I see, so spring boot starter wouldn't support OTEL_EXPORTER_OTLP_HEADERS env var? I think that's fine, and aligns with open-telemetry/opentelemetry-specification#3850

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

OTEL_EXPORTER_OTLP_HEADERS

Yes, this also works:

Copy link
Member Author

Choose a reason for hiding this comment

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

config file considerations

I would like to get the spring starter in a good shape for GA before we look into supporting upcoming features

@@ -20,6 +20,9 @@
* <p>Get Exporter Endpoint
*
* <p>Get max wait time for Collector to process Span Batches
*
* <p>Note that this class mostly exists to support auto-completion in IDEs. The actual properties
Copy link
Member

Choose a reason for hiding this comment

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

About the auto-completion of properties resolved from the Environment object, the Spring Boot code seems to add them to an additional-spring-configuration-metadata.json file. We could perhaps stay close to the way Spring Boot is implemented. I started an additional-spring-configuration-metadata.json file here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is recommended to be generated automatically from configuration properties files.

Copy link
Member

Choose a reason for hiding this comment

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

This file is recommended to be generated automatically from configuration properties files.

it looks like we are already doing this? (#8516)

Copy link
Member

Choose a reason for hiding this comment

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

See https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html#appendix.configuration-metadata.annotation-processor.adding-additional-metadata

When a property is retrieved from an Environment object, Spring annotation processor can't automatically generate an autocompletion file. In this case, the practice in the Spring Boot project seems to add properties in the additional-spring-configuration-metadata.json file, example with org.springframework.boot.context.logging.LoggingApplicationListener: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, then we should apply the best practice 😄

@trask trask merged commit f715a18 into open-telemetry:main Feb 6, 2024
47 checks passed
@zeitlinger zeitlinger deleted the spring-starter-otlp-exporter branch February 6, 2024 11:07
steverao pushed a commit to steverao/opentelemetry-java-instrumentation that referenced this pull request Feb 16, 2024
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
4 participants