Skip to content

Commit 766de2e

Browse files
committed
Bulk conversion
1 parent 0de27c0 commit 766de2e

File tree

32 files changed

+412
-401
lines changed

32 files changed

+412
-401
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ license = "MIT"
1414
license-file = "LICENSE.txt"
1515

1616
[workspace.dependencies]
17+
bon = "3"
1718
derive_builder = "0.20"
1819
derive_more = { version = "2.0", features = [
1920
"constructor",

crates/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test-utilities = ["history_builders"]
2323
anyhow = "1.0"
2424
async-trait = "0.1"
2525
base64 = "0.22"
26+
bon = { workspace = true }
2627
dirs = { version = "6.0", optional = true }
2728
derive_builder = { workspace = true }
2829
derive_more = { workspace = true }

crates/common/src/telemetry.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,30 @@ pub trait CoreTelemetry {
2828
fn fetch_buffered_logs(&self) -> Vec<CoreLog>;
2929
}
3030

31-
/// Telemetry configuration options. Construct with [TelemetryOptionsBuilder]
32-
#[derive(Clone, derive_builder::Builder)]
31+
/// Telemetry configuration options. Construct with [TelemetryOptions::builder]
32+
#[derive(Clone, bon::Builder)]
3333
#[non_exhaustive]
3434
pub struct TelemetryOptions {
3535
/// Optional logger - set as None to disable.
36-
#[builder(setter(into, strip_option), default)]
36+
#[builder(into)]
3737
pub logging: Option<Logger>,
3838
/// Optional metrics exporter - set as None to disable.
39-
#[builder(setter(into, strip_option), default)]
39+
#[builder(into)]
4040
pub metrics: Option<Arc<dyn CoreMeter>>,
4141
/// If set true (the default) explicitly attach a `service_name` label to all metrics. Turn this
4242
/// off if your collection system supports the `target_info` metric from the OpenMetrics spec.
4343
/// For more, see
4444
/// [here](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems)
45-
#[builder(default = "true")]
45+
#[builder(default = true)]
4646
pub attach_service_name: bool,
4747
/// A prefix to be applied to all core-created metrics. Defaults to "temporal_".
48-
#[builder(default = "METRIC_PREFIX.to_string()")]
48+
#[builder(default = METRIC_PREFIX.to_string())]
4949
pub metric_prefix: String,
5050
/// If provided, logging config will be ignored and this explicit subscriber will be used for
5151
/// all logging and traces.
52-
#[builder(setter(strip_option), default)]
5352
pub subscriber_override: Option<Arc<dyn Subscriber + Send + Sync>>,
5453
/// See [TaskQueueLabelStrategy].
55-
#[builder(default = "TaskQueueLabelStrategy::UseNormal")]
54+
#[builder(default = TaskQueueLabelStrategy::UseNormal)]
5655
pub task_queue_label_strategy: TaskQueueLabelStrategy,
5756
}
5857
impl Debug for TelemetryOptions {
@@ -96,19 +95,19 @@ pub enum TaskQueueLabelStrategy {
9695
}
9796

9897
/// Options for exporting to an OpenTelemetry Collector
99-
#[derive(Debug, Clone, derive_builder::Builder)]
98+
#[derive(Debug, Clone, bon::Builder)]
10099
pub struct OtelCollectorOptions {
101100
/// The url of the OTel collector to export telemetry and metrics to. Lang SDK should also
102101
/// export to this same collector.
103102
pub url: Url,
104103
/// Optional set of HTTP headers to send to the Collector, e.g for authentication.
105-
#[builder(default = "HashMap::new()")]
104+
#[builder(default = HashMap::new())]
106105
pub headers: HashMap<String, String>,
107106
/// Optionally specify how frequently metrics should be exported. Defaults to 1 second.
108-
#[builder(default = "Duration::from_secs(1)")]
107+
#[builder(default = Duration::from_secs(1))]
109108
pub metric_periodicity: Duration,
110109
/// Specifies the aggregation temporality for metric export. Defaults to cumulative.
111-
#[builder(default = "MetricTemporality::Cumulative")]
110+
#[builder(default = MetricTemporality::Cumulative)]
112111
pub metric_temporality: MetricTemporality,
113112
/// A map of tags to be applied to all metrics
114113
#[builder(default)]
@@ -120,12 +119,12 @@ pub struct OtelCollectorOptions {
120119
#[builder(default)]
121120
pub histogram_bucket_overrides: HistogramBucketOverrides,
122121
/// Protocol to use for communication with the collector
123-
#[builder(default = "OtlpProtocol::Grpc")]
122+
#[builder(default = OtlpProtocol::Grpc)]
124123
pub protocol: OtlpProtocol,
125124
}
126125

127126
/// Options for exporting metrics to Prometheus
128-
#[derive(Debug, Clone, derive_builder::Builder)]
127+
#[derive(Debug, Clone, bon::Builder)]
129128
pub struct PrometheusExporterOptions {
130129
pub socket_addr: SocketAddr,
131130
// A map of tags to be applied to all metrics
@@ -205,7 +204,7 @@ pub enum OtlpProtocol {
205204

206205
impl Default for TelemetryOptions {
207206
fn default() -> Self {
208-
TelemetryOptionsBuilder::default().build().unwrap()
207+
TelemetryOptions::builder().build()
209208
}
210209
}
211210

crates/common/src/telemetry/metrics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,16 @@ impl WorkerHeartbeatMetrics {
259259
}
260260
}
261261

262-
#[derive(Debug, Clone, derive_builder::Builder)]
262+
#[derive(Debug, Clone, bon::Builder)]
263263
pub struct MetricParameters {
264264
/// The name for the new metric/instrument
265-
#[builder(setter(into))]
265+
#[builder(into)]
266266
pub name: Cow<'static, str>,
267267
/// A description that will appear in metadata if the backend supports it
268-
#[builder(setter(into), default = "\"\".into()")]
268+
#[builder(into, default = Cow::Borrowed(""))]
269269
pub description: Cow<'static, str>,
270270
/// Unit information that will appear in metadata if the backend supports it
271-
#[builder(setter(into), default = "\"\".into()")]
271+
#[builder(into, default = Cow::Borrowed(""))]
272272
pub unit: Cow<'static, str>,
273273
}
274274
impl From<&'static str> for MetricParameters {

0 commit comments

Comments
 (0)