Skip to main content

Log

Struct Log 

Source
pub struct Log { /* private fields */ }
Expand description

A simplified log representation that keeps track of where each field was found.

A log on the wire is a JSON object with a handful of envelope fields (message, status, hostname, service, ddsource, timestamp, and ddtags), optionally other top-level keys, and a message that may itself be a JSON object serialized as a string. The Agent puts all log properties inside that string, while other producers may put them at the top level. Keeping the two locations apart means that a property that moved from one to the other shows up as a difference, rather than being normalized away.

Implementations§

Source§

impl Log

Source

pub fn try_from_payload(payload: &[u8]) -> Result<Vec<Self>, GenericError>

Parses a decompressed logs intake payload, which is a JSON array of log objects.

§Errors

If the payload isn’t valid JSON, isn’t an array of objects, or has a ddtags field that isn’t a string, an error is returned.

Source

pub fn message(&self) -> Option<&Value>

Returns the raw envelope message field.

Source

pub fn status(&self) -> Option<&Value>

Returns the raw envelope status field.

Source

pub fn hostname(&self) -> Option<&Value>

Returns the raw envelope hostname field.

Source

pub fn service(&self) -> Option<&Value>

Returns the raw envelope service field.

Source

pub fn ddsource(&self) -> Option<&Value>

Returns the raw envelope ddsource field.

Source

pub fn timestamp(&self) -> Option<&Value>

Returns the raw envelope timestamp field.

Source

pub fn ddtags(&self) -> &BTreeSet<String>

Returns the envelope ddtags field as a set.

Like the logs intake, the raw string is split on ,, each element is trimmed, and empty elements and duplicates are dropped.

Source

pub fn envelope_properties(&self) -> &BTreeMap<String, Value>

Returns top-level keys other than the envelope fields.

Source

pub fn content_properties(&self) -> Option<&BTreeMap<String, Value>>

Returns the properties parsed from the envelope message, if it’s a string holding a JSON object.

Source

pub fn envelope_field(&self, name: &str) -> Option<&Value>

Returns the envelope field with the given name, if it’s one of the fields held as a raw value.

ddtags isn’t held as a raw value, so it isn’t returned here; use Log::ddtags instead.

Source

pub fn display_message(&self) -> Option<&Value>

Returns the displayed message: the content’s message when the content is a JSON object, or else the envelope message.

Source

pub fn semantic_view(&self) -> BTreeMap<String, Value>

Returns a location-independent view of the log, used to identify the same log on both sides of a comparison.

Envelope fields and other top-level keys come first, then content properties overwrite them. When the content is a JSON object, the raw envelope message is left out, since its properties are already present. ddtags is included as a sorted array.

Trait Implementations§

Source§

impl Clone for Log

Source§

fn clone(&self) -> Log

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Log

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Log

Source§

fn default() -> Log

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Log

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Log

Source§

fn eq(&self, other: &Log) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Log

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Log

Source§

impl StructuralPartialEq for Log

Auto Trait Implementations§

§

impl Freeze for Log

§

impl RefUnwindSafe for Log

§

impl Send for Log

§

impl Sync for Log

§

impl Unpin for Log

§

impl UnsafeUnpin for Log

§

impl UnwindSafe for Log

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> Track for T

§

fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>

Instruments this type by attaching the given resource group token, returning a Tracked wrapper. Read more
§

fn in_current_resource_group(self) -> Tracked<Self>

Instruments this type by attaching the current resource group, returning a Tracked wrapper. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,