Out-of-the-box tracing support
Using Spring Boot
The Spring Boot starters wire up automatically all you need for tracing, given an ObservationRegistry bean is present.
All you need is the standard Spring Boot tracing setup. Add the following dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Required for the Restate Client instrumentation, not shipped by spring-boot-actuator -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-java11</artifactId>
</dependency>And configure the exporter of your choice.
For more details on setting up supported exporters, refer to the Spring Boot tracing documentation.
To set up a sample OTLP tracing exporter, add the following dependencies:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>And setup the tracing endpoint in the application.properties:
# Sample every request (tune for production)
management.tracing.sampling.probability=1.0
# OTLP gRPC endpoint (e.g. Jaeger on 4317). Use 4318 + transport=http_protobuf for HTTP/protobuf.
management.otlp.tracing.endpoint=http://localhost:4317
management.otlp.tracing.transport=grpcUsing OpenTelemetry with vanilla SDK
The new module dev.restate:sdk-interceptor-opentelemetry adds tracing for both the Java and Kotlin APIs:
- For every handler invocation attempt, an
attempt <target>span is created, and linked up automatically with the parent span propagated from Restate. - For every executed
ctx.run(name, ...)block, arun (<name>)child span is created. Spans are automatically propagated to the thread executing therunclosure.
To configure:
- Set up a
GlobalOpenTelemetryusing the OpenTelemetry SDK. The easiest way is to use OpenTelemetry autoconfigure SDK as shown in this official example - Manually set up a specific
OpenTelemetryinstance and register the factory:
var otel = new OpenTelemetryInterceptorFactory(openTelemetry);
var endpoint =
Endpoint.bind(
new MyService(),
new HandlerRunner.Options()
.addHandlerInterceptorFactory(otel)
.addRunInterceptorFactory(otel))
.build();Using Micrometer with vanilla SDK
The new module dev.restate:sdk-interceptor-micrometer adds tracing through Micrometer Observation for both the Java and Kotlin APIs:
- For every handler invocation attempt, an
attempt <target>observation is created, and linked up automatically with the parent span propagated from Restate. - For every executed
ctx.run(name, ...)block, arun (<name>)child observation is created. Observations are automatically propagated to the thread executing therunclosure.
Spans produced through the Micrometer tracing bridge mirror those emitted by the OpenTelemetry integration, so dashboards look the same regardless of which integration you pick.
To configure, set up an ObservationRegistry instance and register the factory:
var micrometer = new MicrometerInterceptorFactory(observationRegistry);
var endpoint =
Endpoint.bind(
new MyService(),
new HandlerRunner.Options()
.addHandlerInterceptorFactory(micrometer)
.addRunInterceptorFactory(micrometer))
.build();New interceptor API
The new tracing support is built on a new public interceptor API in dev.restate.sdk.interceptor (Java) and dev.restate.sdk.kotlin.interceptor (Kotlin), which you can use to plug in your own cross-cutting concerns, such as custom tracing, metrics, MDC/logging scopes, error mapping, and so on.
Check out the Javadocs or Kotlindocs for more details.
The interceptor API is marked experimental and may change in future releases.
Full Changelog: v2.7.0...v2.8.0