Skip to content

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Aug 30, 2021

==COMMIT_MSG==
Support attaching DetachedSpan state to a thread without creating children
==COMMIT_MSG==

Potential Downsides

Previously we tried to couple thread state transitions/associations directly with named spans to more easily discover and remediate tracing state leak. Using @MustBeClosed should make it harder to create asymmetric start/complete tracing structures, and we're clearly pushing more spans than we'd like. I'd rather relax our opinions in this project than further reduce tracing rate while pushing unhelpful data.

@changelog-app
Copy link

changelog-app bot commented Aug 30, 2021

Generate changelog in changelog/@unreleased

Type

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

Description

Support attaching DetachedSpan state to a thread without creating children

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from CRogers August 30, 2021 16:09
@carterkozak
Copy link
Contributor Author

@smoorpal This is the piece that should enable the capability you were looking for in dialogue -- this way we can decouple the concerns around retaining trace state from span creation.

* completed separately.
*/
@MustBeClosed
CloseableSpan attach();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CloseableSpan type is a little bit odd here because it's not actually creating a span. I played with a new (though functionally identical) CloseableContext type to make the naming cleaner, but it also made the api larger, so I've pushed reusing the existing type.

assertThat(observed.get(0)).extracting(Span::getOperation).isEqualTo(operationName + " initial");
assertThat(observed.get(1)).extracting(Span::getOperation).isEqualTo(operationName);
assertThat(observed).hasSize(1);
assertThat(observed.get(0)).extracting(Span::getOperation).isEqualTo(operationName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everyone using the Tracers.wrapListenableFuture functionality will get cleaner tracing spans (no more "initial" span) when they upgrade.

@bulldozer-bot bulldozer-bot bot merged commit 8cd27e5 into develop Aug 30, 2021
@bulldozer-bot bulldozer-bot bot deleted the ckozak/span_free_attach branch August 30, 2021 17:08
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