TelemetryLogger Class
Packages > @fluidframework/telemetry-utils > TelemetryLogger
TelemetryLogger class contains various helper telemetry methods, encoding in one place schemas for various types of Fluid telemetry events. Creates sub-logger that appends properties to all events
Signature:
export declare abstract class TelemetryLogger implements ITelemetryLogger
Implements: ITelemetryLogger
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(namespace, properties, propertyGetters) | Constructs a new instance of the TelemetryLogger class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
eventNamespaceSeparator | static |
(not declared) |
Methods
Method | Modifiers | Description |
---|---|---|
debugAssert(condition, event) | Log an debug assert with the logger | |
formatTick(tick) | static |
|
getStack() | static |
|
logException(event, exception) | Helper method to log exceptions | |
logGenericError(eventName, error) | Log generic error with the logger | |
numberFromString(str) | static |
Attempts to parse number from string. If fails,returns original string. Used to make telemetry data typed (and support math operations, like comparison), in places where we do expect numbers (like contentsize/duration property in http header) |
prepareErrorObject(event, error, fetchStack) | static |
|
prepareEvent(event) | ||
sanitizePkgName(name) | static |
|
send(event) | Send an event with the logger | |
sendErrorEvent(event, error) | Send an error telemetry event with the logger | |
sendPerformanceEvent(event, error) | Send a performance telemetry event with the logger | |
sendTelemetryEvent(event, error) | Send a telemetry event with the logger | |
shipAssert(condition, event) | Log an ship assert with the logger |
Constructors
TelemetryLogger.(constructor)
Constructs a new instance of the TelemetryLogger
class
Signature:
protected constructor(namespace?: string | undefined, properties?: ITelemetryProperties | undefined, propertyGetters?: ITelemetryPropertyGetters | undefined);
Parameters
Parameter | Type | Description |
---|---|---|
namespace | string | undefined | |
properties | ITelemetryProperties | undefined | |
propertyGetters | ITelemetryPropertyGetters | undefined |
Properties
eventNamespaceSeparator
Signature:
static readonly eventNamespaceSeparator = ":";
Methods
debugAssert
Log an debug assert with the logger
Signature:
debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
Parameters
Parameter | Type | Description |
---|---|---|
condition | boolean | the condition to assert on |
event | ITelemetryErrorEvent | the event to log if the condition fails |
Returns:
void
formatTick
Signature:
static formatTick(tick: number): number;
Parameters
Parameter | Type | Description |
---|---|---|
tick | number |
Returns:
number
getStack
Signature:
protected static getStack(): string | undefined;
Returns:
string | undefined
logException
Helper method to log exceptions
Signature:
logException(event: ITelemetryErrorEvent, exception: any): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryErrorEvent | the event to send |
exception | any | Exception object to add to an event |
Returns:
void
logGenericError
Log generic error with the logger
Signature:
logGenericError(eventName: string, error: any): void;
Parameters
Parameter | Type | Description |
---|---|---|
eventName | string | the name of the event |
error | any | the error object to include in the event, require to be JSON-able |
Returns:
void
numberFromString
Attempts to parse number from string. If fails,returns original string. Used to make telemetry data typed (and support math operations, like comparison), in places where we do expect numbers (like contentsize/duration property in http header)
Signature:
static numberFromString(str: string | null | undefined): string | number | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
str | string | null | undefined |
Returns:
string | number | undefined
prepareErrorObject
Signature:
static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryBaseEvent | |
error | any | |
fetchStack | boolean |
Returns:
void
prepareEvent
Signature:
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryBaseEvent |
Returns:
sanitizePkgName
Signature:
static sanitizePkgName(name: string): string;
Parameters
Parameter | Type | Description |
---|---|---|
name | string |
Returns:
string
send
Send an event with the logger
Signature:
abstract send(event: ITelemetryBaseEvent): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryBaseEvent | the event to send |
Returns:
void
sendErrorEvent
Send an error telemetry event with the logger
Signature:
sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryErrorEvent | the event to send |
error | any | optional error object to log |
Returns:
void
sendPerformanceEvent
Send a performance telemetry event with the logger
Signature:
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryPerformanceEvent | Event to send |
error | any | optional error object to log |
Returns:
void
sendTelemetryEvent
Send a telemetry event with the logger
Signature:
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void;
Parameters
Parameter | Type | Description |
---|---|---|
event | ITelemetryGenericEvent | the event to send |
error | any | optional error object to log |
Returns:
void
shipAssert
Log an ship assert with the logger
Signature:
shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
Parameters
Parameter | Type | Description |
---|---|---|
condition | boolean | the condition to assert on |
event | ITelemetryErrorEvent | the event to log if the condition fails |
Returns:
void