Skip to main content
Exporting custom metrics and logs is available in the Shuttle Pro Tier and above.
This guide will show you how to add custom metrics and tracing events to your Shuttle application using the tracing crate.

Getting Started

First, add the tracing dependency to your project:

Basic Usage

Add tracing events with fields to your functions to create custom metrics. Here’s a simple example:
This will:
  1. Send an info level log to stdout
  2. Export the metric to your configured telemetry provider
  3. Include the custom attribute counter.hello with value 1

Metric Types

The runtime’s OTel exporter uses tracing-opentelemetry under the hood, which automatically handles three metric types:
  1. Monotonic Counters: Values that only increase (e.g., total requests)
  2. Counters: Values that can increase or decrease
  3. Histograms: For measuring distributions of values

Example Trace Output

Here’s what a tracing event looks like when exported:

Best Practices

  1. Use Meaningful Names: Choose clear, descriptive names for your metrics
  2. Include Context: Add relevant context to your metrics
  3. Use Appropriate Metric Types:
    • Use monotonic_counter for values that only increase
    • Use counter for values that can go up and down
    • Use histogram for measuring distributions

Learn More