forked from open-telemetry/opentelemetry-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clippy warnings and deny them in CI (open-telemetry#453)
- Loading branch information
Showing
6 changed files
with
85 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,20 +23,21 @@ jobs: | |
- name: Test | ||
run: ./scripts/test.sh | ||
lint: | ||
strategy: | ||
matrix: | ||
rust: [stable, beta] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
submodules: true | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
toolchain: stable | ||
components: rustfmt | ||
profile: minimal | ||
- uses: arduino/setup-protoc@v1 | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
- name: Lint | ||
run: ./scripts/lint.sh | ||
msrv: | ||
|
@@ -55,7 +56,7 @@ jobs: | |
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio-support,serde,testing && | ||
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml && | ||
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml | ||
meta: | ||
coverage: | ||
continue-on-error: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -65,7 +66,6 @@ jobs: | |
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
components: rustfmt, clippy | ||
override: true | ||
- uses: arduino/setup-protoc@v1 | ||
- uses: actions-rs/cargo@v1 | ||
|
@@ -78,8 +78,3 @@ jobs: | |
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | ||
- uses: actions-rs/[email protected] | ||
- uses: codecov/codecov-action@v1 | ||
- run: cargo fmt -- --check | ||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --all-features --workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,62 @@ | ||
//! Thrift generated Jaeger client | ||
//! | ||
//! Definitions: https://github.com/uber/jaeger-idl/blob/master/thrift/ | ||
use std::time::{Duration, SystemTime}; | ||
|
||
use opentelemetry::trace::Event; | ||
use opentelemetry::{Key, KeyValue, Value}; | ||
|
||
pub(crate) mod agent; | ||
pub(crate) mod jaeger; | ||
pub(crate) mod zipkincore; | ||
|
||
impl From<super::Process> for jaeger::Process { | ||
fn from(process: super::Process) -> jaeger::Process { | ||
jaeger::Process::new( | ||
process.service_name, | ||
Some(process.tags.into_iter().map(Into::into).collect()), | ||
) | ||
} | ||
} | ||
|
||
impl From<Event> for jaeger::Log { | ||
fn from(event: crate::exporter::Event) -> jaeger::Log { | ||
let timestamp = event | ||
.timestamp | ||
.duration_since(SystemTime::UNIX_EPOCH) | ||
.unwrap_or_else(|_| Duration::from_secs(0)) | ||
.as_micros() as i64; | ||
let mut event_set_via_attribute = false; | ||
let mut fields = event | ||
.attributes | ||
.into_iter() | ||
.map(|attr| { | ||
if attr.key.as_str() == "event" { | ||
event_set_via_attribute = true; | ||
}; | ||
attr.into() | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
if !event_set_via_attribute { | ||
fields.push(Key::new("event").string(event.name).into()); | ||
} | ||
|
||
jaeger::Log::new(timestamp, fields) | ||
} | ||
} | ||
|
||
#[rustfmt::skip] | ||
impl From<KeyValue> for jaeger::Tag { | ||
fn from(kv: KeyValue) -> jaeger::Tag { | ||
let KeyValue { key, value } = kv; | ||
match value { | ||
Value::String(s) => jaeger::Tag::new(key.into(), jaeger::TagType::String, Some(s.into()), None, None, None, None), | ||
Value::F64(f) => jaeger::Tag::new(key.into(), jaeger::TagType::Double, None, Some(f.into()), None, None, None), | ||
Value::Bool(b) => jaeger::Tag::new(key.into(), jaeger::TagType::Bool, None, None, Some(b), None, None), | ||
Value::I64(i) => jaeger::Tag::new(key.into(), jaeger::TagType::Long, None, None, None, Some(i), None), | ||
// TODO: better Array handling, jaeger thrift doesn't support arrays | ||
v @ Value::Array(_) => jaeger::Tag::new(key.into(), jaeger::TagType::String, Some(v.to_string()), None, None, None, None), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters