pub struct RequestTelemetry { /* private fields */ }
Expand description

Represents completion of an external request to the application and contains a summary of that request execution and results. This struct is focused on HTTP requests.

Examples

use appinsights::telemetry::{Telemetry, RequestTelemetry};
use http::{Method, Uri};
use std::time::Duration;

// create a telemetry item
let mut telemetry = RequestTelemetry::new(
    Method::GET,
    "https://api.github.com/dmolokanov/appinsights-rs".parse::<Uri>().unwrap(),
    Duration::from_millis(182),
    "200"
);

// attach custom properties, measurements and context tags
telemetry.properties_mut().insert("component".to_string(), "data_processor".to_string());
telemetry.tags_mut().insert("os_version".to_string(), "linux x86_64".to_string());
telemetry.measurements_mut().insert("body_size".to_string(), 115.0);

// submit telemetry item to server
client.track(telemetry);

Implementations

Creates a new telemetry item for HTTP request.

Returns custom measurements to submit with the telemetry item.

Returns mutable reference to custom measurements.

Returns an indication of successful or unsuccessful call.

Sets the request id. Use this to link other telemetry to this request by setting their operation parent id to this request’s id.

let operation_id = "...".to_string();
let request_id = "...".to_string();

let mut request = RequestTelemetry::new(
    Method::GET,
    "https://api.github.com/dmolokanov/appinsights-rs".parse::<Uri>().unwrap(),
    Duration::from_millis(182),
    "200",
);
request.set_id(request_id.clone());
request.tags_mut().operation_mut().set_id(operation_id.clone());
client.track(request);

let mut trace = TraceTelemetry::new(
    "Starting data processing",
    SeverityLevel::Information,
);
trace.tags_mut().operation_mut().set_id(operation_id);
trace.tags_mut().operation_mut().set_parent_id(request_id);
client.track(trace);

Trait Implementations

Formats the value using the given formatter. Read more

Returns the time when this telemetry was measured.

Returns custom properties to submit with the telemetry item.

Returns mutable reference to custom properties.

Returns context data containing extra, optional tags. Overrides values found on client telemetry context.

Returns mutable reference to custom tags.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more