Skip to content

Commit

Permalink
deprecate event logger (#1466)
Browse files Browse the repository at this point in the history
The event logger was a Development-status component of the logging signal. It has been
removed in favour of adding emitEvent to the logger interface,
see open-telemetry/opentelemetry-specification#4319
  • Loading branch information
brettmc authored Jan 8, 2025
1 parent a860bd4 commit 351a30b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public static function loggerProvider(): LoggerProviderInterface
return Context::getCurrent()->get(ContextKeys::loggerProvider()) ?? self::globals()->loggerProvider;
}

/**
* @deprecated
* @phan-suppress PhanDeprecatedFunction
*/
public static function eventLoggerProvider(): EventLoggerProviderInterface
{
return Context::getCurrent()->get(ContextKeys::eventLoggerProvider()) ?? self::globals()->eventLoggerProvider;
Expand All @@ -76,7 +80,7 @@ public static function registerInitializer(Closure $initializer): void
}

/**
* @phan-suppress PhanTypeMismatchReturnNullable
* @phan-suppress PhanTypeMismatchReturnNullable,PhanDeprecatedFunction
*/
private static function globals(): self
{
Expand Down
5 changes: 5 additions & 0 deletions Instrumentation/CachedInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function logger(): LoggerInterface

return $this->loggers[$loggerProvider] ??= $loggerProvider->getLogger($this->name, $this->version, $this->schemaUrl, $this->attributes);
}

/**
* @deprecated
* @phan-suppress PhanDeprecatedFunction
*/
public function eventLogger(): EventLoggerInterface
{
$eventLoggerProvider = Globals::eventLoggerProvider();
Expand Down
7 changes: 7 additions & 0 deletions Instrumentation/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function create(): Configurator

/**
* Creates a configurator that uses noop instances for not configured values.
* @phan-suppress PhanDeprecatedFunction
*/
public static function createNoop(): Configurator
{
Expand All @@ -63,6 +64,9 @@ public function activate(): ScopeInterface
return $this->storeInContext()->activate();
}

/**
* @phan-suppress PhanDeprecatedFunction
*/
public function storeInContext(?ContextInterface $context = null): ContextInterface
{
$context ??= Context::getCurrent();
Expand Down Expand Up @@ -118,6 +122,9 @@ public function withLoggerProvider(?LoggerProviderInterface $loggerProvider): Co
return $self;
}

/**
* @deprecated
*/
public function withEventLoggerProvider(?EventLoggerProviderInterface $eventLoggerProvider): Configurator
{
$self = clone $this;
Expand Down
1 change: 1 addition & 0 deletions Instrumentation/ContextKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function loggerProvider(): ContextKeyInterface
}

/**
* @deprecated
* @return ContextKeyInterface<EventLoggerProviderInterface>
*/
public static function eventLoggerProvider(): ContextKeyInterface
Expand Down
1 change: 1 addition & 0 deletions Logs/EventLoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OpenTelemetry\Context\ContextInterface;

/**
* @deprecated
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/event-api.md#events-api-interface
*/
interface EventLoggerInterface
Expand Down
1 change: 1 addition & 0 deletions Logs/EventLoggerProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace OpenTelemetry\API\Logs;

/**
* @deprecated
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.32.0/specification/logs/event-api.md#get-an-eventlogger
*/
interface EventLoggerProviderInterface
Expand Down
3 changes: 3 additions & 0 deletions Logs/NoopEventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use OpenTelemetry\Context\ContextInterface;

/**
* @phan-suppress PhanDeprecatedInterface
*/
class NoopEventLogger implements EventLoggerInterface
{
public static function instance(): self
Expand Down
3 changes: 3 additions & 0 deletions Logs/NoopEventLoggerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace OpenTelemetry\API\Logs;

/**
* @phan-suppress PhanDeprecatedInterface
*/
class NoopEventLoggerProvider implements EventLoggerProviderInterface
{
public static function getInstance(): self
Expand Down

0 comments on commit 351a30b

Please sign in to comment.