Skip to content

Commit 367c983

Browse files
authored
rename with_metrics_options to with_metrics (#35)
1 parent cc29827 commit 367c983

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub fn configure() -> LogfireConfigBuilder {
255255
console_mode: ConsoleMode::Force,
256256
additional_span_processors: Vec::new(),
257257
advanced: None,
258-
metrics: None,
258+
metrics: Some(MetricsOptions::default()),
259259
enable_metrics: true,
260260
install_panic_handler: false,
261261
default_level_filter: None,
@@ -338,7 +338,7 @@ impl LogfireConfigBuilder {
338338

339339
/// Whether to log to the console.
340340
#[must_use]
341-
#[deprecated(note = "use `console_options()` instead")]
341+
#[deprecated(since = "0.4.0", note = "use `with_console()` instead")]
342342
#[expect(deprecated)]
343343
pub fn console_mode(mut self, console_mode: ConsoleMode) -> Self {
344344
// FIXME: remove this API and make it match Python, see `console_options()` below
@@ -392,16 +392,25 @@ impl LogfireConfigBuilder {
392392
}
393393

394394
/// Configure [metrics options](crate::config::MetricsOptions).
395+
///
396+
/// Set to `None` to disable metrics.
395397
#[must_use]
398+
pub fn with_metrics(mut self, metrics: Option<MetricsOptions>) -> Self {
399+
self.metrics = metrics;
400+
self
401+
}
402+
403+
/// Configure [metrics options](crate::config::MetricsOptions).
404+
#[must_use]
405+
#[deprecated(since = "0.4.0", note = "use `with_metrics` instead")]
396406
pub fn with_metrics_options(mut self, metrics: MetricsOptions) -> Self {
397407
self.metrics = Some(metrics);
398408
self
399409
}
400410

401411
/// Whether to enable metrics.
402-
///
403-
/// If set to false, this will override [`with_metrics_options`][Self::with_metrics_options].
404412
#[must_use]
413+
#[deprecated(since = "0.4.0", note = "use `with_metrics(None)` to disable metrics")]
405414
pub fn enable_metrics(mut self, enable: bool) -> Self {
406415
self.enable_metrics = enable;
407416
self

tests/test_basic_exports.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ fn test_basic_span() {
10321032
"code.lineno",
10331033
),
10341034
value: I64(
1035-
666,
1035+
675,
10361036
),
10371037
},
10381038
KeyValue {
@@ -1295,7 +1295,9 @@ async fn test_basic_metrics() {
12951295

12961296
let handler = logfire::configure()
12971297
.send_to_logfire(false)
1298-
.with_metrics_options(MetricsOptions::default().with_additional_reader(reader.clone()))
1298+
.with_metrics(Some(
1299+
MetricsOptions::default().with_additional_reader(reader.clone()),
1300+
))
12991301
.with_advanced_options(
13001302
AdvancedOptions::default()
13011303
.with_resource(Resource::builder_empty().with_service_name("test").build()),

0 commit comments

Comments
 (0)