Skip to main content

grow_apache_skywalking/
lib.rs

1// Skeleton created by sdk-kit 0.1.0; owned by this repository (edit freely).
2//! # grow-apache-skywalking
3//!
4//! Rust SDK for [Apache SkyWalking](https://grow-codes-packages.github.io/apache-skywalking/) by
5//! Grow Codes: the OAP GraphQL query API, OpenTelemetry tracing exported over OTLP/gRPC,
6//! native logs, `sw8` propagation and the SPEC trace/log query clients.
7//!
8//! ```no_run
9//! # async fn demo() -> grow_apache_skywalking::Result<()> {
10//! use grow_apache_skywalking::tracing::TraceQueryClient;
11//! use grow_apache_skywalking::{SkyWalkingClient, SkyWalkingConfig};
12//!
13//! let client = SkyWalkingClient::new(SkyWalkingConfig::from_env()?)?;
14//! println!("healthy: {}", client.health().await?.healthy);
15//! println!("version: {}", client.server_version().await?);
16//! let services = client.query().list_services(None, None).await?;
17//! let traced = client.traces().list_services().await?;
18//! println!("{} native services, {} traced services", services.len(), traced.len());
19//! client.close().await;
20//! # Ok(())
21//! # }
22//! ```
23//!
24//! | Module | What |
25//! | - | - |
26//! | [`SkyWalkingClient`] | health, ping, server version, raw GraphQL, log client, tracing setup |
27//! | [`SkyWalkingQueryClient`] | services, endpoints, instances, native traces, logs, topology |
28//! | [`SkyWalkingTraceQueryClient`] | SPEC `TraceQueryClient` (Zipkin store for OTLP, native store for agents) |
29//! | [`SkyWalkingLogQueryClient`] | SPEC `LogQueryClient` (`queryLogs`, client-side text filter) |
30//! | [`init_tracing`] | OpenTelemetry → OTLP/gRPC to OAP (port 11800), `sw8` propagator |
31//!
32//! Features: `blocking` (a blocking client), `testing` (in-memory fakes and the conformance
33//! runner), `tracing-layer` and `log-bridge` (logging adapters, on by default), `tower` and
34//! `reqwest-middleware` (tracing instrumentation).
35#![cfg_attr(docsrs, feature(doc_cfg))]
36
37pub mod core;
38
39mod api;
40mod client;
41mod config;
42mod duration;
43mod logs;
44mod native;
45mod query;
46mod setup;
47mod sw8;
48mod traces;
49mod zipkin;
50
51#[cfg(feature = "blocking")]
52#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
53pub mod blocking;
54
55#[cfg(feature = "testing")]
56#[cfg_attr(docsrs, doc(cfg(feature = "testing")))]
57pub mod testing;
58
59pub mod logging;
60pub mod tracing;
61
62pub use crate::core::{Error, ErrorCode, HealthStatus, Result, RetryPolicy, Secret};
63
64pub use crate::api::{
65    graphql_error, graphql_errors, GraphQLErrorInfo, GraphQLResponse, SkyWalkingCapabilities,
66    TimeInfo,
67};
68pub use crate::client::{create_log_client, SkyWalkingClient, SkyWalkingLogClientOptions};
69pub use crate::config::{
70    base_from_graphql_url, collector_to_url, parse_otlp_headers, zipkin_query_url, OtlpProtocol,
71    SkyWalkingConfig, SkyWalkingConfigBuilder, TraceBackend, DEFAULT_GRAPHQL_PATH, DEFAULT_URL,
72    OTLP_GRPC_PORT, VENDOR_AUTHENTICATION_VARS, VENDOR_OTLP_ENDPOINT_VARS,
73    VENDOR_OTLP_HEADERS_VARS, VENDOR_OTLP_PROTOCOL_VARS, VENDOR_TRACE_BACKEND_VARS,
74    VENDOR_URL_VARS, VENDOR_ZIPKIN_URL_VARS, ZIPKIN_QUERY_PORT,
75};
76pub use crate::duration::{
77    endpoint_id, epoch_ms, format_duration_time, from_epoch_ms, instance_id, parse_timezone,
78    resolve_range, service_id, service_id_with, to_graphql_duration, GraphQLDuration,
79    ResolvedRange, Step, TimeRange, DEFAULT_RANGE,
80};
81pub use crate::logs::{
82    log_to_record, matches_text, parse_log_query, record_to_log_data, tag_text, ParsedLogQuery,
83    SkyWalkingLogExporter, SkyWalkingLogQueryClient, DEFAULT_LOG_SERVICE_NAME,
84    DEFAULT_MAX_SCAN_PAGES, LOG_SCAN_PAGE_SIZE,
85};
86pub use crate::native::{
87    decode_native_span, decode_topology, key_values, native_span_key, native_span_to_span,
88    native_trace_from_spans, native_trace_to_trace, topology_to_dependencies, KeyValue, NativeSpan,
89    NativeSpanLog, NativeSpanRef, NativeTrace, Topology, TopologyCall, TopologyNode,
90    NATIVE_SPAN_FIELDS,
91};
92pub use crate::query::{
93    decode_native_log, InstanceAttribute, LogOrder, NativeLog, Paging, QueryLogsOptions,
94    QueryLogsResult, QueryTracesOptions, QueryTracesResult, SkyWalkingEndpoint, SkyWalkingInstance,
95    SkyWalkingQueryClient, SkyWalkingService, TopologyOptions, TraceOrder, TraceState,
96};
97pub use crate::setup::{
98    apply_skywalking_defaults, init_tracing, init_tracing_with_config, skywalking_propagators,
99    skywalking_span_exporter, tracing_config, AUTHENTICATION_HEADER,
100};
101pub use crate::sw8::{
102    decode_sw8, decode_sw8_correlation, encode_sw8, encode_sw8_correlation, sw8_attributes,
103    sw8_context, with_sw8_context, Sw8Context, Sw8InjectContext, Sw8Propagator,
104    SW8_CORRELATION_HEADER, SW8_HEADER, SW8_PROPAGATOR,
105};
106pub use crate::traces::{SkyWalkingTraceQueryClient, DEFAULT_TRACE_SEARCH_LIMIT};
107pub use crate::zipkin::{
108    annotation_to_event, is_bookkeeping_tag, is_hex_trace_id, strings_from_body, summarize,
109    zipkin_span_to_span, zipkin_spans_from_body, zipkin_trace_id, zipkin_trace_to_trace,
110    zipkin_traces_from_body, ZipkinAnnotation, ZipkinEndpoint, ZipkinSpan,
111};
112
113/// Service-prefixed alias of [`Error`].
114pub type SkyWalkingError = Error;