Skip to content

Feature/6.1/tracing util#10

Open
TravisWhip wants to merge 2 commits into
6.1from
feature/6.1/tracing-util
Open

Feature/6.1/tracing util#10
TravisWhip wants to merge 2 commits into
6.1from
feature/6.1/tracing-util

Conversation

@TravisWhip
Copy link
Copy Markdown

@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.

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.

@obilliard
Copy link
Copy Markdown

Hey @TravisWhip,
Thanks for this, some good stuff in there.
However, it would be best if most of that code was provided by the core. It does not make sense to copy the util in every project as we want to keep things simple.
Can you please create a core ticket asking for that enhancement?

@TravisWhip
Copy link
Copy Markdown
Author

TravisWhip commented Jan 20, 2026

Hey @obilliard,
@nidabouzid has already created a ticket PIVOT-13116 asking for the core to have a public API to add traces, which references this PR.

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