Skip to content

fix(semconv): repair generate.sh version step and update weaver to 0.28.0 - #1274

Open
MariusCiocanel wants to merge 3 commits into
open-telemetry:mainfrom
MariusCiocanel:fix/semconv-version-sed-noop
Open

MariusCiocanel wants to merge 3 commits into
open-telemetry:mainfrom
MariusCiocanel:fix/semconv-version-sed-noop

Conversation

@MariusCiocanel

Copy link
Copy Markdown
Contributor

Refs #598 (codegen now runs on weaver).

Tooling-only changes to Scripts/semantic-convention/. Generated sources are unchanged: generate.sh at semconv v1.38.0 produces byte-identical output before and after, and after each commit.

1. Fix the silent no-op in the version step (generate.sh)
Since the Swift 6 migration (open-telemetry/opentelemetry-swift-core#30), OpenTelemetry.swift declares public static let version, but the script's final sed matched only public static var version. It matched nothing, exited 0, and never updated the reported spec version. It also used BSD-only sed -i ''. The step now matches var or let, fails with an error when no declaration is found, and uses sed -i.bak, which works with both BSD and GNU sed.

2. Make the template work with newer weaver (SemanticAttributes.swift.j2)
The template strips the namespace from attribute names, which leaves a leading dot (client.address → .address). Newer weaver versions capitalise the word after that dot in camel_case, which would rename every generated identifier (address → Address) and break users. Adding | trim(".") before camel_case fixes it. Output with the current weaver 0.17.1 is unchanged.

3. Bump weaver 0.17.1 → 0.28.0 (generate.sh)
Together with commit 2, output is identical. The comment now points at open-telemetry/weaver.

Not in this PR: updating semantic conventions (v1.38.0 → latest).
weaver.yaml sets exclude_deprecated: true, so every semconv bump removes the Swift constants that upstream deprecated instead of marking them deprecated. For example, v1.39.0 removes Rpc.system and Rpc.gStatusCode, which is a source-breaking change for users. I'd like to discuss at the next SIG whether to keep deprecated attributes (marked @available(*, deprecated)) or accept the breaks with release notes. The semconv bump will follow in a separate PR once that's decided.

Testing

  • bash -n and shellcheck -S warning on generate.sh
  • generate.sh at v1.38.0: no changes under Sources/ with weaver 0.17.1 + new template, and with weaver 0.28.0 + new template
  • Version step on temporary copies with BSD sed and GNU sed 4.9: rewrites let/var, and exits 1 when the declaration is missing
  • swift build --build-tests and swift test pass, with the same test count as main

AI assistance: Claude (Opus 5.5) helped write these changes (Assisted-by trailers). I reviewed and tested them before opening this PR.

🤖 Generated with Claude Code

…o-op

Since the Swift 6 migration, OpenTelemetry.swift declares
`public static let version`, but the final sed step in generate.sh still
matched only `public static var version`. It matched nothing and exited 0,
so the reported spec version was never updated. It also used BSD-only
`sed -i ''`.

Match both `var` and `let`, exit non-zero with an error when no version
declaration is found, and use `sed -i.bak`, which works with both BSD and
GNU sed.

Assisted-by: Claude Opus 5.5
The template strips the root namespace from attribute names, which
leaves a leading dot (`client.address` -> `.address`). Newer weaver
versions treat that dot as a word boundary in `camel_case`, so every
generated identifier would become UpperCamel (`address` -> `Address`)
and Swift keywords would stop being escaped (`_extension` ->
`Extension`).

Trim the dot before `camel_case`. Output with weaver 0.17.1 is
unchanged.

Assisted-by: Claude Opus 5.5
Update the semantic-conventions generator from 0.17.1 to 0.28.0. With
the template fix in the previous commit, generated sources at semconv
v1.38.0 are identical.

Also point the comment at open-telemetry/weaver instead of the old
build-tools repository.

Assisted-by: Claude Opus 5.5
@MariusCiocanel

Copy link
Copy Markdown
Contributor Author

From SIG: Add a parameter to the generate.sh to be able to choose between deleting the old code (e.g in version 3.0.0) or marking the deprecations with @available(*, deprecated) (e.g for 3.1.0)

@williazz

williazz commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Suggestion: can we refactor this pr to 'chore!: upgrade sem conv to x.y.z' , then another pr can update the version to 3.x

@benjoseph-grafana

Copy link
Copy Markdown
Member

@williazz any reason this PR cannot be just updating weaver to the latest version?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants