Update opentelemetry dependencies

This commit is contained in:
asonix 2023-11-13 12:43:07 -06:00
parent 0663e5f331
commit dd2f7ffd5d
4 changed files with 45 additions and 35 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "tracing-awc"
description = "Tracing instrumentation for the awc http client"
version = "0.1.8"
version = "0.1.9"
authors = ["asonix <asonix@asonix.dog"]
edition = "2018"
license = "AGPL-3.0"
@ -10,11 +10,11 @@ readme = "README.md"
[[example]]
name = "client"
required-features = ["opentelemetry_0_20"]
required-features = ["opentelemetry_0_21"]
[[example]]
name = "server"
required-features = ["opentelemetry_0_20"]
required-features = ["opentelemetry_0_21"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@ -50,7 +50,11 @@ opentelemetry_0_19 = [
]
opentelemetry_0_20 = [
"opentelemetry_0_20_pkg",
"tracing-opentelemetry_0_20_pkg",
"tracing-opentelemetry_0_21_pkg",
]
opentelemetry_0_21 = [
"opentelemetry_0_21_pkg",
"tracing-opentelemetry_0_22_pkg",
]
[dependencies]
@ -67,6 +71,7 @@ opentelemetry_0_17_pkg = { package = "opentelemetry", version = "0.17", optional
opentelemetry_0_18_pkg = { package = "opentelemetry", version = "0.18", optional = true }
opentelemetry_0_19_pkg = { package = "opentelemetry", version = "0.19", optional = true }
opentelemetry_0_20_pkg = { package = "opentelemetry", version = "0.20", optional = true }
opentelemetry_0_21_pkg = { package = "opentelemetry", version = "0.21", optional = true }
pin-project-lite = "0.2.7"
tracing = "0.1"
tracing-opentelemetry_0_12_pkg = { package = "tracing-opentelemetry", version = "0.12", optional = true }
@ -76,16 +81,16 @@ tracing-opentelemetry_0_16_pkg = { package = "tracing-opentelemetry", version =
tracing-opentelemetry_0_17_pkg = { package = "tracing-opentelemetry", version = "0.17", optional = true }
tracing-opentelemetry_0_18_pkg = { package = "tracing-opentelemetry", version = "0.18", optional = true }
tracing-opentelemetry_0_19_pkg = { package = "tracing-opentelemetry", version = "0.19", optional = true }
tracing-opentelemetry_0_20_pkg = { package = "tracing-opentelemetry", version = "0.20", optional = true }
tracing-opentelemetry_0_21_pkg = { package = "tracing-opentelemetry", version = "0.21", optional = true }
tracing-opentelemetry_0_22_pkg = { package = "tracing-opentelemetry", version = "0.22", optional = true }
[dev-dependencies]
actix-rt = "2.6"
actix-web = { version = "4.0.0", default-features = false }
opentelemetry-otlp = "0.13"
opentelemetry_0_20_pkg = { package = "opentelemetry", version = "0.20", features = [
"rt-tokio",
] }
tracing-actix-web = { version = "0.7.6", features = ["opentelemetry_0_20"] }
opentelemetry-otlp = "0.14"
opentelemetry_0_21_pkg = { package = "opentelemetry", version = "0.21" }
opentelemetry_sdk = { version = "0.21", features = ["rt-tokio"] }
tracing-actix-web = { version = "0.7.8", features = ["opentelemetry_0_21"] }
tracing-subscriber = { version = "0.3", features = [
"ansi",
"env-filter",

View file

@ -5,13 +5,11 @@ use tracing::instrument::Instrument;
use tracing_awc::{root_span, Tracing};
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
use opentelemetry_0_20_pkg as opentelemetry;
use tracing_opentelemetry_0_20_pkg as tracing_opentelemetry;
use opentelemetry_0_21_pkg as opentelemetry;
use tracing_opentelemetry_0_22_pkg as tracing_opentelemetry;
use opentelemetry::{
sdk::{propagation::TraceContextPropagator, Resource},
KeyValue,
};
use opentelemetry::KeyValue;
use opentelemetry_sdk::{propagation::TraceContextPropagator, Resource};
async fn request(url: &str) -> Result<(), Box<dyn Error>> {
Client::builder()
@ -47,7 +45,7 @@ fn init_opentelemetry(url: &str) -> Result<(), Box<dyn Error>> {
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_trace_config(
opentelemetry::sdk::trace::config().with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_sdk::trace::config().with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"client-demo",
)])),
@ -57,7 +55,7 @@ fn init_opentelemetry(url: &str) -> Result<(), Box<dyn Error>> {
.tonic()
.with_endpoint(url),
)
.install_batch(opentelemetry::runtime::Tokio)?;
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);

View file

@ -7,13 +7,11 @@ use std::error::Error;
use tracing_actix_web::TracingLogger;
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
use opentelemetry_0_20_pkg as opentelemetry;
use tracing_opentelemetry_0_20_pkg as tracing_opentelemetry;
use opentelemetry_0_21_pkg as opentelemetry;
use tracing_opentelemetry_0_22_pkg as tracing_opentelemetry;
use opentelemetry::{
sdk::{propagation::TraceContextPropagator, Resource},
KeyValue,
};
use opentelemetry::KeyValue;
use opentelemetry_sdk::{propagation::TraceContextPropagator, Resource};
#[tracing::instrument(name = "Index")]
async fn index() -> impl Responder {
@ -51,7 +49,7 @@ fn init_opentelemetry(url: &str) -> Result<(), Box<dyn Error>> {
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_trace_config(
opentelemetry::sdk::trace::config().with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_sdk::trace::config().with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"server-demo",
)])),
@ -61,7 +59,7 @@ fn init_opentelemetry(url: &str) -> Result<(), Box<dyn Error>> {
.tonic()
.with_endpoint(url),
)
.install_batch(opentelemetry::runtime::Tokio)?;
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);

View file

@ -26,6 +26,8 @@ use opentelemetry_0_18_pkg as opentelemetry;
use opentelemetry_0_19_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_20")]
use opentelemetry_0_20_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_21")]
use opentelemetry_0_21_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_13")]
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
@ -42,7 +44,9 @@ use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_19")]
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_20")]
use tracing_opentelemetry_0_20_pkg as tracing_opentelemetry;
use tracing_opentelemetry_0_21_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_21")]
use tracing_opentelemetry_0_22_pkg as tracing_opentelemetry;
#[cfg(any(
feature = "opentelemetry_0_13",
@ -52,7 +56,8 @@ use tracing_opentelemetry_0_20_pkg as tracing_opentelemetry;
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19",
feature = "opentelemetry_0_20"
feature = "opentelemetry_0_20",
feature = "opentelemetry_0_21",
))]
pub fn root_span() -> Span {
let span = tracing::info_span!("Root span", trace_id = tracing::field::Empty,);
@ -63,7 +68,8 @@ pub fn root_span() -> Span {
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19",
feature = "opentelemetry_0_20"
feature = "opentelemetry_0_20",
feature = "opentelemetry_0_21",
)))]
let trace_id = span.context().span().span_context().trace_id().to_hex();
@ -71,7 +77,8 @@ pub fn root_span() -> Span {
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19",
feature = "opentelemetry_0_20"
feature = "opentelemetry_0_20",
feature = "opentelemetry_0_21",
))]
let trace_id = {
let id = span.context().span().span_context().trace_id();
@ -277,9 +284,9 @@ where
.span
.get_or_insert_with(|| tracing::info_span!("HTTP Client Response Body"));
let dummy_span = this.dummy_span.get_or_insert_with(|| {
tracing::trace_span!(parent: None, "HTTP Client Response Body Inner")
});
let dummy_span = this.dummy_span.get_or_insert_with(
|| tracing::trace_span!(parent: None, "HTTP Client Response Body Inner"),
);
let body = this.body;
@ -310,7 +317,8 @@ struct RequestHeaderCarrier<'a> {
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19",
feature = "opentelemetry_0_20"
feature = "opentelemetry_0_20",
feature = "opentelemetry_0_21",
))]
impl<'a> opentelemetry::propagation::Injector for RequestHeaderCarrier<'a> {
fn set(&mut self, key: &str, value: String) {
@ -346,7 +354,8 @@ fn record_otel(_headers: &mut HeaderMap, _span: &Span) {
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19",
feature = "opentelemetry_0_20"
feature = "opentelemetry_0_20",
feature = "opentelemetry_0_21",
))]
{
let span = _span;