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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//! # Rust SDK for Pydantic Logfire
//!
//! From the team behind Pydantic Validation, **Pydantic Logfire** is an observability platform built on the same belief as our open source library — that the most powerful tools can be easy to use.
//!
//! The most important API is [`logfire::configure()`][configure], which is used to set up
//! integrations with `tracing` and `log`, as well as exporters for `opentelemetry`. Code
//! instrumented using `tracing` and `log` will *just work* once this configuration is in place.
//!
//! This SDK also offers opinionated functions to instrument code following Logfire's design principles:
//! - **traces**: [`logfire::span!()`][span] to create a span with structured data.
//! - **logs**: [`logfire::info!()`][info], [`logfire::debug!()`][debug] and similar macros to log messages
//! with structured data.
//! - **metrics**: [`logfire::u64_counter()`][u64_counter] and similar functions.
//!
//! See the [Logfire documentation](https://logfire.pydantic.dev/docs/) for more information about
//! Logfire in general, and the [Logfire GitHub repository](https://github.com/pydantic/logfire) for
//! the source of that documentation, the Python SDK and an issue tracker for general questions
//! about Logfire.
//!
//! # Usage
//!
//! The setup for this SDK is a quick three-step process:
//! 1. Add the `logfire` crate to your `Cargo.toml`.
//! 2. Call [`logfire::configure()`][configure] at the start of your program to set up the SDK.
//! 3. Run your application with the [`LOGFIRE_TOKEN`] environment variable set to connect it to the Logfire platform.
//!
//! This process is demonstrated below. The [usage guide][usage] contains more detailed information about how to use this
//! SDK to its full potential.
//!
//! ## Getting Started
//!
//! To use `logfire` in your Rust project, add the following to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! ```
//!
//! Then, in your Rust code, add a call to [`logfire::configure()`][configure] at the beginning of your program:
//!
//! ```rust
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let logfire = logfire::configure()
//! # .send_to_logfire(logfire::config::SendToLogfire::IfTokenPresent)
//! .finish()?;
//!
//! let _guard = logfire.shutdown_guard();
//!
//! logfire::info!("Hello world");
//!
//! // Guard automatically shuts down Logfire when it goes out of scope
//! Ok(())
//! }
//! ```
//!
//! ## Configuration
//!
//! After adding basic setup as per above, the most two important environment variables are:
//! - [`LOGFIRE_TOKEN`] (required) - the token to send data to the Logfire platform
//! - [`RUST_LOG`](https://docs.rs/env_logger/latest/env_logger/#filtering-results) (optional) - the level of verbosity to send to the Logfire platform. By default
//! data is captured at `TRACE` level so that all data is available for you to analyze in the
//! Logfire platform. This format should match the format used by the [`env_logger`](https://docs.rs/env_logger/) crate.
//!
//! All environment variables supported by the Rust Opentelemetry SDK are also supported by the
//! Logfire SDK.
//!
//! ## Usage Guide
//!
//! See the [usage guide][usage] for more detailed information about how to use this SDK to its full potential.
//!
//! # Examples
//!
//! See [examples][usage::examples] subchapter of this documentation.
//!
//! [`LOGFIRE_TOKEN`]: https://logfire.pydantic.dev/docs/how-to-guides/create-write-tokens/
use Error;
use crateLogfireConfigBuilder;
pub use *;
pub use *;
pub use crateLogfireTracingLayer;
pub use crate;
/// An error which may arise when configuring Logfire.
/// An error which may arise when shutting down Logfire.
/// Main entry point to configure logfire.
///
/// This should be called once at the start of the program.
///
/// See [`LogfireConfigBuilder`] for the full set of configuration options.
///
/// # Example
///
/// ```rust
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let logfire = logfire::configure()
/// # .send_to_logfire(logfire::config::SendToLogfire::IfTokenPresent)
/// .finish()?;
///
/// let _guard = logfire.shutdown_guard();
///
/// logfire::info!("Hello world");
///
/// // Guard automatically shuts down Logfire when it goes out of scope
/// Ok(())
/// }
/// ```
pub use crateset_local_logfire;