Skip to content

Commit

Permalink
update semconv to 1.22.0 (#1126)
Browse files Browse the repository at this point in the history
* update semver to 1.22.0
Since 1.19.0, the source has been split out of opentelemetry-specifiction into semantic-conventions. Update the build script accordingly.
Update to latest generator.
Add 2 new deprecations for semconvs which were renamed since 1.19
* update telemetry semconv
  • Loading branch information
brettmc authored Oct 18, 2023
1 parent 842aa41 commit a325a8f
Show file tree
Hide file tree
Showing 5 changed files with 1,552 additions and 776 deletions.
18 changes: 10 additions & 8 deletions script/semantic-conventions/semconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../../"
SPEC_DIR="${ROOT_DIR}/var/opentelemetry-specification"
SPEC_DIR="${ROOT_DIR}/var/semantic-conventions"
CODE_DIR="${ROOT_DIR}/src/SemConv"

# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
SEMCONV_VERSION=${SEMCONV_VERSION:=1.19.0}
SEMCONV_VERSION=${SEMCONV_VERSION:=1.22.0}
SPEC_VERSION=v$SEMCONV_VERSION
SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION
GENERATOR_VERSION=0.18.0
GENERATOR_VERSION=0.22.0

cd "${SCRIPT_DIR}" || exit

Expand All @@ -24,7 +24,7 @@ mkdir "${SPEC_DIR}"
cd "${SPEC_DIR}" || exit

git init -b main
git remote add origin https://github.com/open-telemetry/opentelemetry-specification.git
git remote add origin https://github.com/open-telemetry/semantic-conventions.git
git fetch origin "$SPEC_VERSION"
git reset --hard FETCH_HEAD

Expand All @@ -35,13 +35,14 @@ find "${CODE_DIR}" -name "*.php" -exec rm -f {} \;

# Trace
docker run --rm \
-v "${SPEC_DIR}/semantic_conventions:/source" \
-v "${SPEC_DIR}/model:/source" \
-v "${SCRIPT_DIR}/templates:/templates" \
-v "${CODE_DIR}:/output" \
-u "${UID}" \
otel/semconvgen:$GENERATOR_VERSION \
--only span,event,attribute_group,scope \
-f /source code \
--yaml-root /source \
code \
--template /templates/Attributes.php.j2 \
--output "/output/TraceAttributes.php" \
-Dnamespace="OpenTelemetry\\SemConv" \
Expand All @@ -50,13 +51,14 @@ docker run --rm \

# Resource
docker run --rm \
-v "${SPEC_DIR}/semantic_conventions:/source" \
-v "${SPEC_DIR}/model:/source" \
-v "${SCRIPT_DIR}/templates:/templates" \
-v "${CODE_DIR}:/output" \
-u "${UID}" \
otel/semconvgen:$GENERATOR_VERSION \
--only resource \
-f /source code \
--yaml-root /source \
code \
--template /templates/Attributes.php.j2 \
--output "/output/ResourceAttributes.php" \
-Dnamespace="OpenTelemetry\\SemConv" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/**
* @deprecated
* @deprecated Use USER_AGENT_ORIGINAL
*/
public const BROWSER_USER_AGENT = 'browser.user_agent';

/**
* @deprecated
* @deprecated Use CLOUD_RESOURCE_ID
*/
public const FAAS_ID = 'faas.id';

/**
* @deprecated Use TELEMETRY_DISTRO_VERSION
*/
public const TELEMETRY_AUTO_VERSION = 'telemetry.auto.version';

/**
* @deprecated Use CONTAINER_IMAGE_TAGS
*/
public const CONTAINER_IMAGE_TAG = 'container.image.tag';
3 changes: 2 additions & 1 deletion src/SDK/Resource/Detectors/Sdk.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function getResource(): ResourceInfo
}

if (extension_loaded('opentelemetry')) {
$attributes[ResourceAttributes::TELEMETRY_AUTO_VERSION] = phpversion('opentelemetry');
$attributes[ResourceAttributes::TELEMETRY_DISTRO_NAME] = 'opentelemetry-php-instrumentation';
$attributes[ResourceAttributes::TELEMETRY_DISTRO_VERSION] = phpversion('opentelemetry');
}

return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
Expand Down
Loading

0 comments on commit a325a8f

Please sign in to comment.