Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate event logger #1466

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/SDK/Logs/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OpenTelemetry\Context\ContextInterface;

/**
* @deprecated
* @phan-suppress PhanDeprecatedInterface
*/
class EventLogger implements EventLoggerInterface
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/Logs/EventLoggerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public function __construct(private readonly LoggerProviderInterface $loggerProv
{
}

/**
* @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/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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this work if moved to phan-suppress-next-line around the event logger? 🤔

*/
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
Loading