-
Notifications
You must be signed in to change notification settings - Fork 384
/
link.rs
38 lines (33 loc) · 1.06 KB
/
link.rs
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
//! # OpenTelemetry Trace Link Interface
use crate::{trace::SpanContext, KeyValue};
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
/// During the `Span` creation user MUST have the ability to record links to other `Span`s. Linked
/// `Span`s can be from the same or a different trace.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct Link {
span_context: SpanContext,
attributes: Vec<KeyValue>,
}
impl Link {
/// Create a new link
pub fn new(span_context: SpanContext, attributes: Vec<KeyValue>) -> Self {
Link {
span_context,
attributes,
}
}
/// The span context of the linked span
pub fn span_context(&self) -> &SpanContext {
&self.span_context
}
/// Attributes of the span link
pub fn attributes(&self) -> &Vec<KeyValue> {
&self.attributes
}
/// Mutable attributes of the link
pub(crate) fn attributes_mut(&mut self) -> &mut Vec<KeyValue> {
self.attributes.as_mut()
}
}