OpenTelemetry PHP

LogRecord extends Message
in package

A log record according to OpenTelemetry Log Data Model: https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md

Generated from protobuf message opentelemetry.proto.logs.v1.LogRecord

Table of Contents

Properties

$body  : mixed
A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].
$dropped_attributes_count  : mixed
Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>
$flags  : mixed
Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
$observed_time_unix_nano  : mixed
Time when the event was observed by the collection system.
$severity_number  : mixed
Numerical value of the severity, normalized to values described in Log Data Model.
$severity_text  : mixed
The severity text (also known as log level). The original string representation as it is known at the source. [Optional].
$span_id  : mixed
A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).
$time_unix_nano  : mixed
time_unix_nano is the time when the event occurred.
$trace_id  : mixed
A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).
$attributes  : mixed
Additional attributes that describe the specific event occurrence. [Optional].

Methods

__construct()  : mixed
Constructor.
clearBody()  : mixed
getAttributes()  : RepeatedField
Additional attributes that describe the specific event occurrence. [Optional].
getBody()  : AnyValue|null
A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].
getDroppedAttributesCount()  : int
Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>
getFlags()  : int
Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
getObservedTimeUnixNano()  : int|string
Time when the event was observed by the collection system.
getSeverityNumber()  : int
Numerical value of the severity, normalized to values described in Log Data Model.
getSeverityText()  : string
The severity text (also known as log level). The original string representation as it is known at the source. [Optional].
getSpanId()  : string
A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).
getTimeUnixNano()  : int|string
time_unix_nano is the time when the event occurred.
getTraceId()  : string
A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).
hasBody()  : mixed
setAttributes()  : $this
Additional attributes that describe the specific event occurrence. [Optional].
setBody()  : $this
A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].
setDroppedAttributesCount()  : $this
Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>
setFlags()  : $this
Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
setObservedTimeUnixNano()  : $this
Time when the event was observed by the collection system.
setSeverityNumber()  : $this
Numerical value of the severity, normalized to values described in Log Data Model.
setSeverityText()  : $this
The severity text (also known as log level). The original string representation as it is known at the source. [Optional].
setSpanId()  : $this
A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).
setTimeUnixNano()  : $this
time_unix_nano is the time when the event occurred.
setTraceId()  : $this
A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

Properties

$body

A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].

protected mixed $body = null

Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue body = 5;

$dropped_attributes_count

Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>

protected mixed $dropped_attributes_count = 0

$flags

Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].

protected mixed $flags = 0

Generated from protobuf field fixed32 flags = 8;

$observed_time_unix_nano

Time when the event was observed by the collection system.

protected mixed $observed_time_unix_nano = 0

For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) this timestamp is typically set at the generation time and is equal to Timestamp. For events originating externally and collected by OpenTelemetry (e.g. using Collector) this is the time when OpenTelemetry's code observed the event measured by the clock of the OpenTelemetry code. This field MUST be set once the event is observed by OpenTelemetry. For converting OpenTelemetry log data to formats that support only one timestamp or when receiving OpenTelemetry log data by recipients that support only one timestamp internally the following logic is recommended:

  • Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 observed_time_unix_nano = 11;

$severity_number

Numerical value of the severity, normalized to values described in Log Data Model.

protected mixed $severity_number = 0

[Optional].

Generated from protobuf field .opentelemetry.proto.logs.v1.SeverityNumber severity_number = 2;

$severity_text

The severity text (also known as log level). The original string representation as it is known at the source. [Optional].

protected mixed $severity_text = ''

Generated from protobuf field string severity_text = 3;

$span_id

A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

protected mixed $span_id = ''

This field is optional. If the sender specifies a valid span_id then it SHOULD also specify a valid trace_id. The receivers SHOULD assume that the log record is not associated with a span if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes span_id = 10;

$time_unix_nano

time_unix_nano is the time when the event occurred.

protected mixed $time_unix_nano = 0

Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 time_unix_nano = 1;

$trace_id

A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

protected mixed $trace_id = ''

This field is optional. The receivers SHOULD assume that the log record is not associated with a trace if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes trace_id = 9;

$attributes

Additional attributes that describe the specific event occurrence. [Optional].

private mixed $attributes

Attribute keys MUST be unique (it is not allowed to have more than one attribute with the same key).

Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6;

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $data = NULL ]) : mixed
Parameters
$data : array<string|int, mixed> = NULL

{ Optional. Data for populating the Message object.

@type int|string $time_unix_nano
      time_unix_nano is the time when the event occurred.
      Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
      Value of 0 indicates unknown or missing timestamp.
@type int|string $observed_time_unix_nano
      Time when the event was observed by the collection system.
      For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK)
      this timestamp is typically set at the generation time and is equal to Timestamp.
      For events originating externally and collected by OpenTelemetry (e.g. using
      Collector) this is the time when OpenTelemetry's code observed the event measured
      by the clock of the OpenTelemetry code. This field MUST be set once the event is
      observed by OpenTelemetry.
      For converting OpenTelemetry log data to formats that support only one timestamp or
      when receiving OpenTelemetry log data by recipients that support only one timestamp
      internally the following logic is recommended:
        - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano.
      Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
      Value of 0 indicates unknown or missing timestamp.
@type int $severity_number
      Numerical value of the severity, normalized to values described in Log Data Model.
      [Optional].
@type string $severity_text
      The severity text (also known as log level). The original string representation as
      it is known at the source. [Optional].
@type \Opentelemetry\Proto\Common\V1\AnyValue $body
      A value containing the body of the log record. Can be for example a human-readable
      string message (including multi-line) describing the event in a free form or it can
      be a structured data composed of arrays and maps of other values. [Optional].
@type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes
      Additional attributes that describe the specific event occurrence. [Optional].
      Attribute keys MUST be unique (it is not allowed to have more than one
      attribute with the same key).
@type int $dropped_attributes_count
@type int $flags
      Flags, a bit field. 8 least significant bits are the trace flags as
      defined in W3C Trace Context specification. 24 most significant bits are reserved
      and must be set to 0. Readers must not assume that 24 most significant bits
      will be zero and must correctly mask the bits when reading 8-bit trace flag (use
      flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
@type string $trace_id
      A unique identifier for a trace. All logs from the same trace share
      the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
      of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
      is zero-length and thus is also invalid).
      This field is optional.
      The receivers SHOULD assume that the log record is not associated with a
      trace if any of the following is true:
        - the field is not present,
        - the field contains an invalid value.
@type string $span_id
      A unique identifier for a span within a trace, assigned when the span
      is created. The ID is an 8-byte array. An ID with all zeroes OR of length
      other than 8 bytes is considered invalid (empty string in OTLP/JSON
      is zero-length and thus is also invalid).
      This field is optional. If the sender specifies a valid span_id then it SHOULD also
      specify a valid trace_id.
      The receivers SHOULD assume that the log record is not associated with a
      span if any of the following is true:
        - the field is not present,
        - the field contains an invalid value.

}

getAttributes()

Additional attributes that describe the specific event occurrence. [Optional].

public getAttributes() : RepeatedField

Attribute keys MUST be unique (it is not allowed to have more than one attribute with the same key).

Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6;

Return values
RepeatedField

getBody()

A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].

public getBody() : AnyValue|null

Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue body = 5;

Return values
AnyValue|null

getDroppedAttributesCount()

Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>

public getDroppedAttributesCount() : int
Return values
int

getFlags()

Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].

public getFlags() : int

Generated from protobuf field fixed32 flags = 8;

Return values
int

getObservedTimeUnixNano()

Time when the event was observed by the collection system.

public getObservedTimeUnixNano() : int|string

For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) this timestamp is typically set at the generation time and is equal to Timestamp. For events originating externally and collected by OpenTelemetry (e.g. using Collector) this is the time when OpenTelemetry's code observed the event measured by the clock of the OpenTelemetry code. This field MUST be set once the event is observed by OpenTelemetry. For converting OpenTelemetry log data to formats that support only one timestamp or when receiving OpenTelemetry log data by recipients that support only one timestamp internally the following logic is recommended:

  • Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 observed_time_unix_nano = 11;

Return values
int|string

getSeverityNumber()

Numerical value of the severity, normalized to values described in Log Data Model.

public getSeverityNumber() : int

[Optional].

Generated from protobuf field .opentelemetry.proto.logs.v1.SeverityNumber severity_number = 2;

Return values
int

getSeverityText()

The severity text (also known as log level). The original string representation as it is known at the source. [Optional].

public getSeverityText() : string

Generated from protobuf field string severity_text = 3;

Return values
string

getSpanId()

A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

public getSpanId() : string

This field is optional. If the sender specifies a valid span_id then it SHOULD also specify a valid trace_id. The receivers SHOULD assume that the log record is not associated with a span if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes span_id = 10;

Return values
string

getTimeUnixNano()

time_unix_nano is the time when the event occurred.

public getTimeUnixNano() : int|string

Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 time_unix_nano = 1;

Return values
int|string

getTraceId()

A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

public getTraceId() : string

This field is optional. The receivers SHOULD assume that the log record is not associated with a trace if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes trace_id = 9;

Return values
string

setAttributes()

Additional attributes that describe the specific event occurrence. [Optional].

public setAttributes(array<string|int, KeyValue>|RepeatedField $var) : $this

Attribute keys MUST be unique (it is not allowed to have more than one attribute with the same key).

Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6;

Parameters
$var : array<string|int, KeyValue>|RepeatedField
Return values
$this

setBody()

A value containing the body of the log record. Can be for example a human-readable string message (including multi-line) describing the event in a free form or it can be a structured data composed of arrays and maps of other values. [Optional].

public setBody(AnyValue $var) : $this

Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue body = 5;

Parameters
$var : AnyValue
Return values
$this

setDroppedAttributesCount()

Generated from protobuf field <code>uint32 dropped_attributes_count = 7;</code>

public setDroppedAttributesCount(int $var) : $this
Parameters
$var : int
Return values
$this

setFlags()

Flags, a bit field. 8 least significant bits are the trace flags as defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. Readers must not assume that 24 most significant bits will be zero and must correctly mask the bits when reading 8-bit trace flag (use flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].

public setFlags(int $var) : $this

Generated from protobuf field fixed32 flags = 8;

Parameters
$var : int
Return values
$this

setObservedTimeUnixNano()

Time when the event was observed by the collection system.

public setObservedTimeUnixNano(int|string $var) : $this

For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) this timestamp is typically set at the generation time and is equal to Timestamp. For events originating externally and collected by OpenTelemetry (e.g. using Collector) this is the time when OpenTelemetry's code observed the event measured by the clock of the OpenTelemetry code. This field MUST be set once the event is observed by OpenTelemetry. For converting OpenTelemetry log data to formats that support only one timestamp or when receiving OpenTelemetry log data by recipients that support only one timestamp internally the following logic is recommended:

  • Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 observed_time_unix_nano = 11;

Parameters
$var : int|string
Return values
$this

setSeverityNumber()

Numerical value of the severity, normalized to values described in Log Data Model.

public setSeverityNumber(int $var) : $this

[Optional].

Generated from protobuf field .opentelemetry.proto.logs.v1.SeverityNumber severity_number = 2;

Parameters
$var : int
Return values
$this

setSeverityText()

The severity text (also known as log level). The original string representation as it is known at the source. [Optional].

public setSeverityText(string $var) : $this

Generated from protobuf field string severity_text = 3;

Parameters
$var : string
Return values
$this

setSpanId()

A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes OR of length other than 8 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

public setSpanId(string $var) : $this

This field is optional. If the sender specifies a valid span_id then it SHOULD also specify a valid trace_id. The receivers SHOULD assume that the log record is not associated with a span if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes span_id = 10;

Parameters
$var : string
Return values
$this

setTimeUnixNano()

time_unix_nano is the time when the event occurred.

public setTimeUnixNano(int|string $var) : $this

Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. Value of 0 indicates unknown or missing timestamp.

Generated from protobuf field fixed64 time_unix_nano = 1;

Parameters
$var : int|string
Return values
$this

setTraceId()

A unique identifier for a trace. All logs from the same trace share the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR of length other than 16 bytes is considered invalid (empty string in OTLP/JSON is zero-length and thus is also invalid).

public setTraceId(string $var) : $this

This field is optional. The receivers SHOULD assume that the log record is not associated with a trace if any of the following is true:

  • the field is not present,
  • the field contains an invalid value.

Generated from protobuf field bytes trace_id = 9;

Parameters
$var : string
Return values
$this

        
On this page

Search results