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

SOLR-16938 Auto configure tracer without a <tracerConfig> tag in solr… #1922

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

stillalex
Copy link
Member

….xml

https://issues.apache.org/jira/browse/SOLR-16938

Description

Enable OTEL based on presence of system property. also use config params for otel init, but not if the respective system properties are already defined.

Solution

Please provide a short description of the approach taken to implement your solution.

Tests

Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@stillalex stillalex requested a review from janhoy September 13, 2023 18:34
@stillalex
Copy link
Member Author

@janhoy if you have a few mins could you please take a look.
The proposed approach is to attempt to init otel if the OTEL_SERVICE_NAME property exists. I am open to suggestions here if there is anything better. if it will attempt and fail there is a log message that points to enabling module.

The other part of this PR is passing the init params to the OtelTracerConfigurator and using them to set some system properties if they are not already set. this should fill in the plugin config gap.

Copy link
Contributor

@janhoy janhoy left a comment

Choose a reason for hiding this comment

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

Looks like a way to go.
Will you attempt a ref-guide edit as well?

@@ -49,17 +49,17 @@ public OtelTracerConfigurator() {

@Override
public Tracer getTracer() {
// TODO remove reliance on global
return GlobalOpenTelemetry.getTracer("solr");
return TraceUtils.getGlobalTracer();
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: While this is correct, it feels backward for a plugin method to ask a core class to return its instance.

String envValue = System.getenv().get(envName);
String sysName = envName.toLowerCase(Locale.ROOT).replace("_", ".");
String sysValue = System.getProperty(sysName);
return sysValue != null ? sysValue : envValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is duplicating OtelTracerConfigurator#getEnvOrSysprop. Perhaps you can extract some functionality into a common static utility?

@stillalex stillalex merged commit 5f25f09 into apache:main Sep 14, 2023
2 checks passed
@stillalex stillalex deleted the SOLR-16938-auto-config branch September 14, 2023 23:08
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.

2 participants