Skip to content

Commit 217a23c

Browse files
authored
leverage native async trait in JaegerJsonRuntime and GcpAuthorizer (#186)
1 parent 5c72573 commit 217a23c

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

opentelemetry-contrib/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ api = []
2323
default = []
2424
base64_format = ["base64", "binary_propagator"]
2525
binary_propagator = []
26-
jaeger_json_exporter = ["opentelemetry_sdk", "serde_json", "futures-core", "futures-util", "async-trait"]
26+
jaeger_json_exporter = ["opentelemetry_sdk", "serde_json", "futures-core", "futures-util"]
2727
rt-tokio = ["tokio", "opentelemetry_sdk/rt-tokio"]
2828
rt-tokio-current-thread = ["tokio", "opentelemetry_sdk/rt-tokio-current-thread"]
2929
rt-async-std = ["async-std", "opentelemetry_sdk/rt-async-std"]
3030

3131
[dependencies]
3232
async-std = { version = "1.10", optional = true }
33-
async-trait = { version = "0.1", optional = true }
3433
base64 = { version = "0.22", optional = true }
3534
futures-core = { version = "0.3", optional = true }
3635
futures-util = { version = "0.3", optional = true, default-features = false }

opentelemetry-contrib/src/trace/exporter/jaeger_json.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! # Jaeger JSON file Exporter
22
//!
33
4-
use async_trait::async_trait;
54
use futures_core::future::BoxFuture;
65
use futures_util::FutureExt;
76
use opentelemetry::trace::SpanId;
@@ -205,16 +204,18 @@ fn opentelemetry_value_to_json(value: &opentelemetry::Value) -> (&str, serde_jso
205204
/// Jaeger Json Runtime is an extension to [`RuntimeChannel`].
206205
///
207206
/// [`RuntimeChannel`]: opentelemetry_sdk::runtime::RuntimeChannel
208-
#[async_trait]
209207
pub trait JaegerJsonRuntime: RuntimeChannel + std::fmt::Debug {
210208
/// Create a new directory if the given path does not exist yet
211-
async fn create_dir(&self, path: &Path) -> OTelSdkResult;
209+
fn create_dir(&self, path: &Path) -> impl std::future::Future<Output = OTelSdkResult> + Send;
212210
/// Write the provided content to a new file at the given path
213-
async fn write_to_file(&self, path: &Path, content: &[u8]) -> OTelSdkResult;
211+
fn write_to_file(
212+
&self,
213+
path: &Path,
214+
content: &[u8],
215+
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
214216
}
215217

216218
#[cfg(feature = "rt-tokio")]
217-
#[async_trait]
218219
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::Tokio {
219220
async fn create_dir(&self, path: &Path) -> OTelSdkResult {
220221
if tokio::fs::metadata(path).await.is_err() {
@@ -244,7 +245,6 @@ impl JaegerJsonRuntime for opentelemetry_sdk::runtime::Tokio {
244245
}
245246

246247
#[cfg(feature = "rt-tokio-current-thread")]
247-
#[async_trait]
248248
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::TokioCurrentThread {
249249
async fn create_dir(&self, path: &Path) -> OTelSdkResult {
250250
if tokio::fs::metadata(path).await.is_err() {
@@ -274,7 +274,6 @@ impl JaegerJsonRuntime for opentelemetry_sdk::runtime::TokioCurrentThread {
274274
}
275275

276276
#[cfg(feature = "rt-async-std")]
277-
#[async_trait]
278277
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::AsyncStd {
279278
async fn create_dir(&self, path: &Path) -> OTelSdkResult {
280279
if async_std::fs::metadata(path).await.is_err() {

opentelemetry-etw-metrics/src/etw/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub fn register() {
3333
}
3434

3535
/// Write an event to the ETW provider.
36+
#[allow(clippy::repr_packed_without_abi)]
3637
pub fn write(buffer: &[u8]) -> u32 {
3738
tracelogging::write_event!(
3839
PROVIDER,

opentelemetry-resource-detectors/src/host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::process::Command;
1616
///
1717
/// This resource detector returns the following information:
1818
///
19-
/// - [`host.id from non-containerized systems`]: https://opentelemetry.io/docs/specs/semconv/resource/host/#collecting-hostid-from-non-containerized-systems
19+
/// - [`host.id from non-containerized systems`](https://opentelemetry.io/docs/specs/semconv/resource/host/#collecting-hostid-from-non-containerized-systems)
2020
/// - Host architecture (host.arch).
2121
pub struct HostResourceDetector {
2222
host_id_detect: fn() -> Option<String>,

opentelemetry-stackdriver/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ exclude = ["/proto"]
1010
rust-version = "1.75.0"
1111

1212
[dependencies]
13-
async-trait = "0.1.48"
1413
gcp_auth = { version = "0.12", optional = true }
1514
hex = "0.4"
1615
http = "1"

opentelemetry-stackdriver/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use std::{
2323
time::{Duration, Instant},
2424
};
2525

26-
use async_trait::async_trait;
2726
use futures_core::future::BoxFuture;
2827
use futures_util::stream::StreamExt;
2928
use opentelemetry::{
@@ -442,7 +441,6 @@ impl GcpAuthorizer {
442441
}
443442

444443
#[cfg(feature = "gcp-authorizer")]
445-
#[async_trait]
446444
impl Authorizer for GcpAuthorizer {
447445
type Error = Error;
448446

@@ -470,16 +468,15 @@ impl Authorizer for GcpAuthorizer {
470468
}
471469
}
472470

473-
#[async_trait]
474471
pub trait Authorizer: Sync + Send + 'static {
475472
type Error: std::error::Error + fmt::Debug + Send + Sync;
476473

477474
fn project_id(&self) -> &str;
478-
async fn authorize<T: Send + Sync>(
475+
fn authorize<T: Send + Sync>(
479476
&self,
480477
request: &mut Request<T>,
481478
scopes: &[&str],
482-
) -> Result<(), Self::Error>;
479+
) -> impl Future<Output = Result<(), Self::Error>> + Send;
483480
}
484481

485482
impl From<Value> for AttributeValue {

0 commit comments

Comments
 (0)