A recording of a event. Typically the record includes a timestamp indicating when the event happened as well as other data that describes what happened, where it happened, etc.

This interface is not intended to be implemented by users. To produce logs, use Logger#emit. To consume logs, implement LogRecordProcessor#onEmit. SdkLogRecord instances are created and managed by the SDK.

interface SdkLogRecord {
    attributes: AnyValueMap;
    body?: AnyValue;
    droppedAttributesCount: number;
    eventName?: string;
    hrTime: HrTime;
    hrTimeObserved: HrTime;
    instrumentationScope: core.InstrumentationScope;
    resource: resources.Resource;
    severityNumber?: SeverityNumber;
    severityText?: string;
    spanContext?: SpanContext;
    setAttribute(key: string, value?: AnyValue): logs.SdkLogRecord;
    setAttributes(attributes: AnyValueMap): logs.SdkLogRecord;
    setBody(body: AnyValue): logs.SdkLogRecord;
    setEventName(eventName: string): logs.SdkLogRecord;
    setSeverityNumber(severityNumber: SeverityNumber): logs.SdkLogRecord;
    setSeverityText(severityText: string): logs.SdkLogRecord;
}

Properties

attributes: AnyValueMap
body?: AnyValue
droppedAttributesCount: number
eventName?: string
hrTime: HrTime
hrTimeObserved: HrTime
instrumentationScope: core.InstrumentationScope
severityNumber?: SeverityNumber
severityText?: string
spanContext?: SpanContext

Methods

  • Sets a single attribute on the log record.

    Parameters

    • key: string

      The attribute key.

    • Optionalvalue: AnyValue

      The attribute value.

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.

  • Sets multiple attributes on the log record.

    Parameters

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.

  • Sets the body of the log record.

    Parameters

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.

  • Sets the event name for the log record.

    Parameters

    • eventName: string

      The event name.

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.

  • Sets the severity number for the log record.

    Parameters

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.

  • Sets the severity text (log level) for the log record.

    Parameters

    • severityText: string

      The severity text.

    Returns logs.SdkLogRecord

    The updated SdkLogRecord.