fixing warnings from local build (#1277)
A couple of warnings have popped up recently: - docker compose 'version' is deprecated - BSD host id test was running a command that doesn't exist, which was visible in test output (removed test case) - synchronous metric stream test was triggering a warnings which was visible in test output (changed to use LogsMessagesTrait) - resource merging with different schema URLs was triggering a warnings from Config test (updated yaml schema_url and documented)
This commit is contained in:
parent
43339294f5
commit
5019361068
|
@ -1,4 +1,3 @@
|
||||||
version: '3.7'
|
|
||||||
services:
|
services:
|
||||||
php:
|
php:
|
||||||
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.1}
|
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.1}
|
||||||
|
|
|
@ -31,3 +31,8 @@ diff <(grep "public const" src/SemConv/TraceAttributes.php | sort -u) \
|
||||||
```
|
```
|
||||||
|
|
||||||
Use this output as a basis for updating the relevant deprecations file and generate a second time to include them in the final output.
|
Use this output as a basis for updating the relevant deprecations file and generate a second time to include them in the final output.
|
||||||
|
|
||||||
|
## Update tests
|
||||||
|
|
||||||
|
Update `tests/Integration/Config/configurations/kitchen-sink.yaml`'s `resource.schema_url` value to the latest, as merging resources
|
||||||
|
with different schema URLs is a merging error, per spec.
|
|
@ -5,18 +5,17 @@ declare(strict_types=1);
|
||||||
namespace OpenTelemetry\SDK\Metrics\Stream;
|
namespace OpenTelemetry\SDK\Metrics\Stream;
|
||||||
|
|
||||||
use function assert;
|
use function assert;
|
||||||
use const E_USER_WARNING;
|
|
||||||
use function extension_loaded;
|
use function extension_loaded;
|
||||||
use GMP;
|
use GMP;
|
||||||
use function gmp_init;
|
use function gmp_init;
|
||||||
use function is_int;
|
use function is_int;
|
||||||
|
use OpenTelemetry\API\Behavior\LogsMessagesTrait;
|
||||||
use OpenTelemetry\SDK\Metrics\AggregationInterface;
|
use OpenTelemetry\SDK\Metrics\AggregationInterface;
|
||||||
use OpenTelemetry\SDK\Metrics\Data\DataInterface;
|
use OpenTelemetry\SDK\Metrics\Data\DataInterface;
|
||||||
use OpenTelemetry\SDK\Metrics\Data\Exemplar;
|
use OpenTelemetry\SDK\Metrics\Data\Exemplar;
|
||||||
use OpenTelemetry\SDK\Metrics\Data\Temporality;
|
use OpenTelemetry\SDK\Metrics\Data\Temporality;
|
||||||
use const PHP_INT_SIZE;
|
use const PHP_INT_SIZE;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function trigger_error;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -24,6 +23,8 @@ use function trigger_error;
|
||||||
*/
|
*/
|
||||||
final class SynchronousMetricStream implements MetricStreamInterface
|
final class SynchronousMetricStream implements MetricStreamInterface
|
||||||
{
|
{
|
||||||
|
use LogsMessagesTrait;
|
||||||
|
|
||||||
private readonly DeltaStorage $delta;
|
private readonly DeltaStorage $delta;
|
||||||
private int|GMP $readers = 0;
|
private int|GMP $readers = 0;
|
||||||
private int|GMP $cumulative = 0;
|
private int|GMP $cumulative = 0;
|
||||||
|
@ -62,7 +63,7 @@ final class SynchronousMetricStream implements MetricStreamInterface
|
||||||
|
|
||||||
if ($reader === (PHP_INT_SIZE << 3) - 1 && is_int($this->readers)) {
|
if ($reader === (PHP_INT_SIZE << 3) - 1 && is_int($this->readers)) {
|
||||||
if (!extension_loaded('gmp')) {
|
if (!extension_loaded('gmp')) {
|
||||||
trigger_error(sprintf('GMP extension required to register over %d readers', (PHP_INT_SIZE << 3) - 1), E_USER_WARNING);
|
self::logWarning(sprintf('GMP extension required to register over %d readers', (PHP_INT_SIZE << 3) - 1));
|
||||||
$reader = PHP_INT_SIZE << 3;
|
$reader = PHP_INT_SIZE << 3;
|
||||||
} else {
|
} else {
|
||||||
assert(is_int($this->cumulative));
|
assert(is_int($this->cumulative));
|
||||||
|
|
|
@ -68,7 +68,7 @@ final class Host implements ResourceDetectorInterface
|
||||||
|
|
||||||
$out = exec('kenv -q smbios.system.uuid');
|
$out = exec('kenv -q smbios.system.uuid');
|
||||||
|
|
||||||
if ($out != false) {
|
if ($out !== false) {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ final class Host implements ResourceDetectorInterface
|
||||||
{
|
{
|
||||||
$out = exec('ioreg -rd1 -c IOPlatformExpertDevice | awk \'/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }\'');
|
$out = exec('ioreg -rd1 -c IOPlatformExpertDevice | awk \'/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }\'');
|
||||||
|
|
||||||
if ($out != false) {
|
if ($out !== false) {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ final class Host implements ResourceDetectorInterface
|
||||||
{
|
{
|
||||||
$out = exec('powershell.exe -Command "Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\Cryptography -Name MachineGuid"');
|
$out = exec('powershell.exe -Command "Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\Cryptography -Name MachineGuid"');
|
||||||
|
|
||||||
if ($out != false) {
|
if ($out !== false) {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,4 +349,4 @@ resource:
|
||||||
# Environment variable: OTEL_SERVICE_NAME
|
# Environment variable: OTEL_SERVICE_NAME
|
||||||
service.name: !!str "unknown_service"
|
service.name: !!str "unknown_service"
|
||||||
# Configure the resource schema URL.
|
# Configure the resource schema URL.
|
||||||
schema_url: https://opentelemetry.io/schemas/1.23.1
|
schema_url: https://opentelemetry.io/schemas/1.25.0
|
||||||
|
|
|
@ -16,8 +16,8 @@ class HostTest extends TestCase
|
||||||
{
|
{
|
||||||
public function test_host_get_resource(): void
|
public function test_host_get_resource(): void
|
||||||
{
|
{
|
||||||
$resouceDetector = new Detectors\Host();
|
$resourceDetector = new Detectors\Host();
|
||||||
$resource = $resouceDetector->getResource();
|
$resource = $resourceDetector->getResource();
|
||||||
|
|
||||||
$this->assertSame(ResourceAttributes::SCHEMA_URL, $resource->getSchemaUrl());
|
$this->assertSame(ResourceAttributes::SCHEMA_URL, $resource->getSchemaUrl());
|
||||||
$this->assertIsString($resource->getAttributes()->get(ResourceAttributes::HOST_NAME));
|
$this->assertIsString($resource->getAttributes()->get(ResourceAttributes::HOST_NAME));
|
||||||
|
@ -30,8 +30,8 @@ class HostTest extends TestCase
|
||||||
public function test_host_id_filesystem(string $os, array $files, ?string $expectedId): void
|
public function test_host_id_filesystem(string $os, array $files, ?string $expectedId): void
|
||||||
{
|
{
|
||||||
$root = vfsStream::setup('/', null, $files);
|
$root = vfsStream::setup('/', null, $files);
|
||||||
$resouceDetector = new Detectors\Host($root->url(), $os);
|
$resourceDetector = new Detectors\Host($root->url(), $os);
|
||||||
$resource = $resouceDetector->getResource();
|
$resource = $resourceDetector->getResource();
|
||||||
|
|
||||||
if ($expectedId === null) {
|
if ($expectedId === null) {
|
||||||
$this->assertFalse($resource->getAttributes()->has(ResourceAttributes::HOST_ID));
|
$this->assertFalse($resource->getAttributes()->has(ResourceAttributes::HOST_ID));
|
||||||
|
@ -71,7 +71,6 @@ class HostTest extends TestCase
|
||||||
['Linux', $etc_machineid, '1234567890'],
|
['Linux', $etc_machineid, '1234567890'],
|
||||||
['Linux', array_merge($etc_machineid, $varLibDbus), '1234567890'],
|
['Linux', array_merge($etc_machineid, $varLibDbus), '1234567890'],
|
||||||
['Linux', $etc_machineid, '1234567890'],
|
['Linux', $etc_machineid, '1234567890'],
|
||||||
['BSD', [], null],
|
|
||||||
['BSD', $etc_hostid, '1234567890'],
|
['BSD', $etc_hostid, '1234567890'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue