How to add custom metrics and tracing events to your Shuttle application
This guide will show you how to add custom metrics and tracing events to your Shuttle application using the tracing
crate.
First, add the tracing
dependency to your project:
Add tracing events with fields to your functions to create custom metrics. Here’s a simple example:
This will:
info
level log to stdoutcounter.hello
with value 1
The runtime’s OTel exporter uses tracing-opentelemetry
under the hood, which automatically handles three metric types:
Monotonic Counters: Values that only increase (e.g., total requests)
Counters: Values that can increase or decrease
Histograms: For measuring distributions of values
Here’s what a tracing event looks like when exported:
Use Meaningful Names: Choose clear, descriptive names for your metrics
Include Context: Add relevant context to your metrics
Use Appropriate Metric Types:
monotonic_counter
for values that only increasecounter
for values that can go up and downhistogram
for measuring distributionsHow to add custom metrics and tracing events to your Shuttle application
This guide will show you how to add custom metrics and tracing events to your Shuttle application using the tracing
crate.
First, add the tracing
dependency to your project:
Add tracing events with fields to your functions to create custom metrics. Here’s a simple example:
This will:
info
level log to stdoutcounter.hello
with value 1
The runtime’s OTel exporter uses tracing-opentelemetry
under the hood, which automatically handles three metric types:
Monotonic Counters: Values that only increase (e.g., total requests)
Counters: Values that can increase or decrease
Histograms: For measuring distributions of values
Here’s what a tracing event looks like when exported:
Use Meaningful Names: Choose clear, descriptive names for your metrics
Include Context: Add relevant context to your metrics
Use Appropriate Metric Types:
monotonic_counter
for values that only increasecounter
for values that can go up and downhistogram
for measuring distributions