dsmiley commented on code in PR #1854: URL: https://github.com/apache/solr/pull/1854#discussion_r1299299408
########## solr/modules/opentelemetry/src/test/org/apache/solr/opentelemetry/TestSimplePropagatorDistributedTracing.java: ########## @@ -0,0 +1,101 @@ +/* + * 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.opentelemetry; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.TracerProvider; +import java.io.IOException; +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.cloud.SolrCloudTestCase; +import org.apache.solr.core.SolrCore; +import org.apache.solr.logging.MDCLoggingContext; +import org.apache.solr.util.LogListener; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.MDC; + +public class TestSimplePropagatorDistributedTracing extends SolrCloudTestCase { + + private static final String COLLECTION = "collection1"; + + @BeforeClass + public static void setupCluster() throws Exception { + + // enable simple propagator + System.setProperty("solr.otel.simplePropagatorOnly", "true"); + + // force early init + CustomTestOtelTracerConfigurator.prepareForTest(); + + configureCluster(4) + .addConfig("config", TEST_PATH().resolve("collection1").resolve("conf")) + .withSolrXml(TEST_PATH().resolve("solr.xml")) + .configure(); + + // tracer should be disabled + assertEquals( + "Expecting active otel, not noop impl", + TracerProvider.noop(), + GlobalOpenTelemetry.get().getTracerProvider()); + + CollectionAdminRequest.createCollection(COLLECTION, "config", 2, 2) + .process(cluster.getSolrClient()); + cluster.waitForActiveCollection(COLLECTION, 2, 4); + } + + @AfterClass + public static void afterClass() { + CustomTestOtelTracerConfigurator.resetForTest(); + } + + @Test + public void test() throws IOException, SolrServerException { + CloudSolrClient cloudClient = cluster.getSolrClient(); + + // Indexing + cloudClient.add(COLLECTION, sdoc("id", "1")); + cloudClient.add(COLLECTION, sdoc("id", "2")); + cloudClient.commit(COLLECTION); + // TODO check tid + + try (LogListener reqLog = LogListener.info(SolrCore.class.getName() + ".Request")) { + assertNull(MDC.get(MDCLoggingContext.TRACE_ID)); Review Comment: From the context of the test, it might always be null? Maybe you intended to check this from within Solr (thus during a request). I suppose what you should be looking for is the "t" MDC value in the logs. I think I'm not understanding something. Don't we want to actually see a trace ID after all? Even for "only" propagation; nonetheless there is a trace ID and logging it is absolutely the point. -- 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]
