Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into grid-slot-matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 committed Dec 19, 2024
2 parents 4e663bb + 825b040 commit 744678d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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);
}
}

0 comments on commit 744678d

Please sign in to comment.