Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package server;

import static datadog.trace.agent.test.assertions.SpanMatcher.span;
import static datadog.trace.agent.test.assertions.TraceMatcher.trace;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertTrue;

import datadog.context.ContextScope;
import datadog.trace.agent.test.AbstractInstrumentationTest;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import io.vertx.core.Vertx;
import io.vertx.ext.web.sstore.LocalSessionStore;
import io.vertx.ext.web.sstore.impl.LocalSessionStoreImpl;
import org.junit.jupiter.api.Test;

class LocalSessionStoreInstrumentationTest extends AbstractInstrumentationTest {
@Test
void initializingSessionStoreDoesNotRetainRequest() throws Exception {
Vertx vertx = Vertx.vertx();
try {
AgentSpan parent = startSpan("test", "parent");
LocalSessionStore store;
try (ContextScope ignored = activateSpan(parent)) {
store = LocalSessionStore.create(vertx, "initializing", 60_000);
} finally {
parent.finish();
}
try {
assertTrue(
writer.waitForTracesMax(1, 3), "Session-store timers retained the request trace");
assertTraces(trace(span().root().operationName("parent")));
} finally {
store.close();
}
} finally {
vertx.close().toCompletionStage().toCompletableFuture().get(10, SECONDS);
}
}

@Test
void rearmingSessionReaperDoesNotRetainRequest() throws Exception {
Vertx vertx = Vertx.vertx();
LocalSessionStore store = LocalSessionStore.create(vertx, "rearming", 60_000);
try {
AgentSpan parent = startSpan("test", "parent");
try (ContextScope ignored = activateSpan(parent)) {
((LocalSessionStoreImpl) store).handle(0L);
} finally {
parent.finish();
}
assertTrue(writer.waitForTracesMax(1, 3), "Session reaper retained the request trace");
assertTraces(trace(span().root().operationName("parent")));
} finally {
store.close();
vertx.close().toCompletionStage().toCompletableFuture().get(10, SECONDS);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datadog.trace.instrumentation.vertx_5_0.server;
package datadog.trace.instrumentation.vertx_4_0.server;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.isAsyncPropagationEnabled;
Expand All @@ -21,7 +21,7 @@
public final class LocalSessionStoreInstrumentation extends InstrumenterModule.ContextTracking
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
public LocalSessionStoreInstrumentation() {
super("vertx", "vertx-5.0");
super("vertx");
}

@Override
Expand All @@ -31,7 +31,8 @@ public String instrumentedType() {

@Override
public Reference[] additionalMuzzleReferences() {
return new Reference[] {VertxVersionMatcher.HTTP_HEADERS_INTERNAL};
// Vert.x 3.9 has the same class and timer methods.
return new Reference[] {VertxVersionMatcher.HTTP_1X_SERVER_RESPONSE};
Comment thread
bric3 marked this conversation as resolved.
}

@Override
Expand Down
Loading