Skip to content

Conversation

@TravisWhip
Copy link

@TravisWhip TravisWhip commented Dec 30, 2025

Added a simple utility to create tracing Spans.

Closable spans

These spans are wrapped in a Closable class so they are ended when out of scope. Spans can be easily created to track a method / given scope with.

Example usages

I have added a span around the initial load.

  private void initialLoad() {
    @Cleanup var span = TracingUtil.startSpan("Initial CSV Data Load");
    ... method body ...
  }

This gives us a span with sub-spans:
image

Automatic closing of Span when out of scope:

void myMethod(){
  @Cleanup var span = TracingUtil.startSpan(); // Span with name "MyClass.myMethod" is created & started
  ... method code ...
  ... Span is automatically closed at the end of this method's scope due to lombok's @Cleanup annotation.
}

Spans can be kept open:

class MyClass {
  TracingUtil.ClosableSpan span;

  void start(){
    span = TracingUtil.startSpan("My multi-method span");
  }
  void end(){
    span.close();
  }
}

Cleanup still required

The property TracingUtil.defaultTracingScopeName is static and set at startup from a Void bean which may not be the cleanest.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants