mlbiscoc commented on code in PR #3379:
URL: https://github.com/apache/solr/pull/3379#discussion_r2116805755


##########
solr/core/src/java/org/apache/solr/core/CoreContainer.java:
##########
@@ -465,6 +480,39 @@ public CoreContainer(NodeConfig config, CoresLocator 
locator, boolean asyncSolrC
             new SolrNamedThreadFactory("IndexFingerprintPool"));
   }
 
+  /**
+   * Initializes the {@link io.opentelemetry.api.GlobalOpenTelemetry} instance 
by configuring the
+   * {@link io.opentelemetry.sdk.OpenTelemetrySdk}. The initialization process 
prioritizes in the
+   * following order:
+   *
+   * <p>{@link PluginInfo} for an OpenTelemetry configurator is provided and 
enabled, it will be
+   * used to load and initialize a custom OpenTelemetry SDK.
+   *
+   * <p>If auto-configuration is enabled, the SDK will be auto-configured 
using default behavior of
+   * AutoConfiguredOpenTelemetrySdk
+   *
+   * <p>If neither is enabled, the default creates a basic SDK is configured 
with a {@link
+   * SdkMeterProvider} and {@link 
org.apache.solr.util.tracing.SimplePropagator} for context
+   * propagation
+   *
+   * @see OpenTelemetryConfigurator
+   */
+  private void initializeOpenTelemetrySdk() {
+    PluginInfo info = cfg.getTracerConfiguratorPluginInfo();
+
+    if (info != null && info.isEnabled()) {
+      OpenTelemetryConfigurator.configureCustomOpenTelemetrySdk(
+          loader, cfg.getTracerConfiguratorPluginInfo());
+    } else if (OpenTelemetryConfigurator.shouldAutoConfigOTEL()) {
+      OpenTelemetryConfigurator.autoConfigureOpenTelemetrySdk(loader);
+    } else {
+      // Initializing sampler as always off to replicate no-op Tracer provider
+      OpenTelemetryConfigurator.configureOpenTelemetrySdk(
+          
SdkMeterProvider.builder().registerMetricReader(prometheusMetricReader).build(),
+          SdkTracerProvider.builder().setSampler(Sampler.alwaysOff()).build());

Review Comment:
   @stillalex going to CC you since I saw you were the last author of the 
`SimplePropagator`. When initializing the SDK, there is no `NOOP` Tracer 
provider that I can set, and so the best I was able to do is just set it to 
always off and I changed a few places around that were checking for `NOOP`.
   
   You can see it in this [commit 
here](https://github.com/apache/solr/pull/3379/commits/f34e9577733d22e636dc329233a0c29b11e6495e)
 . This seems to be somewhat equivalent but let me know if you disagree.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to