Skip to content

Commit

Permalink
migrate Clock classes to API (#1281)
Browse files Browse the repository at this point in the history
* migrate Clock classes to API
- move Clock* + Util into API
- add a deprecated wrapper for ClockFactory and Util
- remove unused StopWatch* classes

* review feedback

* replace ClockFactory with Clock
It's not really a factory, and really only provides access to a system clock. Create a
Clock class which is more clear in its purpose.

* remove time Util class
per review feedback, it's only used in Zipkin. Removed some unused consts from ClockInterface

* Apply suggestions from code review

Co-authored-by: Tobias Bachert <[email protected]>

---------

Co-authored-by: Tobias Bachert <[email protected]>
  • Loading branch information
brettmc and Nevay authored Apr 29, 2024
1 parent 606129c commit 89fac3c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ComponentProvider/Logs/LogRecordProcessorBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace OpenTelemetry\Config\SDK\ComponentProvider\Logs;

use OpenTelemetry\API\Common\Time\Clock;
use OpenTelemetry\Config\SDK\Configuration\ComponentPlugin;
use OpenTelemetry\Config\SDK\Configuration\ComponentProvider;
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Logs\LogRecordExporterInterface;
use OpenTelemetry\SDK\Logs\LogRecordProcessorInterface;
use OpenTelemetry\SDK\Logs\Processor\BatchLogRecordProcessor;
Expand All @@ -33,7 +33,7 @@ public function createPlugin(array $properties, Context $context): LogRecordProc
{
return new BatchLogRecordProcessor(
exporter: $properties['exporter']->create($context),
clock: ClockFactory::getDefault(),
clock: Clock::getDefault(),
maxQueueSize: $properties['max_queue_size'],
scheduledDelayMillis: $properties['schedule_delay'],
exportTimeoutMillis: $properties['export_timeout'],
Expand Down
4 changes: 2 additions & 2 deletions ComponentProvider/OpenTelemetrySdk.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OpenTelemetry\Config\SDK\ComponentProvider;

use OpenTelemetry\API\Common\Time\Clock;
use OpenTelemetry\Config\SDK\Configuration\ComponentPlugin;
use OpenTelemetry\Config\SDK\Configuration\ComponentProvider;
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
Expand All @@ -13,7 +14,6 @@
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeFactory;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Logs\LoggerProvider;
use OpenTelemetry\SDK\Logs\LogRecordProcessorInterface;
use OpenTelemetry\SDK\Logs\Processor\MultiLogRecordProcessor;
Expand Down Expand Up @@ -215,7 +215,7 @@ public function createPlugin(array $properties, Context $context): SdkBuilder
$meterProvider = new MeterProvider(
contextStorage: null,
resource: $resource,
clock: ClockFactory::getDefault(),
clock: Clock::getDefault(),
attributesFactory: Attributes::factory(),
instrumentationScopeFactory: new InstrumentationScopeFactory(Attributes::factory()),
metricReaders: $metricReaders, // @phpstan-ignore-line
Expand Down
4 changes: 2 additions & 2 deletions ComponentProvider/Trace/SpanProcessorBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace OpenTelemetry\Config\SDK\ComponentProvider\Trace;

use OpenTelemetry\API\Common\Time\Clock;
use OpenTelemetry\Config\SDK\Configuration\ComponentPlugin;
use OpenTelemetry\Config\SDK\Configuration\ComponentProvider;
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Trace\SpanExporterInterface;
use OpenTelemetry\SDK\Trace\SpanProcessor\BatchSpanProcessor;
use OpenTelemetry\SDK\Trace\SpanProcessorInterface;
Expand All @@ -33,7 +33,7 @@ public function createPlugin(array $properties, Context $context): SpanProcessor
{
return new BatchSpanProcessor(
exporter: $properties['exporter']->create($context),
clock: ClockFactory::getDefault(),
clock: Clock::getDefault(),
maxQueueSize: $properties['max_queue_size'],
scheduledDelayMillis: $properties['schedule_delay'],
exportTimeoutMillis: $properties['export_timeout'],
Expand Down

0 comments on commit 89fac3c

Please sign in to comment.