diff --git a/Logs/Logger.php b/Logs/Logger.php index 94ab3d7..563566a 100644 --- a/Logs/Logger.php +++ b/Logs/Logger.php @@ -7,15 +7,10 @@ use OpenTelemetry\API\Behavior\LogsMessagesTrait; use OpenTelemetry\API\Logs\LoggerInterface; use OpenTelemetry\API\Logs\LogRecord; +use OpenTelemetry\Context\ContextInterface; use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; use OpenTelemetry\SDK\Common\InstrumentationScope\Configurator; -/** - * Note that this logger class is deliberately NOT psr-3 compatible, per spec: "Note: this document defines a log - * backend API. The API is not intended to be called by application developers directly." - * - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md - */ class Logger implements LoggerInterface { use LogsMessagesTrait; @@ -33,6 +28,9 @@ public function __construct( $this->config = $configurator ? $configurator->resolve($scope) : LoggerConfig::default(); } + /** + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.44.0/specification/logs/api.md#emit-a-logrecord + */ public function emit(LogRecord $logRecord): void { //If a Logger is disabled, it MUST behave equivalently to No-op Logger. @@ -52,12 +50,16 @@ public function emit(LogRecord $logRecord): void } } - public function isEnabled(): bool + /** + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.44.0/specification/logs/api.md#enabled + */ + public function isEnabled(?ContextInterface $context = null, ?int $severityNumber = null): bool { return $this->config->isEnabled(); } /** + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.44.0/specification/logs/sdk.md#loggerconfigurator * @param Configurator $configurator */ public function updateConfig(Configurator $configurator): void diff --git a/Logs/ReadableLogRecord.php b/Logs/ReadableLogRecord.php index f1d09e5..d5c49a3 100644 --- a/Logs/ReadableLogRecord.php +++ b/Logs/ReadableLogRecord.php @@ -37,6 +37,7 @@ public function __construct( $this->spanContext = Span::fromContext($context)->getContext(); $this->severityNumber = $logRecord->severityNumber; $this->severityText = $logRecord->severityText; + $this->eventName = $logRecord->eventName; //convert attributes now so that excess data is not sent to processors $this->convertedAttributes = $this->loggerSharedState @@ -94,6 +95,11 @@ public function getBody() return $this->body; } + public function getEventName(): ?string + { + return $this->eventName; + } + public function getAttributes(): AttributesInterface { return $this->convertedAttributes;