Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log at debug when completeSpan methods are used with no active trace #1016

Merged
merged 2 commits into from
Mar 15, 2023

Conversation

carterkozak
Copy link
Contributor

Such states suggest that a bug has occurred closing more spans than were opened.

==COMMIT_MSG==
Log at debug when completeSpan methods are used with no active trace
==COMMIT_MSG==

Such states suggest that a bug has occurred closing more spans
than were opened.
@changelog-app
Copy link

changelog-app bot commented Mar 14, 2023

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Log at debug when completeSpan methods are used with no active trace

Check the box to generate changelog(s)

  • Generate changelog entry

log.debug(
"Attempted to complete spans when there is no active Trace. This may be the "
+ "result of calling completeSpan more times than startSpan",
new SafeRuntimeException("not a real exception"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also do this on line 656 as well when there is no open span?

    private static <T> void completeSpanAndNotifyObservers(
            Optional<OpenSpan> openSpan, TagTranslator<? super T> tag, T state, String traceId) {
        //noinspection OptionalIsPresent - Avoid lambda allocation in hot paths
        if (openSpan.isPresent()) {
            Tracer.notifyObservers(toSpan(openSpan.get(), tag, state, traceId));
        } else if (log.isDebugEnabled()) {
            log.debug(
                    "Attempted to complete spans when there is no active Trace. This may be the "
                            + "result of calling completeSpan more times than startSpan",
                    new SafeRuntimeException("not a real exception"));
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that works because Optional<OpenSpan> isn't necessarily present unless the span is sampled:

@Override
Optional<OpenSpan> pop() {
validateNumberOfSpans();
if (numberOfSpans > 0) {
numberOfSpans--;
}
return Optional.empty();
}

We clear the current trace when the final span is completed, so I don't think that would give us additional coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

log.debug(
"Attempted to complete spans when there is no active Trace. This may be the "
+ "result of calling completeSpan more times than startSpan",
new SafeRuntimeException("not a real exception"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

@bulldozer-bot bulldozer-bot bot merged commit ee89d8e into develop Mar 15, 2023
@bulldozer-bot bulldozer-bot bot deleted the ckozak/asymmetric_span_completion_logging branch March 15, 2023 13:26
@svc-autorelease
Copy link
Collaborator

Released 6.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants