Expand description
§grow-signoz
Rust SDK for SigNoz by Grow Codes.
use grow_signoz::logging::{attrs, LogClient};
use grow_signoz::{FilterBuilder, LogOptions, LogQuery, SignozClient, SignozConfig};
let client = SignozClient::new(SignozConfig::from_env()?)?;
let health = client.health().await?;
println!("healthy: {}", health.healthy);
// Ingest: OTLP logs to the SigNoz collector.
let logs = client.log_client(LogOptions::service("checkout"))?;
logs.logger(None, attrs! {}).info("order placed", attrs! { "order.id" => "o-1" });
logs.flush(None).await?;
// Query: the SigNoz query API with SIGNOZ-API-KEY.
let filter = FilterBuilder::new().eq("service.name", "checkout").build()?;
let page = client.query().query_logs(LogQuery::new(filter)).await?;
println!("{} records", page.records.len());
client.close().await;Ingest goes to the collector (SignozConfig::otlp_endpoint, OTLP/HTTP protobuf by default
or OTLP/gRPC): SignozClient::log_client and SignozClient::init_tracing /
init_tracing. Queries go to the query API (SignozConfig::url) with the
SIGNOZ-API-KEY header: SignozClient::query returns a SignozQueryClient with
query_logs, tail, query_traces, get_trace, search_traces, list_services,
list_operations, get_dependencies, list_log_fields, list_field_values and
aggregate. Filter expressions are built with FilterBuilder, aggregations with
AggregateBuilder.
SigNoz is a trademark of SigNoz, Inc. This crate is not affiliated with or endorsed by SigNoz, Inc.
Features: blocking (a blocking client), testing (in-memory fakes and the conformance
runner), tracing-layer and log-bridge (logging adapters, on by default), 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§
- blocking
blocking - Blocking wrapper (feature
blocking). Each client owns a small tokio runtime (one worker thread, so log batching and span export keep running between calls). - core
- Shared core: errors, configuration, secrets in config, redaction, retries and transport.
- logging
- Logging category (SPEC §4): records, batching, redaction, the
Loggerfacade, the query model and framework adapters. - testing
testing - 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.
Macros§
- attrs
- Builds an
Attributesmap:attrs! { "user" => "ada", "n" => 3 }.
Structs§
- Aggregate
Builder - Builds an
AggregateQueryfluently: - Aggregate
Point - One bucket of a time series.
- Aggregate
Query - A count/percentile query for
SignozQueryClient::aggregate; build it withAggregateBuilderor as a literal. - Aggregate
Result - Result of
SignozQueryClient::aggregate:rowsfor scalar queries,seriesfor time series. - Aggregate
Row - One group of a scalar aggregate.
- Aggregate
Series - One time series of a time-series aggregate.
- Aggregation
- One aggregate expression and the name its values get in the result.
- Field
Values Options - Narrows
SignozQueryClient::list_field_values. - Filter
Builder - Builds SigNoz filter expressions, for example
- List
Fields Options - Narrows
SignozQueryClient::list_log_fields. The default lists every field. - LogField
- One log field known to SigNoz. A name may exist in several contexts (for example an attribute and a resource attribute).
- LogOptions
- Options for
SignozClient::log_client/new_log_client. The default is valid. - LogQuery
- A logs query for
SignozQueryClient::query_logs. The default lists the newest 100 records of the last hour. - LogQuery
Result - One page of
SignozQueryClient::query_logs. - Otlp
LogExporter - A
LogExporterthat sends records to the SigNoz collector over OTLP/HTTP protobuf (POST <endpoint>/v1/logs) or OTLP/gRPC (LogsService/Export), with thesignoz-ingestion-keyheader when an ingestion key is configured. Retries are left to theBatchProcessor. - Query
Range Result - Result of
SignozQueryClient::query_range. - Signoz
Client - Async client for SigNoz. Cheap to clone (clones share one connection pool).
- Signoz
Config - Immutable client configuration; build it with
SignozConfig::builderorSignozConfig::from_env.Debugoutput redacts every credential. - Signoz
Config Builder - Builder for
SignozConfig. Values set here win over the environment. - Signoz
Query Client - Query client of the SigNoz query API. Get it from
SignozClient::query; cheap to clone. It implementsLogQueryClientandTraceQueryClient. - Span
Query Result - Result of
SignozQueryClient::query_traces: oneSpanper matching span. - Time
Range - A query time window.
Nonemeans the default: end = now, start = end − 1 h. - Trace
Query - A spans query for
SignozQueryClient::query_traces. The default lists the newest 100 spans of the last hour.
Enums§
- Filter
Operator - Comparison operator for
FilterBuilder::where_op. - Filter
Value - A value in a filter expression: strings are quoted and escaped, numbers and booleans are rendered bare.
- Signal
- A SigNoz telemetry signal for the query builder.
Constants§
- API_
KEY_ HEADER - Header that carries the service-account API key on query calls (redacted everywhere).
- DEFAULT_
OTLP_ GRPC_ ENDPOINT - Default OTLP/gRPC endpoint of the SigNoz collector.
- DEFAULT_
OTLP_ HTTP_ ENDPOINT - Default OTLP/HTTP endpoint of the SigNoz collector.
- DEFAULT_
QUERY_ WINDOW - Time window of a query without an explicit start: the hour before the end (the end defaults to now).
- DEFAULT_
SEARCH_ LIMIT - Default page size of raw logs and spans queries.
- DEFAULT_
TAIL_ RECONNECT - Wait before a dropped live tail stream is reconnected (when
TailOptions::intervalis zero). - DEFAULT_
TRACE_ SEARCH_ LIMIT - Default number of traces returned by
search_traces. - DEFAULT_
URL - Query API endpoint used when neither the builder nor the environment sets one (SigNoz UI + API port 8080).
- INGESTION_
KEY_ HEADER - Header / gRPC metadata that carries the SigNoz Cloud ingestion key on exports.
- LOG_
SCOPE_ NAME - Instrumentation scope of records exported by this package.
- MAX_
QUERY_ LIMIT - Largest row limit the SigNoz query API accepts.
Functions§
- and_
filters - Joins non-empty expressions with
AND, parenthesising each when there is more than one. - build_
otlp_ logs_ request - Converts records to an OTLP
ExportLogsServiceRequest, oneResourceLogsper distinct resource. Invalid trace or span ids are left out (the collector would reject the whole batch). - create_
span_ exporter - Builds the OTLP span exporter for a resolved tracing config (see
tracing_config_for): OTLP/HTTP protobuf with a client that honours TLS, proxy and connect timeout ofconfig, or OTLP/gRPC with the headers as metadata (TLS forhttpsendpoints). - escape_
like_ pattern - Escapes
\,%and_sotextmatches literally insideCONTAINSorLIKE(quote it afterwards). - filter_
literal - Renders a filter value: strings quoted (
quote_filter_string), booleanstrue/false, numbers bare. Non-finite floats areVALIDATIONerrors. - init_
tracing - Starts OpenTelemetry tracing that exports spans to SigNoz. The collector endpoint,
protocol, ingestion key and TLS settings come from the environment
(
SignozConfig::from_env:GROW_SIGNOZ_OTLP_ENDPOINT,SIGNOZ_OTLP_ENDPOINT, …) unlesstracingsets them. No API key is needed. UseSignozClient::init_tracingto take them from an existing client instead. - init_
tracing_ with_ config - Starts OpenTelemetry tracing that exports spans to SigNoz with
config’s collector endpoint, protocol, ingestion key and TLS (seetracing_config_for). Must be called inside a tokio runtime. - new_
log_ client - Starts a batching
LogClientthat sends OTLP logs to the SigNoz collector described byconfig. It needs no API key (only the ingestion key for SigNoz Cloud). Must be called inside a tokio runtime; close it to flush. - quote_
filter_ string - Quotes
sin single quotes with\and'escaped. - tracing_
config_ for - Fills the export settings
tracingleaves open fromconfig:
Type Aliases§
- Signoz
Error - Service-prefixed alias of
Error.