Skip to main content

grow_signoz/
lib.rs

1// Skeleton created by sdk-kit 0.1.0; owned by this repository (edit freely).
2//! # grow-signoz
3//!
4//! Rust SDK for [SigNoz](https://grow-codes-packages.github.io/signoz/) by Grow Codes.
5//!
6//! ```no_run
7//! # async fn demo() -> grow_signoz::Result<()> {
8//! use grow_signoz::logging::{attrs, LogClient};
9//! use grow_signoz::{FilterBuilder, LogOptions, LogQuery, SignozClient, SignozConfig};
10//!
11//! let client = SignozClient::new(SignozConfig::from_env()?)?;
12//! let health = client.health().await?;
13//! println!("healthy: {}", health.healthy);
14//!
15//! // Ingest: OTLP logs to the SigNoz collector.
16//! let logs = client.log_client(LogOptions::service("checkout"))?;
17//! logs.logger(None, attrs! {}).info("order placed", attrs! { "order.id" => "o-1" });
18//! logs.flush(None).await?;
19//!
20//! // Query: the SigNoz query API with SIGNOZ-API-KEY.
21//! let filter = FilterBuilder::new().eq("service.name", "checkout").build()?;
22//! let page = client.query().query_logs(LogQuery::new(filter)).await?;
23//! println!("{} records", page.records.len());
24//! client.close().await;
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! Ingest goes to the collector (`SignozConfig::otlp_endpoint`, OTLP/HTTP protobuf by default
30//! or OTLP/gRPC): [`SignozClient::log_client`] and [`SignozClient::init_tracing`] /
31//! [`init_tracing`]. Queries go to the query API (`SignozConfig::url`) with the
32//! `SIGNOZ-API-KEY` header: [`SignozClient::query`] returns a [`SignozQueryClient`] with
33//! `query_logs`, `tail`, `query_traces`, `get_trace`, `search_traces`, `list_services`,
34//! `list_operations`, `get_dependencies`, `list_log_fields`, `list_field_values` and
35//! `aggregate`. Filter expressions are built with [`FilterBuilder`], aggregations with
36//! [`AggregateBuilder`].
37//!
38//! SigNoz is a trademark of SigNoz, Inc. This crate is not affiliated with or endorsed by
39//! SigNoz, Inc.
40//!
41//! Features: `blocking` (a blocking client), `testing` (in-memory fakes and the conformance
42//! runner), `tracing-layer` and `log-bridge` (logging adapters, on by default), `tower` and
43//! `reqwest-middleware` (tracing instrumentation).
44#![cfg_attr(docsrs, feature(doc_cfg))]
45
46pub mod core;
47
48mod aggregate;
49mod client;
50mod config;
51mod filter;
52mod http;
53mod init_tracing;
54mod otlp_logs;
55mod query;
56mod query_logs;
57mod query_traces;
58mod tail;
59
60#[cfg(feature = "blocking")]
61#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
62pub mod blocking;
63
64#[cfg(feature = "testing")]
65#[cfg_attr(docsrs, doc(cfg(feature = "testing")))]
66pub mod testing;
67
68pub mod logging;
69pub mod tracing;
70
71pub use crate::core::{Error, ErrorCode, HealthStatus, Result, RetryPolicy, Secret};
72
73pub use crate::config::{
74    API_KEY_HEADER, DEFAULT_OTLP_GRPC_ENDPOINT, DEFAULT_OTLP_HTTP_ENDPOINT, DEFAULT_URL,
75    INGESTION_KEY_HEADER,
76};
77
78pub use crate::aggregate::{
79    AggregateBuilder, AggregatePoint, AggregateQuery, AggregateResult, AggregateRow,
80    AggregateSeries, Aggregation,
81};
82pub use crate::filter::{
83    and_filters, escape_like_pattern, filter_literal, quote_filter_string, FilterBuilder,
84    FilterOperator, FilterValue,
85};
86pub use crate::init_tracing::{
87    create_span_exporter, init_tracing, init_tracing_with_config, tracing_config_for,
88};
89pub use crate::otlp_logs::{
90    build_otlp_logs_request, new_log_client, LogOptions, OtlpLogExporter, LOG_SCOPE_NAME,
91};
92pub use crate::query::{
93    QueryRangeResult, Signal, SignozQueryClient, TimeRange, DEFAULT_QUERY_WINDOW,
94    DEFAULT_SEARCH_LIMIT, DEFAULT_TRACE_SEARCH_LIMIT, MAX_QUERY_LIMIT,
95};
96pub use crate::query_logs::{
97    FieldValuesOptions, ListFieldsOptions, LogField, LogQuery, LogQueryResult,
98};
99pub use crate::query_traces::{SpanQueryResult, TraceQuery};
100pub use crate::tail::DEFAULT_TAIL_RECONNECT;
101
102pub use crate::client::SignozClient;
103
104pub use crate::config::SignozConfig;
105
106pub use crate::config::SignozConfigBuilder;
107
108/// Service-prefixed alias of [`Error`].
109pub type SignozError = Error;