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

feat: add extended metrics metadata #222

Merged
merged 3 commits into from
Jul 29, 2024
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
4 changes: 4 additions & 0 deletions src/Client/DefaultRegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function register(iterable $strategyHandlers): bool
'strategies' => array_map(fn (StrategyHandler $strategyHandler): string => $strategyHandler->getStrategyName(), $strategyHandlers),
'started' => (new DateTimeImmutable())->format('c'),
'interval' => $this->configuration->getMetricsInterval(),
'platformName' => PHP_SAPI,
'platformVersion' => phpversion(),
sighphyre marked this conversation as resolved.
Show resolved Hide resolved
'yggdrasilVersion' => null,
'specVersion' => Unleash::SPECIFICATION_VERSION,
], JSON_THROW_ON_ERROR)));
foreach ($this->configuration->getHeaders() as $name => $value) {
$request = $request->withHeader($name, $value);
Expand Down
5 changes: 5 additions & 0 deletions src/Metrics/DefaultMetricsSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Psr\Http\Message\RequestFactoryInterface;
use Unleash\Client\Configuration\UnleashConfiguration;
use Unleash\Client\Helper\StringStream;
use Unleash\Client\Unleash;

final readonly class DefaultMetricsSender implements MetricsSender
{
Expand All @@ -32,6 +33,10 @@ public function sendMetrics(MetricsBucket $bucket): void
'appName' => $this->configuration->getAppName(),
'instanceId' => $this->configuration->getInstanceId(),
'bucket' => $bucket->jsonSerialize(),
'platformName' => PHP_SAPI,
'platformVersion' => phpversion(),
sighphyre marked this conversation as resolved.
Show resolved Hide resolved
'yggdrasilVersion' => null,
'specVersion' => Unleash::SPECIFICATION_VERSION,
], JSON_THROW_ON_ERROR)));
foreach ($this->configuration->getHeaders() as $name => $value) {
$request = $request->withHeader($name, $value);
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/DefaultUnleashRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Unleash\Client\Exception\HttpResponseException;
use Unleash\Client\Exception\InvalidValueException;
use Unleash\Client\Helper\Url;
use Unleash\Client\Unleash;

/**
* @phpstan-type ConstraintArray array{
Expand Down Expand Up @@ -511,7 +512,7 @@ private function fetchFeatures(): array
->createRequest('GET', (string) Url::appendPath($this->configuration->getUrl(), 'client/features'))
->withHeader('UNLEASH-APPNAME', $this->configuration->getAppName())
->withHeader('UNLEASH-INSTANCEID', $this->configuration->getInstanceId())
->withHeader('Unleash-Client-Spec', '4.3.2');
->withHeader('Unleash-Client-Spec', Unleash::SPECIFICATION_VERSION);

foreach ($this->configuration->getHeaders() as $name => $value) {
$request = $request->withHeader($name, $value);
Expand Down
2 changes: 2 additions & 0 deletions src/Unleash.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface Unleash
{
public const string SDK_VERSION = '2.5.1';

public const string SPECIFICATION_VERSION = '4.3.2';

public function isEnabled(string $featureName, ?Context $context = null, bool $default = false): bool;

public function getVariant(string $featureName, ?Context $context = null, ?Variant $fallbackVariant = null): Variant;
Expand Down
Loading