Skip to content

Commit 6957241

Browse files
authored
generate semconv 1.38.0 (#1855)
* generate semconv 1.38.0 - generate 1.38.0 - update resource detectors to use 1.38.0 semconv classes - fix some failing tests * remove new and not-required semconvs
1 parent 393846c commit 6957241

38 files changed

Lines changed: 686 additions & 99 deletions

script/semantic-conventions/semconv.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ SPEC_DIR="${ROOT_DIR}/var/semantic-conventions"
1717
CODE_DIR="${ROOT_DIR}/src/SemConv"
1818

1919
# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
20-
SEMCONV_VERSION=1.37.0
20+
SEMCONV_VERSION=1.38.0
2121
SPEC_VERSION=v$SEMCONV_VERSION
2222
SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION
23-
OTEL_WEAVER_IMG_VERSION=v0.17.1
23+
OTEL_WEAVER_IMG_VERSION=v0.20.0
2424

2525
rm -rf "${SPEC_DIR}"
2626
mkdir "${SPEC_DIR}"

script/semantic-conventions/templates/registry/php/weaver.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ params:
44
excluded_namespaces: [
55
android, app, artifact, aws, azure, browser, cassandra, device, disk,
66
elasticsearch, enduser, event, faas, feature_flag, file, gen_ai, gcp,
7-
geo, go, graphql, heroku, ios, k8s, linux, mainframe, message,
8-
oci, openai, opentracing, other, pool, rpc, security_rule, source, system, test,
7+
geo, go, graphql, heroku, ios, jsonrpc, k8s, linux, mainframe, mcp, message, nfs,
8+
oci, onc_rpc, openai, openshift, opentracing, other, pool, pprof, rpc, security_rule, source, system, test,
99
useragent, v8js, vcs, webengine, zos, az, session, thread, destination,
1010
cicd, cloud, cloudevents, cpu, cpython, aspnetcore,
1111
cloudfoundry, dotnet, hw, jvm, nodejs, profile, signalr

src/API/Behavior/Internal/LogWriter/Formatter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace OpenTelemetry\API\Behavior\Internal\LogWriter;
66

7+
/**
8+
* @todo print $context
9+
*/
710
class Formatter
811
{
912
public static function format($level, string $message, array $context): string

src/SDK/Resource/Detectors/Composer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
1111
use OpenTelemetry\SDK\Resource\ResourceInfo;
1212
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
13-
use OpenTelemetry\SemConv\ResourceAttributes;
13+
use OpenTelemetry\SemConv\Attributes\ServiceAttributes;
14+
use OpenTelemetry\SemConv\Version;
1415

1516
/**
1617
* Detect service name and version of root package. Not included in `all` detectors.
@@ -25,10 +26,10 @@ public function getResource(): ResourceInfo
2526
}
2627

2728
$attributes = [
28-
ResourceAttributes::SERVICE_NAME => InstalledVersions::getRootPackage()['name'],
29-
ResourceAttributes::SERVICE_VERSION => InstalledVersions::getRootPackage()['pretty_version'],
29+
ServiceAttributes::SERVICE_NAME => InstalledVersions::getRootPackage()['name'],
30+
ServiceAttributes::SERVICE_VERSION => InstalledVersions::getRootPackage()['pretty_version'],
3031
];
3132

32-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
33+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
3334
}
3435
}

src/SDK/Resource/Detectors/Environment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use OpenTelemetry\SDK\Common\Configuration\Variables;
1010
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
1111
use OpenTelemetry\SDK\Resource\ResourceInfo;
12-
use OpenTelemetry\SemConv\ResourceAttributes;
12+
use OpenTelemetry\SemConv\Version;
1313

1414
/**
1515
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable
@@ -23,7 +23,7 @@ public function getResource(): ResourceInfo
2323
? self::decode(Configuration::getMap(Variables::OTEL_RESOURCE_ATTRIBUTES, []))
2424
: [];
2525

26-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
26+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
2727
}
2828

2929
private static function decode(array $attributes): array

src/SDK/Resource/Detectors/Host.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
use OpenTelemetry\SDK\Common\Attribute\Attributes;
88
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
99
use OpenTelemetry\SDK\Resource\ResourceInfo;
10-
use OpenTelemetry\SemConv\ResourceAttributes;
10+
use OpenTelemetry\SemConv\Incubating\Attributes\HostIncubatingAttributes;
11+
use OpenTelemetry\SemConv\Incubating\Attributes\OsIncubatingAttributes;
12+
use OpenTelemetry\SemConv\Version;
1113
use const PHP_OS;
1214
use const PHP_OS_FAMILY;
1315
use function php_uname;
@@ -33,16 +35,16 @@ public function __construct(
3335
public function getResource(): ResourceInfo
3436
{
3537
$attributes = [
36-
ResourceAttributes::HOST_NAME => php_uname('n'),
37-
ResourceAttributes::HOST_ARCH => php_uname('m'),
38-
ResourceAttributes::HOST_ID => $this->getMachineId(),
39-
ResourceAttributes::OS_TYPE => strtolower(PHP_OS_FAMILY),
40-
ResourceAttributes::OS_DESCRIPTION => php_uname('r'),
41-
ResourceAttributes::OS_NAME => PHP_OS,
42-
ResourceAttributes::OS_VERSION => php_uname('v'),
38+
HostIncubatingAttributes::HOST_NAME => php_uname('n'),
39+
HostIncubatingAttributes::HOST_ARCH => php_uname('m'),
40+
HostIncubatingAttributes::HOST_ID => $this->getMachineId(),
41+
OsIncubatingAttributes::OS_TYPE => strtolower(PHP_OS_FAMILY),
42+
OsIncubatingAttributes::OS_DESCRIPTION => php_uname('r'),
43+
OsIncubatingAttributes::OS_NAME => PHP_OS,
44+
OsIncubatingAttributes::OS_VERSION => php_uname('v'),
4345
];
4446

45-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
47+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
4648
}
4749

4850
private function getMachineId(): ?string

src/SDK/Resource/Detectors/Process.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
use OpenTelemetry\SDK\Common\Attribute\Attributes;
1010
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
1111
use OpenTelemetry\SDK\Resource\ResourceInfo;
12-
use OpenTelemetry\SemConv\ResourceAttributes;
12+
use OpenTelemetry\SemConv\Incubating\Attributes\ProcessIncubatingAttributes;
13+
use OpenTelemetry\SemConv\Version;
1314
use const PHP_BINARY;
1415
use function php_sapi_name;
1516
use const PHP_VERSION;
@@ -27,25 +28,25 @@ final class Process implements ResourceDetectorInterface
2728
public function getResource(): ResourceInfo
2829
{
2930
$attributes = [
30-
ResourceAttributes::PROCESS_RUNTIME_NAME => php_sapi_name(),
31-
ResourceAttributes::PROCESS_RUNTIME_VERSION => PHP_VERSION,
32-
ResourceAttributes::PROCESS_PID => getmypid(),
33-
ResourceAttributes::PROCESS_EXECUTABLE_PATH => PHP_BINARY,
31+
ProcessIncubatingAttributes::PROCESS_RUNTIME_NAME => php_sapi_name(),
32+
ProcessIncubatingAttributes::PROCESS_RUNTIME_VERSION => PHP_VERSION,
33+
ProcessIncubatingAttributes::PROCESS_PID => getmypid(),
34+
ProcessIncubatingAttributes::PROCESS_EXECUTABLE_PATH => PHP_BINARY,
3435
];
3536

3637
/**
3738
* @psalm-suppress PossiblyUndefinedArrayOffset
3839
*/
3940
if ($_SERVER['argv'] ?? null) {
40-
$attributes[ResourceAttributes::PROCESS_COMMAND] = $_SERVER['argv'][0];
41-
$attributes[ResourceAttributes::PROCESS_COMMAND_ARGS] = $_SERVER['argv'];
41+
$attributes[ProcessIncubatingAttributes::PROCESS_COMMAND] = $_SERVER['argv'][0];
42+
$attributes[ProcessIncubatingAttributes::PROCESS_COMMAND_ARGS] = $_SERVER['argv'];
4243
}
4344

4445
/** @phan-suppress-next-line PhanTypeComparisonFromArray */
4546
if (extension_loaded('posix') && ($user = \posix_getpwuid(\posix_geteuid())) !== false) {
46-
$attributes[ResourceAttributes::PROCESS_OWNER] = $user['name'];
47+
$attributes[ProcessIncubatingAttributes::PROCESS_OWNER] = $user['name'];
4748
}
4849

49-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
50+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
5051
}
5152
}

src/SDK/Resource/Detectors/Sdk.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use OpenTelemetry\SDK\Common\Attribute\Attributes;
1010
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
1111
use OpenTelemetry\SDK\Resource\ResourceInfo;
12-
use OpenTelemetry\SemConv\ResourceAttributes;
12+
use OpenTelemetry\SemConv\Attributes\TelemetryAttributes;
13+
use OpenTelemetry\SemConv\Incubating\Attributes\TelemetryIncubatingAttributes;
14+
use OpenTelemetry\SemConv\Version;
1315

1416
/**
1517
* The SDK MUST provide access to a Resource with at least the attributes listed
@@ -26,8 +28,8 @@ final class Sdk implements ResourceDetectorInterface
2628
public function getResource(): ResourceInfo
2729
{
2830
$attributes = [
29-
ResourceAttributes::TELEMETRY_SDK_NAME => 'opentelemetry',
30-
ResourceAttributes::TELEMETRY_SDK_LANGUAGE => 'php',
31+
TelemetryAttributes::TELEMETRY_SDK_NAME => 'opentelemetry',
32+
TelemetryAttributes::TELEMETRY_SDK_LANGUAGE => 'php',
3133
];
3234

3335
if (class_exists(InstalledVersions::class)) {
@@ -39,17 +41,17 @@ public function getResource(): ResourceInfo
3941
continue;
4042
}
4143

42-
$attributes[ResourceAttributes::TELEMETRY_SDK_VERSION] = $version;
44+
$attributes[TelemetryAttributes::TELEMETRY_SDK_VERSION] = $version;
4345

4446
break;
4547
}
4648
}
4749

4850
if (extension_loaded('opentelemetry')) {
49-
$attributes[ResourceAttributes::TELEMETRY_DISTRO_NAME] = 'opentelemetry-php-instrumentation';
50-
$attributes[ResourceAttributes::TELEMETRY_DISTRO_VERSION] = phpversion('opentelemetry');
51+
$attributes[TelemetryIncubatingAttributes::TELEMETRY_DISTRO_NAME] = 'opentelemetry-php-instrumentation';
52+
$attributes[TelemetryIncubatingAttributes::TELEMETRY_DISTRO_VERSION] = phpversion('opentelemetry');
5153
}
5254

53-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
55+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
5456
}
5557
}

src/SDK/Resource/Detectors/Service.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
use OpenTelemetry\SDK\Common\Configuration\Variables;
1010
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
1111
use OpenTelemetry\SDK\Resource\ResourceInfo;
12-
use OpenTelemetry\SemConv\ResourceAttributes;
12+
use OpenTelemetry\SemConv\Attributes\ServiceAttributes;
13+
use OpenTelemetry\SemConv\Version;
1314

1415
/**
1516
* @see https://github.com/open-telemetry/semantic-conventions/tree/main/docs/resource#service-experimental
@@ -24,9 +25,9 @@ public function getResource(): ResourceInfo
2425
: null;
2526

2627
$attributes = [
27-
ResourceAttributes::SERVICE_NAME => $serviceName,
28+
ServiceAttributes::SERVICE_NAME => $serviceName,
2829
];
2930

30-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
31+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
3132
}
3233
}

src/SDK/Resource/Detectors/ServiceInstance.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
use OpenTelemetry\SDK\Common\Attribute\Attributes;
88
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
99
use OpenTelemetry\SDK\Resource\ResourceInfo;
10-
use OpenTelemetry\SemConv\ResourceAttributes;
10+
use OpenTelemetry\SemConv\Incubating\Attributes\ServiceIncubatingAttributes;
11+
use OpenTelemetry\SemConv\Version;
1112
use Ramsey\Uuid\Uuid;
1213

1314
/**
@@ -25,9 +26,9 @@ public function getResource(): ResourceInfo
2526
$serviceInstanceId ??= Uuid::uuid4()->toString();
2627

2728
$attributes = [
28-
ResourceAttributes::SERVICE_INSTANCE_ID => $serviceInstanceId,
29+
ServiceIncubatingAttributes::SERVICE_INSTANCE_ID => $serviceInstanceId,
2930
];
3031

31-
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
32+
return ResourceInfo::create(Attributes::create($attributes), Version::VERSION_1_38_0->url());
3233
}
3334
}

0 commit comments

Comments
 (0)