Skip to main content

Crate grow_signoz

Crate grow_signoz 

Source
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§

blockingblocking
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 Logger facade, the query model and framework adapters.
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.

Macros§

attrs
Builds an Attributes map: attrs! { "user" => "ada", "n" => 3 }.

Structs§

AggregateBuilder
Builds an AggregateQuery fluently:
AggregatePoint
One bucket of a time series.
AggregateQuery
A count/percentile query for SignozQueryClient::aggregate; build it with AggregateBuilder or as a literal.
AggregateResult
Result of SignozQueryClient::aggregate: rows for scalar queries, series for time series.
AggregateRow
One group of a scalar aggregate.
AggregateSeries
One time series of a time-series aggregate.
Aggregation
One aggregate expression and the name its values get in the result.
FieldValuesOptions
Narrows SignozQueryClient::list_field_values.
FilterBuilder
Builds SigNoz filter expressions, for example
ListFieldsOptions
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.
LogQueryResult
One page of SignozQueryClient::query_logs.
OtlpLogExporter
A LogExporter that sends records to the SigNoz collector over OTLP/HTTP protobuf (POST <endpoint>/v1/logs) or OTLP/gRPC (LogsService/Export), with the signoz-ingestion-key header when an ingestion key is configured. Retries are left to the BatchProcessor.
QueryRangeResult
Result of SignozQueryClient::query_range.
SignozClient
Async client for SigNoz. Cheap to clone (clones share one connection pool).
SignozConfig
Immutable client configuration; build it with SignozConfig::builder or SignozConfig::from_env. Debug output redacts every credential.
SignozConfigBuilder
Builder for SignozConfig. Values set here win over the environment.
SignozQueryClient
Query client of the SigNoz query API. Get it from SignozClient::query; cheap to clone. It implements LogQueryClient and TraceQueryClient.
SpanQueryResult
Result of SignozQueryClient::query_traces: one Span per matching span.
TimeRange
A query time window. None means the default: end = now, start = end − 1 h.
TraceQuery
A spans query for SignozQueryClient::query_traces. The default lists the newest 100 spans of the last hour.

Enums§

FilterOperator
Comparison operator for FilterBuilder::where_op.
FilterValue
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::interval is 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, one ResourceLogs per 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 of config, or OTLP/gRPC with the headers as metadata (TLS for https endpoints).
escape_like_pattern
Escapes \, % and _ so text matches literally inside CONTAINS or LIKE (quote it afterwards).
filter_literal
Renders a filter value: strings quoted (quote_filter_string), booleans true/false, numbers bare. Non-finite floats are VALIDATION errors.
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, …) unless tracing sets them. No API key is needed. Use SignozClient::init_tracing to 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 (see tracing_config_for). Must be called inside a tokio runtime.
new_log_client
Starts a batching LogClient that sends OTLP logs to the SigNoz collector described by config. 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 s in single quotes with \ and ' escaped.
tracing_config_for
Fills the export settings tracing leaves open from config:

Type Aliases§

SignozError
Service-prefixed alias of Error.