HttpHandler { Span handleStart(HttpRequest request, Span span) { if (span.isNoop()) return span; try { parseRequest(request, span); } catch (Throwable t) { propagateIfFatal(t); Platform.get().log("error parsing request {0}", request, t); } finally { long timestamp = request.startTimestamp(); if (timestamp == 0L) { span.start(); } else { span.start(timestamp); } } return span; } HttpHandler(HttpRequestParser requestParser, HttpResponseParser responseParser);   }
@Test public void handleStart_parsesTagsWithCustomizer() { when(span.isNoop()).thenReturn(false); when(request.spanKind()).thenReturn(Span.Kind.SERVER); handler.handleStart(request, span); verify(requestParser).parse(request, context, spanCustomizer); }
@Test public void handleStart_addsRemoteEndpointWhenParsed() { handler = new HttpHandler(HttpRequestParser.DEFAULT, HttpResponseParser.DEFAULT) { @Override void parseRequest(HttpRequest request, Span span) { span.remoteIpAndPort("1.2.3.4", 0); } }; handler.handleStart(request, span); verify(span).remoteIpAndPort("1.2.3.4", 0); }
@Test public void handleStart_startedEvenIfParsingThrows() { when(span.isNoop()).thenReturn(false); doThrow(new RuntimeException()).when(requestParser).parse(request, context, spanCustomizer); handler.handleStart(request, span); verify(span).start(); }
@Test public void handleStart_nothingOnNoop_success() { when(span.isNoop()).thenReturn(true); handler.handleStart(request, span); verify(span, never()).start(); }