pub struct Span {
pub env: MetaString,
pub version: MetaString,
pub component: MetaString,
pub kind: u32,
pub attributes: FastHashMap<MetaString, AttributeValue>,
/* private fields */
}Expand description
A span event.
Fields§
§env: MetaStringPer-span environment override. Overrides Trace.payload.env when non-empty.
version: MetaStringPer-span application version.
component: MetaStringInstrumentation component name.
kind: u32Span kind (OTel values): 0=unspecified, 1=internal, 2=server, 3=client, 4=producer, 5=consumer.
attributes: FastHashMap<MetaString, AttributeValue>Typed span-level attributes.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(
service: impl Into<MetaString>,
name: impl Into<MetaString>,
resource: impl Into<MetaString>,
span_type: impl Into<MetaString>,
span_id: u64,
parent_id: u64,
start: u64,
duration: u64,
error: i32,
) -> Self
pub fn new( service: impl Into<MetaString>, name: impl Into<MetaString>, resource: impl Into<MetaString>, span_type: impl Into<MetaString>, span_id: u64, parent_id: u64, start: u64, duration: u64, error: i32, ) -> Self
Creates a new Span with all required fields.
Sourcepub fn with_service(self, service: impl Into<MetaString>) -> Self
pub fn with_service(self, service: impl Into<MetaString>) -> Self
Sets the service name.
Sourcepub fn with_resource(self, resource: impl Into<MetaString>) -> Self
pub fn with_resource(self, resource: impl Into<MetaString>) -> Self
Sets the resource name.
Sourcepub fn with_span_id(self, span_id: u64) -> Self
pub fn with_span_id(self, span_id: u64) -> Self
Sets the span identifier.
Sourcepub fn with_parent_id(self, parent_id: u64) -> Self
pub fn with_parent_id(self, parent_id: u64) -> Self
Sets the parent span identifier.
Sourcepub fn with_start(self, start: u64) -> Self
pub fn with_start(self, start: u64) -> Self
Sets the start timestamp.
Sourcepub fn with_duration(self, duration: u64) -> Self
pub fn with_duration(self, duration: u64) -> Self
Sets the span duration.
Sourcepub fn with_error(self, error: i32) -> Self
pub fn with_error(self, error: i32) -> Self
Sets the error flag.
Sourcepub fn with_span_type(self, span_type: impl Into<MetaString>) -> Self
pub fn with_span_type(self, span_type: impl Into<MetaString>) -> Self
Sets the span type (for example, web, db, lambda).
Sourcepub fn with_attributes(
self,
attributes: impl Into<Option<FastHashMap<MetaString, AttributeValue>>>,
) -> Self
pub fn with_attributes( self, attributes: impl Into<Option<FastHashMap<MetaString, AttributeValue>>>, ) -> Self
Replaces the span attributes map.
Sourcepub fn with_span_links(
self,
span_links: impl Into<Option<Vec<SpanLink>>>,
) -> Self
pub fn with_span_links( self, span_links: impl Into<Option<Vec<SpanLink>>>, ) -> Self
Replaces the span links collection.
Sourcepub fn with_span_events(
self,
span_events: impl Into<Option<Vec<SpanEvent>>>,
) -> Self
pub fn with_span_events( self, span_events: impl Into<Option<Vec<SpanEvent>>>, ) -> Self
Replaces the span events collection.
Sourcepub fn with_env(self, env: impl Into<MetaString>) -> Self
pub fn with_env(self, env: impl Into<MetaString>) -> Self
Sets the per-span environment override.
Sourcepub fn with_version(self, version: impl Into<MetaString>) -> Self
pub fn with_version(self, version: impl Into<MetaString>) -> Self
Sets the per-span application version.
Sourcepub fn with_component(self, component: impl Into<MetaString>) -> Self
pub fn with_component(self, component: impl Into<MetaString>) -> Self
Sets the instrumentation component.
Sourcepub fn set_resource(&mut self, resource: impl Into<MetaString>)
pub fn set_resource(&mut self, resource: impl Into<MetaString>)
Sets the resource name.
Sourcepub fn span_links(&self) -> &[SpanLink]
pub fn span_links(&self) -> &[SpanLink]
Returns the span links collection.
Sourcepub fn span_links_mut(&mut self) -> &mut Vec<SpanLink>
pub fn span_links_mut(&mut self) -> &mut Vec<SpanLink>
Returns a mutable reference to the span links collection.
Sourcepub fn span_events(&self) -> &[SpanEvent]
pub fn span_events(&self) -> &[SpanEvent]
Returns the span events collection.
Sourcepub fn span_events_mut(&mut self) -> &mut Vec<SpanEvent>
pub fn span_events_mut(&mut self) -> &mut Vec<SpanEvent>
Returns a mutable reference to the span events collection.
Trait Implementations§
Source§impl Attributes for Span
impl Attributes for Span
type Text = MetaString
type Bytes = Vec<u8>
type Values = SalukiValues
Source§fn attribute_str(&self, key: &str) -> Option<&str>
fn attribute_str(&self, key: &str) -> Option<&str>
None if it is missing or not a
string.Source§fn attribute_f64(&self, key: &str) -> Option<f64>
fn attribute_f64(&self, key: &str) -> Option<f64>
None if it is missing or not a
number. Integers are converted to f64.Source§impl AttributesIter for Span
impl AttributesIter for Span
Source§fn attributes(
&self,
) -> impl Iterator<Item = (&str, AttributeRef<'_, SalukiValues>)>
fn attributes( &self, ) -> impl Iterator<Item = (&str, AttributeRef<'_, SalukiValues>)>
(key, value) attribute pairs, each key at most onceSource§impl AttributesMut for Span
impl AttributesMut for Span
Source§fn retain_attributes(
&mut self,
f: impl FnMut(&str, &mut AttributeValue) -> bool,
)
fn retain_attributes( &mut self, f: impl FnMut(&str, &mut AttributeValue) -> bool, )
f returns true; f may mutate the values it keeps.
Like [AttributesIter::attributes], f sees each key once.Source§fn attribute_mut(&mut self, key: &str) -> Option<&mut AttributeValue>
fn attribute_mut(&mut self, key: &str) -> Option<&mut AttributeValue>
None if it is missingSource§fn set_attribute(&mut self, key: MetaString, value: AttributeValue)
fn set_attribute(&mut self, key: MetaString, value: AttributeValue)
key, replacing any existing value for that keySource§fn remove_attribute(&mut self, key: &str) -> Option<AttributeValue>
fn remove_attribute(&mut self, key: &str) -> Option<AttributeValue>
key, returning its value if it was presentSource§impl Span for Span
impl Span for Span
type SpanEvent = SpanEvent
type SpanLink = SpanLink
fn service(&self) -> &str
fn resource(&self) -> &str
Source§fn span_events(&self) -> impl Iterator<Item = &SpanEvent>
fn span_events(&self) -> impl Iterator<Item = &SpanEvent>
Source§fn span_links(&self) -> impl Iterator<Item = &SpanLink>
fn span_links(&self) -> impl Iterator<Item = &SpanLink>
§fn compat(&self) -> &CompatSpan<Self>where
Self: Sized,
fn compat(&self) -> &CompatSpan<Self>where
Self: Sized,
meta/metrics would hold them, promoted tags
included. See [CompatSpan].§fn is_trace_root(&self) -> bool
fn is_trace_root(&self) -> bool
§fn has_top_level(&self) -> bool
fn has_top_level(&self) -> bool
§fn is_measured(&self) -> bool
fn is_measured(&self) -> bool
§fn is_partial_snapshot(&self) -> bool
fn is_partial_snapshot(&self) -> bool
Source§impl SpanMut for Span
impl SpanMut for Span
fn set_service(&mut self, value: MetaString)
fn set_resource(&mut self, value: MetaString)
Source§fn set_parent_id(&mut self, value: u64)
fn set_parent_id(&mut self, value: u64)
Source§fn set_start(&mut self, value: i64)
fn set_start(&mut self, value: i64)
Source§fn set_duration(&mut self, value: i64)
fn set_duration(&mut self, value: i64)
fn set_error(&mut self, value: bool)
Source§fn set_span_kind(&mut self, value: &str)
fn set_span_kind(&mut self, value: &str)
fn set_env(&mut self, value: MetaString)
fn set_version(&mut self, value: MetaString)
fn set_component(&mut self, value: MetaString)
Source§fn span_events_mut(&mut self) -> impl Iterator<Item = &mut SpanEvent>
fn span_events_mut(&mut self) -> impl Iterator<Item = &mut SpanEvent>
Source§fn span_links_mut(&mut self) -> impl Iterator<Item = &mut SpanLink>
fn span_links_mut(&mut self) -> impl Iterator<Item = &mut SpanLink>
§fn compat_mut(&mut self) -> &mut CompatSpan<Self>where
Self: Sized,
fn compat_mut(&mut self) -> &mut CompatSpan<Self>where
Self: Sized,
meta/metrics would hold its attributes, promoted
tags included. See [CompatSpan].impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more