Update to opentelemetry 0.19
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
asonix 2023-05-23 16:41:16 -05:00
parent 2147358277
commit 0a54e7aefa
8 changed files with 139 additions and 29 deletions

View file

@ -29,8 +29,9 @@ steps:
- cargo clippy --features opentelemetry_0_16 -- -D warnings
- cargo clippy --features opentelemetry_0_17 -- -D warnings
- cargo clippy --features opentelemetry_0_18 -- -D warnings
- cargo clippy --example client --features opentelemetry_0_18 -- -D warnings
- cargo clippy --example server --features opentelemetry_0_18 -- -D warnings
- cargo clippy --features opentelemetry_0_19 -- -D warnings
- cargo clippy --example client --features opentelemetry_0_19 -- -D warnings
- cargo clippy --example server --features opentelemetry_0_19 -- -D warnings
trigger:
event:
@ -97,8 +98,8 @@ steps:
pull: always
commands:
- cargo check --target=$TARGET
- cargo check --target=$TARGET --example client --features opentelemetry_0_18
- cargo check --target=$TARGET --example server --features opentelemetry_0_18
- cargo check --target=$TARGET --example client --features opentelemetry_0_19
- cargo check --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:
@ -131,8 +132,8 @@ steps:
pull: always
commands:
- cargo check --target=$TARGET
- cargo check --target=$TARGET --example client --features opentelemetry_0_18
- cargo check --target=$TARGET --example server --features opentelemetry_0_18
- cargo check --target=$TARGET --example client --features opentelemetry_0_19
- cargo check --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:
@ -165,8 +166,8 @@ steps:
pull: always
commands:
- cargo check --target=$TARGET
- cargo check --target=$TARGET --example client --features opentelemetry_0_18
- cargo check --target=$TARGET --example server --features opentelemetry_0_18
- cargo check --target=$TARGET --example client --features opentelemetry_0_19
- cargo check --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:
@ -198,8 +199,8 @@ steps:
pull: always
commands:
- cargo build --target=$TARGET
- cargo build --target=$TARGET --example client --features opentelemetry_0_18
- cargo build --target=$TARGET --example server --features opentelemetry_0_18
- cargo build --target=$TARGET --example client --features opentelemetry_0_19
- cargo build --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:
@ -231,8 +232,8 @@ steps:
pull: always
commands:
- cargo build --target=$TARGET
- cargo build --target=$TARGET --example client --features opentelemetry_0_18
- cargo build --target=$TARGET --example server --features opentelemetry_0_18
- cargo build --target=$TARGET --example client --features opentelemetry_0_19
- cargo build --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:
@ -264,8 +265,8 @@ steps:
pull: always
commands:
- cargo build --target=$TARGET
- cargo build --target=$TARGET --example client --features opentelemetry_0_18
- cargo build --target=$TARGET --example server --features opentelemetry_0_18
- cargo build --target=$TARGET --example client --features opentelemetry_0_19
- cargo build --target=$TARGET --example server --features opentelemetry_0_19
trigger:
event:

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
/target
Cargo.lock
/.envrc
/.direnv

View file

@ -1,7 +1,7 @@
[package]
name = "tracing-awc"
description = "Tracing instrumentation for the awc http client"
version = "0.1.6"
version = "0.1.7"
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_18"]
required-features = ["opentelemetry_0_19"]
[[example]]
name = "server"
required-features = ["opentelemetry_0_18"]
required-features = ["opentelemetry_0_19"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@ -44,6 +44,10 @@ opentelemetry_0_18 = [
"opentelemetry_0_18_pkg",
"tracing-opentelemetry_0_18_pkg",
]
opentelemetry_0_19 = [
"opentelemetry_0_19_pkg",
"tracing-opentelemetry_0_19_pkg",
]
[dependencies]
actix-http = { version = "3.0.2", default-features = false }
@ -57,6 +61,7 @@ opentelemetry_0_15_pkg = { package = "opentelemetry", version = "0.15", optional
opentelemetry_0_16_pkg = { package = "opentelemetry", version = "0.16", optional = true }
opentelemetry_0_17_pkg = { package = "opentelemetry", version = "0.17", optional = true }
opentelemetry_0_18_pkg = { package = "opentelemetry", version = "0.18", optional = true }
opentelemetry_0_19_pkg = { package = "opentelemetry", version = "0.19", optional = true }
pin-project-lite = "0.2.7"
tracing = "0.1"
tracing-opentelemetry_0_12_pkg = { package = "tracing-opentelemetry", version = "0.12", optional = true }
@ -65,15 +70,16 @@ tracing-opentelemetry_0_14_pkg = { package = "tracing-opentelemetry", version =
tracing-opentelemetry_0_16_pkg = { package = "tracing-opentelemetry", version = "0.16", optional = true }
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 }
[dev-dependencies]
actix-rt = "2.6"
actix-web = { version = "4.0.0", default-features = false }
opentelemetry-otlp = "0.11"
opentelemetry_0_18_pkg = { package = "opentelemetry", version = "0.18", features = [
opentelemetry-otlp = "0.12"
opentelemetry_0_19_pkg = { package = "opentelemetry", version = "0.19", features = [
"rt-tokio",
] }
tracing-actix-web = { version = "0.6.1", features = ["opentelemetry_0_18"] }
tracing-actix-web = { version = "0.7.5", features = ["opentelemetry_0_19"], git = "https://github.com/asonix/tracing-actix-web", branch = "asonix/opentelemetry-19" }
tracing-subscriber = { version = "0.3", features = [
"ansi",
"env-filter",

View file

@ -5,8 +5,8 @@ use tracing::instrument::Instrument;
use tracing_awc::{root_span, Tracing};
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
use opentelemetry_0_18_pkg as opentelemetry;
use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
use opentelemetry_0_19_pkg as opentelemetry;
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
use opentelemetry::{
sdk::{propagation::TraceContextPropagator, Resource},

View file

@ -7,8 +7,8 @@ use std::error::Error;
use tracing_actix_web::TracingLogger;
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
use opentelemetry_0_18_pkg as opentelemetry;
use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
use opentelemetry_0_19_pkg as opentelemetry;
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
use opentelemetry::{
sdk::{propagation::TraceContextPropagator, Resource},

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1684754342,
"narHash": "sha256-plGnjnbnPLoZCTdQX21oT7xliQhFtgcWlkuDHgtEb1o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7084250df3d7f9735087d3234407f3c1fc2400e3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

25
flake.nix Normal file
View file

@ -0,0 +1,25 @@
{
description = "background-jobs";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
packages.default = pkgs.hello;
devShell = with pkgs; mkShell {
nativeBuildInputs = [ cargo cargo-outdated cargo-zigbuild clippy gcc protobuf rust-analyzer rustc rustfmt ];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
});
}

View file

@ -22,6 +22,8 @@ use opentelemetry_0_16_pkg as opentelemetry;
use opentelemetry_0_17_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_18")]
use opentelemetry_0_18_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_19")]
use opentelemetry_0_19_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_13")]
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
@ -35,6 +37,8 @@ use tracing_opentelemetry_0_16_pkg as tracing_opentelemetry;
use tracing_opentelemetry_0_17_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_18")]
use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_19")]
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
#[cfg(any(
feature = "opentelemetry_0_13",
@ -42,17 +46,26 @@ use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
feature = "opentelemetry_0_15",
feature = "opentelemetry_0_16",
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18"
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19"
))]
pub fn root_span() -> Span {
let span = tracing::info_span!("Root span", trace_id = tracing::field::Empty,);
{
use opentelemetry::trace::TraceContextExt;
use tracing_opentelemetry::OpenTelemetrySpanExt;
#[cfg(not(any(feature = "opentelemetry_0_17", feature = "opentelemetry_0_18")))]
#[cfg(not(any(
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19"
)))]
let trace_id = span.context().span().span_context().trace_id().to_hex();
#[cfg(any(feature = "opentelemetry_0_17", feature = "opentelemetry_0_18"))]
#[cfg(any(
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19"
))]
let trace_id = {
let id = span.context().span().span_context().trace_id();
format!("{:032x}", id)
@ -288,7 +301,8 @@ struct RequestHeaderCarrier<'a> {
feature = "opentelemetry_0_15",
feature = "opentelemetry_0_16",
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18"
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19"
))]
impl<'a> opentelemetry::propagation::Injector for RequestHeaderCarrier<'a> {
fn set(&mut self, key: &str, value: String) {
@ -322,7 +336,8 @@ fn record_otel(_headers: &mut HeaderMap, _span: &Span) {
feature = "opentelemetry_0_15",
feature = "opentelemetry_0_16",
feature = "opentelemetry_0_17",
feature = "opentelemetry_0_18"
feature = "opentelemetry_0_18",
feature = "opentelemetry_0_19"
))]
{
let span = _span;