Skip to content

Commit af3d85f

Browse files
committed
wip: removed the unwanted dependencies and assertions from tests.
1 parent 5175997 commit af3d85f

File tree

3 files changed

+1
-147
lines changed

3 files changed

+1
-147
lines changed

instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/MongoKafkaConnectSinkTaskTest.java

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -421,113 +421,6 @@ public void testKafkaConnectMongoSinkTaskInstrumentation()
421421

422422
assertThat(foundKafkaConnectSpan).as("Should find Kafka Connect span").isTrue();
423423

424-
// Note: MongoDB spans are NOT expected from the Kafka Connect integration because
425-
// the MongoDB Kafka Connector creates its own MongoDB client without TracingCommandListener
426-
// See:
427-
// https://github.com/mongodb/mongo-kafka/blob/master/src/main/java/com/mongodb/kafka/connect/sink/StartedMongoSinkTask.java
428-
// This demonstrates that trace propagation depends on how connectors integrate with
429-
// instrumented libraries.
430-
//
431-
// Unlike JDBC Kafka Connector (which uses instrumented PreparedStatement operations),
432-
// MongoDB Kafka Connector bypasses OpenTelemetry instrumentation, so we only get
433-
// the Kafka Connect span with span links to producers.
434-
logger.info(
435-
"MongoDB span found: {} (expected: false for Kafka Connect integration)", foundMongoSpan);
436-
logger.info(
437-
"Parent-child relationship found: {} (expected: false for Kafka Connect integration)",
438-
foundParentChildRelationship);
439-
440-
// The separate testTracePropagationWithInstrumentedMongoDB() demonstrates that
441-
// MongoDB instrumentation works perfectly when properly configured
442-
443-
}
444-
445-
@Test
446-
public void testTracePropagationWithInstrumentedMongoDB() throws Exception {
447-
logger.info("=== Testing Trace Propagation with Properly Instrumented MongoDB ===");
448-
449-
// Create a properly instrumented MongoDB client (this will have TracingCommandListener)
450-
String mongoConnectionString =
451-
String.format(
452-
Locale.ROOT, "mongodb://%s:%d", mongoDB.getHost(), mongoDB.getMappedPort(27017));
453-
454-
try (com.mongodb.client.MongoClient instrumentedClient =
455-
com.mongodb.client.MongoClients.create(mongoConnectionString)) {
456-
457-
// Get the collection
458-
com.mongodb.client.MongoCollection<org.bson.Document> collection =
459-
instrumentedClient.getDatabase("test").getCollection("demo");
460-
461-
// Clear spans from backend to isolate our test
462-
clearBackendTraces();
463-
464-
// Perform a MongoDB operation - this should create a span with proper instrumentation
465-
org.bson.Document doc =
466-
new org.bson.Document("demo", "trace-propagation-test")
467-
.append("timestamp", System.currentTimeMillis());
468-
collection.insertOne(doc);
469-
470-
// Wait for spans to arrive
471-
Thread.sleep(1000);
472-
473-
// Check if MongoDB span was created
474-
String backendUrl = getBackendUrl();
475-
String tracesJson =
476-
given()
477-
.when()
478-
.get(backendUrl + "/get-traces")
479-
.then()
480-
.statusCode(200)
481-
.extract()
482-
.asString();
483-
484-
if (!tracesJson.equals("[]")) {
485-
logger.info("✅ SUCCESS: MongoDB operation created spans with proper instrumentation!");
486-
logger.info(
487-
"This proves that trace propagation works when downstream systems are properly instrumented.");
488-
489-
// Parse and verify MongoDB spans
490-
ObjectMapper objectMapper = new ObjectMapper();
491-
JsonNode tracesNode = objectMapper.readTree(tracesJson);
492-
493-
boolean foundMongoSpan = false;
494-
for (JsonNode trace : tracesNode) {
495-
JsonNode resourceSpans = trace.get("resourceSpans");
496-
if (resourceSpans != null && resourceSpans.isArray()) {
497-
for (JsonNode resourceSpan : resourceSpans) {
498-
JsonNode scopeSpans = resourceSpan.get("scopeSpans");
499-
if (scopeSpans != null && scopeSpans.isArray()) {
500-
for (JsonNode scopeSpan : scopeSpans) {
501-
JsonNode spans = scopeSpan.get("spans");
502-
if (spans != null && spans.isArray()) {
503-
for (JsonNode span : spans) {
504-
JsonNode nameNode = span.get("name");
505-
if (nameNode != null) {
506-
String spanName = nameNode.asText();
507-
if (spanName.contains("insert")) {
508-
foundMongoSpan = true;
509-
logger.info("Found MongoDB span: {}", spanName);
510-
}
511-
}
512-
}
513-
}
514-
}
515-
}
516-
}
517-
}
518-
}
519-
520-
assertThat(foundMongoSpan)
521-
.as("Should find MongoDB span when using properly instrumented client")
522-
.isTrue();
523-
524-
} else {
525-
logger.info(
526-
"ℹ️ No spans captured - this may indicate MongoDB instrumentation is not active");
527-
// Don't fail the test - this demonstrates the difference between instrumented and
528-
// non-instrumented clients
529-
}
530-
}
531424
}
532425

533426
// Private methods

instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/PostgresKafkaConnectSinkTaskTest.java

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -443,37 +443,7 @@ public void testKafkaConnectSinkTaskInstrumentation() throws IOException, Interr
443443
assertThat(spanCount).as("Should find at least one span").isGreaterThan(0);
444444

445445
assertThat(foundKafkaConnectSpan).as("Should find Kafka Connect span").isTrue();
446-
447-
// JDBC spans are created by the instrumentation, as confirmed by container logs.
448-
// However, in this test environment, we may see spans from both:
449-
// 1. Test setup operations (CREATE TABLE, SELECT COUNT(*) - no parent-child relationship)
450-
// 2. Actual Kafka Connect container operations (with perfect parent-child relationships)
451-
//
452-
// Container logs show perfect trace propagation: Producer → Kafka Connect → JDBC operations
453-
// But test environment may only capture the test-related JDBC spans, not container spans.
454-
assertThat(foundJdbcSpan)
455-
.as("Should find JDBC spans - JDBC instrumentation is active")
456-
.isTrue();
457-
458-
logger.info("JDBC instrumentation test result: JDBC spans were found");
459-
460-
// Parent-child relationships depend on the span source:
461-
// - Container spans (actual Kafka Connect operations): Perfect parent-child relationships ✅
462-
// - Test environment spans (test setup): No parent-child relationships ❌
463-
//
464-
// The container logs prove that trace propagation works perfectly when both
465-
// instrumentations run in the same JVM process.
466-
if (foundParentChildRelationship) {
467-
logger.info(
468-
"✅ SUCCESS: Parent-child relationship found - complete trace propagation verified!");
469-
} else {
470-
logger.info(
471-
"ℹ️ No parent-child relationship in test spans (expected for cross-process scenario)");
472-
logger.info(
473-
"📋 Container logs confirm perfect trace propagation: Producer → Kafka Connect → Database");
474-
logger.info(
475-
"🎯 This demonstrates the instrumentation works correctly for same-JVM deployments");
476-
}
446+
477447
}
478448

479449
@AfterAll
@@ -584,14 +554,6 @@ private static void setupSinkConnector(String topicName) throws IOException {
584554
.then()
585555
.log()
586556
.all();
587-
588-
// Remove this problematic cleanup code:
589-
// try (AdminClient adminClient = createAdminClient()) {
590-
// adminClient.deleteTopics(Collections.singletonList(TOPIC_NAME)).all().get();
591-
// logger.info("Deleted existing topic: " + TOPIC_NAME);
592-
// } catch (e instanceof InterruptedException) {
593-
// logger.info("Topic cleanup: " + e.getMessage());
594-
// }
595557
}
596558

597559
private static void produceMessagesToKafka(String topicName) {

javaagent/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ dependencies {
9494
baseJavaagentLibs(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.52:javaagent"))
9595
baseJavaagentLibs(project(":instrumentation:opentelemetry-instrumentation-api:javaagent"))
9696
baseJavaagentLibs(project(":instrumentation:kafka:kafka-connect-2.6:javaagent"))
97-
baseJavaagentLibs(project(":instrumentation:jdbc:javaagent"))
9897
baseJavaagentLibs(project(":instrumentation:opentelemetry-instrumentation-annotations-1.16:javaagent"))
9998
baseJavaagentLibs(project(":instrumentation:executors:javaagent"))
10099
baseJavaagentLibs(project(":instrumentation:internal:internal-application-logger:javaagent"))

0 commit comments

Comments
 (0)