-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move and refactor clock components (#633)
* Move Clock classes to SDK\Common\Time namespace * Move conversion methods to Util class * Implement StopWatch * Implement ClockFactory * Fix StopwatchInterface * Finalize ClockFactory * Implement StopWatchFactory * Deprecate AbstractClock * Add BC alias * Add initial start time to StopWatch * Unify and optimize SystemClock methods * Use ClockFactory in Span * Use ClockFactory in BatchSpanProcessor * Use ClockInterface in BatchSpanProcessorTest * Use ClockFactory in SpanData * Use ClockFactory in examples * Add millisToNanos Util method * Use StopWatch in BatchSpanProcessor * Make Phan happy * Make Psalm happy * Make PHPUnit happy * Remove sllh/composer-versions-check from allowed composer plugins * Use correct assertion * Use correct assertion * Assert difference
- Loading branch information
Showing
40 changed files
with
902 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SDK\Common\Time; | ||
|
||
final class ClockFactory implements ClockFactoryInterface | ||
{ | ||
private static ?ClockInterface $default; | ||
|
||
public static function create(): self | ||
{ | ||
return new self(); | ||
} | ||
|
||
public function build(): ClockInterface | ||
{ | ||
return new SystemClock(); | ||
} | ||
|
||
public static function getDefault(): ClockInterface | ||
{ | ||
return self::$default ?? self::$default = self::create()->build(); | ||
} | ||
|
||
public static function setDefault(?ClockInterface $clock): void | ||
{ | ||
self::$default = $clock; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SDK\Common\Time; | ||
|
||
interface ClockFactoryInterface | ||
{ | ||
public static function create(): self; | ||
|
||
public function build(): ClockInterface; | ||
|
||
public static function getDefault(): ClockInterface; | ||
|
||
public static function setDefault(?ClockInterface $clock): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SDK\Common\Time; | ||
|
||
interface ClockInterface | ||
{ | ||
public const MILLIS_PER_SECOND = 1_000; | ||
public const MICROS_PER_SECOND = 1_000_000; | ||
public const NANOS_PER_SECOND = 1_000_000_000; | ||
public const NANOS_PER_MILLISECOND = 1_000_000; | ||
public const NANOS_PER_MICROSECOND = 1_000; | ||
|
||
/** | ||
* Returns the current epoch wall-clock timestamp in nanoseconds | ||
*/ | ||
public function now(): int; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
public function nanoTime(): int; | ||
} | ||
|
||
/** | ||
* BC class alias | ||
* @todo: remove in future release. Also in composer.json autoload/files. | ||
*/ | ||
class_alias(ClockInterface::class, 'OpenTelemetry\SDK\ClockInterface'); |
Oops, something went wrong.