TelemetryClient class
Used to write telemetry data to Azure's Application Insights service.
A TelemetryClient provides methods to construct the various telemetry items that are supported by Application Insights. These items are then forwarded onto whatever Processor is used to construct the TelemetryClient. Typically, this will be a chain of processors to buffer and transmit telemetry items, per the following example:
final telemetryClient = TelemetryClient(
processor: BufferedProcessor(
next: TransmissionProcessor(
instrumentationKey: instrumentationKey,
httpClient: Client(),
timeout: const Duration(seconds: 10),
),
);
You can then use the trackError, trackEvent, trackPageView, trackRequest, and trackTrace methods to capture telemetry, though you will typically want to use TelemetryHttpClient rather than calling trackRequest yourself.
See also:
Constructors
- TelemetryClient({required Processor processor, TelemetryContext? context})
- Creates a telemetry client.
Properties
- context → TelemetryContext
-
Contains context to be attached to every telemetry item created by this TelemetryClient.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- processor → Processor
-
A Processor that receives all telemetry items created by this TelemetryClient.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
flush(
) → Future< void> - Flushes this TelemetryClient's processor.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
trackError(
{required Severity severity, required Object error, StackTrace? stackTrace, String? problemId, Map< String, Object> additionalProperties = const <String, Object>{}, DateTime? timestamp}) → void - Creates an ExceptionTelemetryItem item and forwards it onto the processor.
-
trackEvent(
{required String name, Map< String, Object> additionalProperties = const <String, Object>{}, DateTime? timestamp}) → void - Creates an EventTelemetryItem item and forwards it onto the processor.
-
trackPageView(
{required String name, String? id, Duration? duration, String? url, Map< String, Object> additionalProperties = const <String, Object>{}, DateTime? timestamp}) → void - Creates a PageViewTelemetryItem item and forwards it onto the processor.
-
trackRequest(
{required String id, required Duration duration, required String responseCode, String? source, String? name, bool? success, String? url, Map< String, Object> additionalProperties = const <String, Object>{}, DateTime? timestamp}) → void - Creates a RequestTelemetryItem item and forwards it onto the processor.
-
trackTrace(
{required Severity severity, required String message, Map< String, Object> additionalProperties = const <String, Object>{}, DateTime? timestamp}) → void - Creates a TraceTelemetryItem item and forwards it onto the processor.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited