Skip to content

Commit

Permalink
adding enum for semconv versions
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed May 1, 2024
1 parent 100e593 commit e3128c4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion script/semantic-conventions/semconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git reset --hard FETCH_HEAD
cd "${SCRIPT_DIR}"

mkdir -p "${CODE_DIR}"
find "${CODE_DIR}" -name "*.php" -exec rm -f {} \;
find "${CODE_DIR}" -name "*.php" ! -name "Version.php" -exec rm -f {} \;

# Trace
docker run --rm \
Expand Down
20 changes: 20 additions & 0 deletions src/SemConv/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace OpenTelemetry\SemConv;

enum Version: string
{
case VERSION_1_25_0 = '1.25.0';
case VERSION_1_24_0 = '1.24.0';
case VERSION_1_23_1 = '1.23.1';
case VERSION_1_23_0 = '1.23.0';
case VERSION_1_22_0 = '1.22.0';
case VERSION_1_21_0 = '1.21.0';

public function url(): string
{
return 'https://opentelemetry.io/schemas/' . $this->value;
}
}
19 changes: 19 additions & 0 deletions tests/Unit/SemConv/VersionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Unit\SemConv;

use OpenTelemetry\SemConv\Version;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(Version::class)]
class VersionTest extends TestCase
{
public function test_url(): void
{
$url = Version::VERSION_1_25_0->url();
$this->assertSame('https://opentelemetry.io/schemas/1.25.0', $url);
}
}

0 comments on commit e3128c4

Please sign in to comment.