1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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());
}
if event.dropped_attributes_count != 0 {
fields.push(
Key::new("otel.event.dropped_attributes_count")
.i64(i64::from(event.dropped_attributes_count))
.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),
v @ Value::Array(_) => jaeger::Tag::new(key.into(), jaeger::TagType::String, Some(v.to_string()), None, None, None, None),
}
}
}