dsmiley commented on code in PR #3413:
URL: https://github.com/apache/solr/pull/3413#discussion_r2376942420


##########
solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java:
##########
@@ -299,6 +298,7 @@ public static void setupTestCases() {
     }
 
     ExecutorUtil.resetThreadLocalProviders();
+    OpenTelemetryConfigurator.resetForTest();

Review Comment:
   did beginning vs end matter?



##########
solr/core/src/java/org/apache/solr/metrics/otel/MetricExporterFactory.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.metrics.otel;
+
+import io.opentelemetry.sdk.metrics.export.MetricExporter;
+import org.apache.solr.common.util.EnvUtils;
+
+public interface MetricExporterFactory {
+
+  public static final Boolean OTLP_EXPORTER_ENABLED =

Review Comment:
   Just an FYI -- be aware we can't test constants with different values in our 
unit tests.  If we wanted to try a different value, we'd have to add a "BATS" 
test.



##########
solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java:
##########
@@ -390,6 +394,32 @@ public void testObservableDoubleUpDownCounter() {
     assertEquals(-10.1, actual.getDataPoints().getFirst().getValue(), 1e-6);
   }
 
+  @Test
+  public void testMetricExporter() throws Exception {
+    LongCounter counter =
+        metricManager.longCounter(METER_PROVIDER_NAME, "my_counter", "desc", 
null);
+    counter.add(5);
+    counter.add(3);
+    InMemoryMetricExporter exporter = (InMemoryMetricExporter) 
metricManager.getMetricExporter();
+
+    // Wait 3 seconds for the exporter to push metrics
+    Thread.sleep(3000);

Review Comment:
   It's better to use RetryUtil or similar technique instead of sleep.  Sleep 
is tests for large codebases like Solr is rather evil.



-- 
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