class ReadableLogRecord
"Note: Typically this will be implemented with a new interface or (immutable) value type."
Hierarchy
- class \OpenTelemetry\API\Logs\LogRecord
- class \OpenTelemetry\SDK\Logs\ReadableLogRecord extends \OpenTelemetry\API\Logs\LogRecord
Expanded class hierarchy of ReadableLogRecord
See also
https://github.com/open-telemetry/opentelemetry-specification/blob/main…
3 files declare their use of ReadableLogRecord
- ConsoleExporter.php in vendor/
open-telemetry/ sdk/ Logs/ Exporter/ ConsoleExporter.php - LogsConverter.php in vendor/
open-telemetry/ exporter-otlp/ LogsConverter.php - LogsExporter.php in vendor/
open-telemetry/ exporter-otlp/ LogsExporter.php
File
-
vendor/
open-telemetry/ sdk/ Logs/ ReadableLogRecord.php, line 21
Namespace
OpenTelemetry\SDK\LogsView source
class ReadableLogRecord extends LogRecord {
protected AttributesInterface $convertedAttributes;
protected SpanContextInterface $spanContext;
public function __construct(InstrumentationScopeInterface $scope, LoggerSharedState $loggerSharedState, LogRecord $logRecord) {
parent::__construct($logRecord->body);
$this->timestamp = $logRecord->timestamp;
$this->observedTimestamp = $logRecord->observedTimestamp ?? (int) (microtime(true) * LogRecord::NANOS_PER_SECOND);
$this->context = $logRecord->context;
$context = $this->context ?? Context::getCurrent();
$this->spanContext = Span::fromContext($context)->getContext();
$this->severityNumber = $logRecord->severityNumber;
$this->severityText = $logRecord->severityText;
//convert attributes now so that excess data is not sent to processors
$this->convertedAttributes = $this->loggerSharedState
->getLogRecordLimits()
->getAttributeFactory()
->builder($logRecord->attributes, new LogRecordAttributeValidator())
->build();
}
public function getInstrumentationScope() : InstrumentationScopeInterface {
return $this->scope;
}
public function getResource() : ResourceInfo {
return $this->loggerSharedState
->getResource();
}
public function getTimestamp() : ?int {
return $this->timestamp;
}
public function getObservedTimestamp() : ?int {
return $this->observedTimestamp;
}
public function getContext() : ?ContextInterface {
return $this->context;
}
public function getSpanContext() : ?SpanContextInterface {
return $this->spanContext;
}
public function getSeverityNumber() : ?int {
return $this->severityNumber;
}
public function getSeverityText() : ?string {
return $this->severityText;
}
/**
* @return mixed|null
*/
public function getBody() {
return $this->body;
}
public function getAttributes() : AttributesInterface {
return $this->convertedAttributes;
}
}