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
Expand Up @@ -37,7 +37,7 @@ public TracedCommandExecutor(CommandExecutor delegate, Tracer tracer) {

@Override
public Response execute(Command command) throws IOException {
try (Span commandSpan = tracer.getCurrentContext().createSpan("command")) {
try (Span commandSpan = tracer.getCurrentContext().createSpan(command.getName())) {
SessionId sessionId = command.getSessionId();
if (sessionId != null) {
commandSpan.setAttribute("sessionId", sessionId.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.remote;

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
Expand Down Expand Up @@ -48,7 +49,7 @@ class TracedCommandExecutorTest {
public void createMocksAndTracedCommandExecutor() {
MockitoAnnotations.initMocks(this);
when(tracer.getCurrentContext()).thenReturn(traceContext);
when(traceContext.createSpan("command")).thenReturn(span);
when(traceContext.createSpan(anyString())).thenReturn(span);
tracedCommandExecutor = new TracedCommandExecutor(commandExecutor, tracer);
}

Expand Down Expand Up @@ -109,4 +110,18 @@ void canCreateSpanWithCommandName() throws IOException {
verify(span, times(1)).close();
verifyNoMoreInteractions(span);
}

@Test
void canCreateSpanWithCommandNameAsSpanName() throws IOException {
SessionId sessionId = new SessionId(UUID.randomUUID());
Command command = new Command(sessionId, "findElement");

tracedCommandExecutor.execute(command);

verify(traceContext).createSpan("findElement");
verify(span).setAttribute("sessionId", sessionId.toString());
verify(span).setAttribute("command", "findElement");
verify(span).close();
verifyNoMoreInteractions(span);
}
}
Loading