| Crates.io | agp-tracing |
| lib.rs | agp-tracing |
| version | 0.2.1 |
| created_at | 2025-02-11 12:48:01.926804+00 |
| updated_at | 2025-05-14 09:34:05.36473+00 |
| description | Observability for AGP data plane: logs, traces and metrics infrastructure. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1551376 |
| size | 91,348 |
This module provides tracing and observability functionalities for the gateway. It includes the main entry point for the tracing logic and additional utilities.
lib.rsThis file contains the main entry point for the tracing module.
opaque.rsThis file provides utilities for handling opaque tracing data.
To use this module, include it in your Cargo.toml:
[dependencies]
gateway-tracing = "0.1.0"
The module provides a TracingConfiguration struct for configuring logging and tracing:
let config = TracingConfiguration::default()
.with_log_level("debug".to_string())
.enable_opentelemetry();
let _guard = config.setup_tracing_subscriber();
The tracing subscriber must be set up inside a tokio runtime.
The module includes built-in support for OpenTelemetry, enabling distributed tracing and metrics collection.
To start the telemetry stack locally during development (otel-collector, Jaeger, Prometheus):
task data-plane:telemetry:start
This will set up:
To add span instrumentation to your functions:
#[tracing::instrument]
fn process_request(req_id: &str, payload: &Payload) {
// Function logic here will be automatically traced
// with req_id and payload as span attributes
}
For more details on instrumentation, see: tracing instrument documentation: https://docs.rs/tracing/latest/tracing/attr.instrument.html
You can also create manual spans:
use tracing::{info, info_span};
let span = info_span!("processing", request_id = req_id);
let _guard = span.enter();
// Operations inside this scope will be captured in the span
info!("Starting processing");
Metrics can be recorded directly using the tracing macros:
use tracing::info;
// Record a counter metric
info!(counter.num_active_connections = 1);
For more details on metrics usage, see: tracing-opentelemetry MetricsLayer documentation: https://docs.rs/tracing-opentelemetry/latest/tracing_opentelemetry/struct.MetricsLayer.html#usage