Source:
<code>public ResponseEntity postEvent(@PathVariable final String eventTypeName, @RequestBody final String eventsAsString, final NativeWebRequest request, final Client client) throws AccessDeniedException, BlockedException, ServiceTemporarilyUnavailableException, InternalNakadiException, EventTypeTimeoutException, NoSuchEventTypeException { LOG.trace("Received event for event type {}", eventsAsString, eventTypeName); final HttpServletRequest httpServletRequest = request.getNativeRequest(HttpServletRequest.class); <START> final Scope publishingScope = TracingService <END> .getScope("controller", true, (Span) httpServletRequest.getAttribute("span")); publishingScope.span() .setTag(Tags.SPAN_KIND_PRODUCER, client.getClientId()) .setTag("event_type", eventTypeName); Tags.HTTP_METHOD.set(publishingScope.span(), POST.toString()); final EventTypeMetrics eventTypeMetrics = eventTypeMetricRegistry.metricsFor(eventTypeName); if (blacklistService.isProductionBlocked(eventTypeName, client.getClientId())) { publishingScope.span().setTag("status_code", FORBIDDEN.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); throw new BlockedException("Application or event type is blocked"); } try { final ResponseEntity response = postEventInternal( eventTypeName, eventsAsString, request, eventTypeMetrics, client, publishingScope.span()); eventTypeMetrics.incrementResponseCount(response.getStatusCode().value()); Tags.HTTP_STATUS.set(publishingScope.span(), response.getStatusCode().value()); return response; } catch (final NoSuchEventTypeException exception) { eventTypeMetrics.incrementResponseCount(NOT_FOUND.getStatusCode()); Tags.HTTP_STATUS.set(publishingScope.span(), NOT_FOUND.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); throw exception; } catch (final RuntimeException ex) { eventTypeMetrics.incrementResponseCount(INTERNAL_SERVER_ERROR.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); Tags.HTTP_STATUS.set(publishingScope.span(), INTERNAL_SERVER_ERROR.getStatusCode()); throw ex; } }</code><technical_language>Is a span fails instantiated? asking broken instrumentation Nakadi fail</technical_language>

Target:
public ResponseEntity postEvent(@PathVariable final String eventTypeName, @RequestBody final String eventsAsString, final NativeWebRequest request, final Client client) throws AccessDeniedException, BlockedException, ServiceTemporarilyUnavailableException, InternalNakadiException, EventTypeTimeoutException, NoSuchEventTypeException { LOG.trace("Received event for event type {}", eventsAsString, eventTypeName); final HttpServletRequest httpServletRequest = request.getNativeRequest(HttpServletRequest.class); final Scope publishingScope = TracingService .activateSpan((Span) httpServletRequest.getAttribute("span"), false); publishingScope.span() .setTag(Tags.SPAN_KIND_PRODUCER, client.getClientId()) .setTag("event_type", eventTypeName); Tags.HTTP_METHOD.set(publishingScope.span(), POST.toString()); final EventTypeMetrics eventTypeMetrics = eventTypeMetricRegistry.metricsFor(eventTypeName); if (blacklistService.isProductionBlocked(eventTypeName, client.getClientId())) { publishingScope.span().setTag("status_code", FORBIDDEN.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); throw new BlockedException("Application or event type is blocked"); } try { final ResponseEntity response = postEventInternal( eventTypeName, eventsAsString, request, eventTypeMetrics, client, publishingScope.span()); eventTypeMetrics.incrementResponseCount(response.getStatusCode().value()); Tags.HTTP_STATUS.set(publishingScope.span(), response.getStatusCode().value()); return response; } catch (final NoSuchEventTypeException exception) { eventTypeMetrics.incrementResponseCount(NOT_FOUND.getStatusCode()); Tags.HTTP_STATUS.set(publishingScope.span(), NOT_FOUND.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); throw exception; } catch (final RuntimeException ex) { eventTypeMetrics.incrementResponseCount(INTERNAL_SERVER_ERROR.getStatusCode()); Tags.ERROR.set(publishingScope.span(), true); Tags.HTTP_STATUS.set(publishingScope.span(), INTERNAL_SERVER_ERROR.getStatusCode()); throw ex; } }