Skip to content

Commit 55880e7

Browse files
refactor: Use impl trait consistently in method parameters
1 parent f7cc03e commit 55880e7

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/span_ext.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ pub trait OpenTelemetrySpanExt {
183183
///
184184
/// app_root.add_event("job_completed", vec![KeyValue::new("status", "success")]);
185185
/// ```
186-
fn add_event<T>(&self, name: T, attributes: Vec<KeyValue>)
187-
where
188-
T: Into<Cow<'static, str>>;
186+
fn add_event(&self, name: impl Into<Cow<'static, str>>, attributes: Vec<KeyValue>);
189187

190188
/// Adds an OpenTelemetry event with a specific timestamp directly to this span.
191189
/// Similar to `add_event`, but allows overriding the event timestamp.
@@ -207,13 +205,12 @@ pub trait OpenTelemetrySpanExt {
207205
///
208206
/// app_root.add_event_with_timestamp(event_name, event_time, event_attrs);
209207
/// ```
210-
fn add_event_with_timestamp<T>(
208+
fn add_event_with_timestamp(
211209
&self,
212-
name: T,
210+
name: impl Into<Cow<'static, str>>,
213211
timestamp: SystemTime,
214212
attributes: Vec<KeyValue>,
215-
) where
216-
T: Into<Cow<'static, str>>;
213+
);
217214
}
218215

219216
impl OpenTelemetrySpanExt for tracing::Span {
@@ -307,17 +304,16 @@ impl OpenTelemetrySpanExt for tracing::Span {
307304
});
308305
}
309306

310-
fn add_event<T>(&self, name: T, attributes: Vec<KeyValue>)
311-
where
312-
T: Into<Cow<'static, str>>,
313-
{
307+
fn add_event(&self, name: impl Into<Cow<'static, str>>, attributes: Vec<KeyValue>) {
314308
self.add_event_with_timestamp(name, time::now(), attributes);
315309
}
316310

317-
fn add_event_with_timestamp<T>(&self, name: T, timestamp: SystemTime, attributes: Vec<KeyValue>)
318-
where
319-
T: Into<Cow<'static, str>>,
320-
{
311+
fn add_event_with_timestamp(
312+
&self,
313+
name: impl Into<Cow<'static, str>>,
314+
timestamp: SystemTime,
315+
attributes: Vec<KeyValue>,
316+
) {
321317
self.with_subscriber(move |(id, subscriber)| {
322318
let mut event = Some(opentelemetry::trace::Event::new(
323319
name, timestamp, attributes, 0,

0 commit comments

Comments
 (0)