1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! OpenTelemetry [`SdkLoggerProvider`] used for audit and slow-query
//! records.
//!
//! Audit records and slow-query records flow into this logger provider in
//! addition to their existing durable file sink. The provider routes
//! records to the OTLP logs exporter (when configured), so an OTLP
//! subscriber receives the same structured stream that compliance
//! operators see in the file-based audit log.
//!
//! The file sink is intentionally retained as a separate, parallel path:
//! it carries the durable, hash-chained, fsync-able compliance trail and
//! is independent of OTLP availability. The OTel logger provider here
//! adds a non-blocking push exporter on top.
//!
//! The provider is no longer stored in a process-wide `OnceLock`. The
//! telemetry [`Builder`](super::Builder) returns it as part of the
//! [`ObservabilityRuntime`](crate::observe::ObservabilityRuntime) so
//! every observer that wants an audit logger asks the runtime instance
//! it was constructed with rather than mutating a global.
use WithTonicConfig;
use Resource;
use ;
use ClientTlsConfig;
use OTEL_DEFAULT_RESOURCE;
use crate;
/// Whether OTLP push for logs is configured. Reuses the same gate as
/// metrics: when `SURREAL_TELEMETRY_PROVIDER=otlp` and metrics are not
/// explicitly disabled, OTLP logs export is also enabled. A separate
/// `SURREAL_TELEMETRY_DISABLE_LOGS` knob can be added later if operators
/// need finer control.
/// Build the audit / slow-query logger provider.
///
/// Returns `None` when OTLP is not configured, in which case the caller
/// builds an [`ObservabilityRuntime`](crate::observe::ObservabilityRuntime)
/// without an audit logger and emit-site code resolves
/// [`ObservabilityRuntime::audit_logger`] to `None`. When OTLP is
/// configured, the provider carries a [`BatchLogProcessor`] feeding the
/// gRPC OTLP logs exporter.