Skip to content

Instantly share code, notes, and snippets.

@marcingrzejszczak
Last active April 21, 2021 11:48
Show Gist options
  • Select an option

  • Save marcingrzejszczak/d3c15a0c11dda71970e42c513c9c0e09 to your computer and use it in GitHub Desktop.

Select an option

Save marcingrzejszczak/d3c15a0c11dda71970e42c513c9c0e09 to your computer and use it in GitHub Desktop.
Notes on Sleuth to Brave migration

Removed features

  • SpanLogger
    • Name pattern of Span Logger will not be applicable
  • Sampler
    • TODO: describe the new sampling mechanism

Sleuth's Tracer to brave.Tracing

Before

import org.springframework.cloud.sleuth.Tracer;

Tracer tracer;

After

import brave.Tracing;

Tracing tracing;

Child span creation

Before

Span child = tracer.createSpan("name");

After

// tracing is brave.Tracing injected instead of Sleuth's Tracer
brave.Span span = tracing.tracer().nextSpan().name("name");

Span closing

Before

Span child = tracer.createSpan("name");
try {
  // do sth
} finally {
  tracer.close(child);
}

After

// tracing is brave.Tracing injected instead of Sleuth's Tracer
brave.Span span = this.tracing.tracer().nextSpan().name("name");
try {
  // do sth
} finally {
  span.finish();
}

Span tagging

Before

tracer.addTag("foo", "bar");

After

// tracing is brave.Tracing injected instead of Sleuth's Tracer
this.tracing.tracer().currentSpan().tag("foo", "bar");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment