Skip to content

Commit

Permalink
deprecate event logger (open-telemetry#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 committed Jan 9, 2025
1 parent b90344e commit b4484c4
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/API/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 src/API/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 src/API/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 src/API/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 src/API/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 src/API/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 src/API/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 src/API/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
4 changes: 4 additions & 0 deletions src/SDK/Logs/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use OpenTelemetry\Context\Context;
use OpenTelemetry\Context\ContextInterface;

/**
* @deprecated
* @phan-suppress PhanDeprecatedInterface
*/
class EventLogger implements EventLoggerInterface
{
/**
Expand Down
6 changes: 6 additions & 0 deletions src/SDK/Logs/EventLoggerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
use OpenTelemetry\API\Common\Time\Clock;
use OpenTelemetry\API\Logs\EventLoggerInterface;

/**
* @phan-suppress PhanDeprecatedInterface
*/
class EventLoggerProvider implements EventLoggerProviderInterface
{
public function __construct(private readonly LoggerProviderInterface $loggerProvider)
{
}

/**
* @phan-suppress PhanDeprecatedClass
*/
public function getEventLogger(string $name, ?string $version = null, ?string $schemaUrl = null, iterable $attributes = []): EventLoggerInterface
{
return new EventLogger(
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Logs/EventLoggerProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use OpenTelemetry\SDK\Sdk;

/**
* @deprecated
*/
class EventLoggerProviderFactory
{
public function create(LoggerProviderInterface $loggerProvider): EventLoggerProviderInterface
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Logs/EventLoggerProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use OpenTelemetry\API\Logs as API;

/**
* @phan-suppress PhanDeprecatedInterface
*/
interface EventLoggerProviderInterface extends API\EventLoggerProviderInterface
{
public function forceFlush(): bool;
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Logs/NoopEventLoggerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use OpenTelemetry\API\Logs as API;

/**
* @phan-suppress PhanDeprecatedInterface
*/
class NoopEventLoggerProvider extends API\NoopEventLoggerProvider implements EventLoggerProviderInterface
{
public static function getInstance(): self
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Sdk.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function getLoggerProvider(): LoggerProviderInterface
return $this->loggerProvider;
}

/**
* @deprecated
*/
public function getEventLoggerProvider(): EventLoggerProviderInterface
{
return $this->eventLoggerProvider;
Expand Down
5 changes: 4 additions & 1 deletion src/SDK/SdkAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public static function autoload(): bool
return true;
}

/**
* @phan-suppress PhanDeprecatedClass,PhanDeprecatedFunction
*/
private static function environmentBasedInitializer(Configurator $configurator): Configurator
{
$propagator = (new PropagatorFactory())->create();
Expand Down Expand Up @@ -110,7 +113,7 @@ private static function environmentBasedInitializer(Configurator $configurator):
}

/**
* @phan-suppress PhanPossiblyUndeclaredVariable
* @phan-suppress PhanPossiblyUndeclaredVariable,PhanDeprecatedFunction
*/
private static function fileBasedInitializer(Configurator $configurator): Configurator
{
Expand Down
6 changes: 6 additions & 0 deletions src/SDK/SdkBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function setLoggerProvider(LoggerProviderInterface $loggerProvider): self
return $this;
}

/**
* @deprecated
*/
public function setEventLoggerProvider(EventLoggerProviderInterface $eventLoggerProvider): self
{
$this->eventLoggerProvider = $eventLoggerProvider;
Expand Down Expand Up @@ -95,6 +98,9 @@ public function build(): Sdk
);
}

/**
* @phan-suppress PhanDeprecatedFunction
*/
public function buildAndRegisterGlobal(): ScopeInterface
{
$sdk = $this->build();
Expand Down

0 comments on commit b4484c4

Please sign in to comment.