Skip to main content

Crate grow_jaeger

Crate grow_jaeger 

Source
Expand description

§grow-jaeger

Rust SDK for Jaeger by Grow Codes.

use grow_jaeger::tracing::{traced, TracingConfig, TraceSearchQuery};
use grow_jaeger::{init_tracing, JaegerClient, JaegerConfig};

// Export spans to Jaeger over OTLP (http/protobuf on 4318 unless configured otherwise).
let tracing = init_tracing(TracingConfig::new("checkout"))?;
traced("charge-card", async { Ok::<_, std::io::Error>(()) }).await.ok();
tracing.shutdown().await?;

// Read them back through the query API (16686).
let client = JaegerClient::new(JaegerConfig::from_env()?)?;
let summaries = client.query().search_traces(&TraceSearchQuery::service("checkout")).await?;
println!("{} traces", summaries.len());
client.close().await;

Modules: JaegerClient (health, version, sampling strategy), JaegerQueryClient (get_trace, find_traces, search_traces, list_services, list_operations, get_operations, get_dependencies), init_tracing (OTLP preset, presets, remote sampling), JaegerRemoteSampler and the tracing category helpers.

Features: blocking (a blocking client), testing (in-memory fakes and the conformance runner) , tower and reqwest-middleware (tracing instrumentation) .

Re-exports§

pub use crate::core::Error;
pub use crate::core::ErrorCode;
pub use crate::core::HealthStatus;
pub use crate::core::Result;
pub use crate::core::RetryPolicy;
pub use crate::core::Secret;

Modules§

blockingblocking
Blocking wrapper (feature blocking). Each client owns a tokio runtime with one worker thread, so background work (exports, sampler polling, retries’ timers) keeps running between blocking calls.
core
Shared core: errors, configuration, secrets in config, redaction, retries and transport.
normalize
Conversions from Jaeger’s wire formats to the normalized model of the tracing category: OTLP/JSON TracesData (the v3 API), the legacy UI model (/api/traces/{id}), trace summaries (/api/v3/trace-summaries) and dependency links (/api/dependencies).
testingtesting
Test support (feature testing): in-memory fakes and the conformance runner (SPEC §6).
tracing
Tracing category (SPEC §5), built on the OpenTelemetry SDK: setup, span helpers, propagation, framework adapters and the trace query model.

Structs§

GetTraceOptions
Options of JaegerQueryClient::get_trace_with.
JaegerBuildInfo
Build information embedded in the Jaeger UI page (JAEGER_VERSION).
JaegerClient
Async client for Jaeger. Cheap to clone (clones share one connection pool).
JaegerConfig
Immutable client configuration; build it with JaegerConfig::builder or JaegerConfig::from_env. Debug output redacts every credential.
JaegerConfigBuilder
Builder for JaegerConfig. Values set here win over the environment.
JaegerQueryClient
Query client for the Jaeger HTTP query API. Get it with JaegerClient::query or build it with JaegerQueryClient::new. Cheap to clone; implements TraceQueryClient.
JaegerRemoteSampler
OpenTelemetry head sampler driven by Jaeger remote sampling: it polls GET <sampling_url>?service=<service> every poll interval and applies the strategy (see the module docs for the rule). Use it with init_tracing_with_remote_sampler (which wraps it in a parent-based sampler) or SdkTracerProvider::builder().with_sampler(…). Cheap to clone (clones share the strategy and the poller). close stops polling.
JaegerTracingHandle
A running Jaeger tracing setup (SPEC §5 TracingHandle plus the endpoint and the remote sampler). Cheap to clone. Without remote sampling it wraps the category TracingHandle (tracing_handle).
JaegerTracingOptions
Options of init_tracing_with_options.
ListOperationsOptions
Options of JaegerQueryClient::list_operations and JaegerQueryClient::get_operations.
Operation
One operation of a service, as returned by JaegerQueryClient::get_operations.
OperationStrategy
Sampling probability of one operation (span name).
RateLimiter
Token bucket that lets at most credits_per_second traces through per second, with a burst of max(credits_per_second, 1). It starts full, so a rate of 0 lets the first trace through and then none (Jaeger behaviour).
RemoteSamplerOptions
Options of JaegerRemoteSampler::with_options.
SamplingPreset
A named head-sampling choice for TracingConfig.
SamplingStrategy
A Jaeger remote sampling strategy (the /sampling?service= response).

Enums§

RemoteSampling
Remote sampling for JaegerTracingOptions.
StrategyType
Strategy type of a SamplingStrategy.

Constants§

DEFAULT_DEPENDENCY_LOOKBACK
Dependency lookback when no start is given: 24 hours.
DEFAULT_GET_TRACE_WINDOW
Time hint JaegerQueryClient::get_trace sends: the last 7 days.
DEFAULT_INITIAL_SAMPLING_RATE
Probability applied until the first strategy arrives (Jaeger and OpenTelemetry default).
DEFAULT_OTLP_GRPC_ENDPOINT
Default OTLP/gRPC endpoint of a Jaeger all-in-one or collector.
DEFAULT_OTLP_HTTP_ENDPOINT
Default OTLP/HTTP traces endpoint of a Jaeger all-in-one or collector.
DEFAULT_SAMPLING_POLL_INTERVAL
How often a JaegerRemoteSampler polls by default (Jaeger default: 1 minute).
DEFAULT_SAMPLING_URL
Remote sampling endpoint (port 5778) used when neither the builder nor the environment sets one.
DEFAULT_SEARCH_WINDOW
Search window when a TraceSearchQuery has no start: the hour before end (Jaeger requires both bounds).
DEFAULT_TRACING_PROTOCOL
Protocol of the Jaeger preset: OTLP over HTTP/protobuf (works through proxies).
DEFAULT_URL
Query endpoint (UI and HTTP query API, port 16686) used when neither the builder nor the environment sets one.

Functions§

init_tracing
Sets up OpenTelemetry tracing for Jaeger (SPEC §5): the environment fills every field the config leaves unset (see tracing_config_from_env), the exporter is jaeger_exporter. OTEL_TRACES_SAMPLER=jaeger_remote (or parentbased_jaeger_remote) turns on remote sampling with the URL from OTEL_TRACES_SAMPLER_ARG endpoint=, else GROW_JAEGER_SAMPLING_URL / JAEGER_SAMPLING_ENDPOINT / the default. Must be called inside a tokio runtime. Call JaegerTracingHandle::shutdown before exit.
init_tracing_with_options
init_tracing with options.
init_tracing_with_remote_sampler
init_tracing with a JaegerRemoteSampler deciding sampling (parent-based; the sampler is not closed by the handle).
jaeger_exporter
Builds the official OTLP span exporter for Jaeger from a config (the exporter factory of init_tracing_with): http/protobuf posts protobuf to the resolved endpoint (see resolve_endpoint), grpc uses tonic. Headers, compression, timeout and TLS (CA, client certificate, insecure_skip_verify over HTTP) come from the config. native is CONFIG (Jaeger ingests OTLP), and so is insecure_skip_verify over gRPC (tonic cannot skip verification). The environment is not read here; see tracing_config_from_env.
parse_sampling_strategy
Parses and validates a /sampling response body. Missing numbers count as 0 (proto3 JSON omits zero values); a missing strategyType means PROBABILISTIC; a RATE_LIMITING strategy without rateLimitingSampling or probabilisticSampling rate-limits at 0 traces per second. VALIDATION for malformed JSON, an unknown type or values out of range.
resolve_endpoint
The exporter URL for a protocol: for http/protobuf, an endpoint without a path (a base such as http://jaeger:4318) gets /v1/traces; any other endpoint is used as is. Without an endpoint, the Jaeger default for the protocol.
tracing_config_from_env
Fills every unset field of config from env and applies the Jaeger preset (protocol http/protobuf, endpoint per protocol, always set in the result). Precedence: explicit > GROW_JAEGER_OTLP_* > OTEL_EXPORTER_OTLP_TRACES_* > OTEL_EXPORTER_OTLP_* > default. A field still at its TracingConfig::new default counts as unset.

Type Aliases§

JaegerError
Service-prefixed alias of Error.