Expand description

Common telemetry tools.

We focus on supporting the following Rust APIs:

  • tracing for tracing, with support for fowarding from log.
  • metrics for monitoring.

We specifically try to integrate with OpenTelemetry and to support standard "traceparent" and "tracestate" headers.

Environment Variables

The following variables can be used to configure

  • RUST_LOG can be used to control our logging levels in the normal fashion.
  • OPINIONATED_TELEMETRY_TRACER can be set to cloud_trace or debug to enable OpenTelelmetry tracing. If not set, we will log to stderr using tracing, honoring the filter specified by RUST_LOG.
  • OPINIONATED_TELEMETRY_METRICS can be set to prometheus to enable Prometheus metrics, or debug to log metrics. Otherwise metrics will not be reported.
  • OPINIONATED_TELEMETRY_PROMETHEUS_LISTEN_ADDR defaults to `“0.0.0.0:9090”.
  • OPINIONATED_TELEMETRY_PROMETHEUS_PUSHGATEWAY_URL must be specified for CLI tools using Prometheus. We strongly recommend using prom-aggregation-gateway instead of Prometheus’s default pushgateway.
  • OTEL_SERVICE_NAME and OTEL_SERVICE_VERSION can be used to identify your service. If not set, we will use the service_name and service_version parameters to [start_telemetry] or run_with_telemetry. Other OTEL_ variables supported by the opentelemetry crate may also be respected.

For CLI tools, these variables will normally be set by the calling app:

  • TRACEPARENT and TRACESTATE can be passed to CLI tools to link them into an existing trace. These follow the conventions of the W3C Trace Context.

Metric naming conventions

For best results across different metrics reporting systems, we recommend following the Prometheus metric naming conventions.

Example metric names:

  • myapp_requests_total: Counter with no units.
  • myapp_processed_bytes_total: Counter with units.
  • myapp_memory_usage_bytes: Gauge with units.

Label naming

Labels should be “low-arity”. Specifically, that means that labels should have only a small number of possible values, because each possible label value will require most backends to store a new time series.

Re-exports

Macros

Structs

Enums

Traits

Functions

Type Aliases

  • The result type of this library.