public void endSpan(@NotNull String spanName, Function<Span, Span> action) {
    if (!spans.containsKey(spanName)) {
      LOG.error(String.format("Span with name %s isn't started yet, but was called to stop", spanName));
    }

    Span span = spans.get(spanName);
    if (span != null) {
      try {
        action.apply(span).end();
      }
      catch (Exception e) {
        LOG.error(String.format("Error while stopping span %s ", spanName), e);
      }
    }
  }
public void endSpan(@NotNull String spanName, Function<Span, Span> action)