Skip to content

InternalLogger

Xavier F. Gouchet edited this page Sep 4, 2024 · 1 revision

interface InternalLogger

A Logger used to log messages from the internal implementation of the Datadog SDKs.

Rule of thumb to decide which level and target we're using for the Internal Logger usage:

  • Target.USER: the message needs to either be actionable or provide information about the main steps in data processing (tracking, storage, upload).
    • Level.ERROR: for any actionable error originated from a user's configuration, preventing a feature from working, or for an issue resulting in unexpected data loss;
    • Level.WARN: to inform of an actionable misconfiguration or missuses of the SDK, resulting in delayed or incomplete data;
    • Level.INFO: information about important expected event (e.g.: successful upload);
  • Target.TELEMETRY: any event that need to be tracked for usage monitoring or for error diagnostic.
    • Level.ERROR, Level.WARN: for any critical error that is unexpected enough and actionable;
    • Level.INFO, Level.DEBUG, Level.VERBOSE: important information about critical parts of the SDK we want to monitor;
  • Target.MAINTAINER: can be anything relevant about the moving parts of the core SDK or any of the feature. Level is left to the discretion of the authors of a log.
    • Level.ERROR: for any caught error or situation preventing the SDK from working as expected;
    • Level.WARN: for any unexpected situation (e.g.: when one would use an IllegalStateException);
    • Level.INFO: information about internal high level steps of the SDK core or features;
    • Level.DEBUG: information about internal low level steps of the SDK core or features;
    • Level.VERBOSE: information on currently debugged feature or open ticket;

Types

InternalLogger.Companion

InternalLogger.Level

InternalLogger.Target

Functions

log

abstract fun log(level: InternalLogger.Level, target: InternalLogger.Target, messageBuilder: () -> String, throwable: Throwable? = null, onlyOnce: Boolean = false, additionalProperties: Map<String, Any?>? = null)

Logs a message from the internal implementation.

Parameters
level the severity level of the log
target the target handler for the log
messageBuilder the lambda building the log message
throwable an optional throwable error
onlyOnce whether only one instance of the message should be sent per lifetime of the logger (default is false)
additionalProperties additional properties to add to the log

abstract fun log(level: InternalLogger.Level, targets: List<InternalLogger.Target>, messageBuilder: () -> String, throwable: Throwable? = null, onlyOnce: Boolean = false, additionalProperties: Map<String, Any?>? = null)

Logs a message from the internal implementation.

Parameters
level the severity level of the log
targets list of the target handlers for the log
messageBuilder the lambda building the log message
throwable an optional throwable error
onlyOnce whether only one instance of the message should be sent per lifetime of the logger (default is false, onlyOnce applies to each target independently)
additionalProperties additional properties to add to the log

logMetric

abstract fun logMetric(messageBuilder: () -> String, additionalProperties: Map<String, Any?>, samplingRate: Float)

Logs a specific metric from the internal implementation. The metric values will be sent as key-value pairs in the additionalProperties and as part of the com.datadog.android.telemetry.model.TelemetryDebugEvent.Telemetry event.

Parameters
messageBuilder the lambda building the metric message
additionalProperties additional properties to add to the metric
samplingRate value between 0-100 for sampling the event. Note that the sampling rate applied to this metric will be applied in addition to the global telemetry sampling rate.

startPerformanceMeasure

abstract fun startPerformanceMeasure(callerClass: String, metric: TelemetryMetricType, samplingRate: Float, operationName: String): PerformanceMetric?

Start measuring a performance metric.

Return

a PerformanceMetric object that can later be used to send telemetry, or null if sampled out

Parameters
callerClass name of the class calling the performance measurement.
metric name of the metric that we want to measure.
samplingRate value between 0-100 for sampling the event.
operationName the name of the operation being measured
Clone this wiki locally