This document describes the tooling and workflow for managing OpenTelemetry Semantic Conventions in the compile-instrumentation project.
Semantic conventions define a common set of attribute names and values used across OpenTelemetry projects to ensure consistency and interoperability. This project uses OTel Weaver to validate and track changes to semantic conventions.
The project's semantic conventions version is tracked in the .semconv-version file at the root of the repository. This file:
- Specifies which semantic conventions version the project intends to abide by
- Must match the
semconvimports used inpkg/instrumentation/**/semconv/Go code - Is validated by CI to ensure consistency
Example .semconv-version file:
v1.30.0
When updating to a new semantic conventions version:
- Update the version in
.semconv-version - Update Go imports in
pkg/instrumentation/**/semconv/to match - Run
make registry-checkto validate - Update code to handle any breaking changes
The semantic conventions tooling requires OTel Weaver. It will be automatically installed when you run the related make targets:
make weaver-installThis installs the weaver CLI tool to $GOPATH/bin. Ensure your $GOPATH/bin is in your PATH.
Validate that the project's semantic conventions adhere to the registry at the specified version:
make registry-checkThis command:
- Reads the version from
.semconv-version - Validates the semantic convention registry at that version
- Reports any violations or deprecated patterns
- Uses the
--futureflag to enable stricter validation rules - This check is blocking - violations will fail CI
When to use: Run this before committing changes to semantic convention definitions in pkg/instrumentation/**/semconv/.
Compare the current version against the latest to see available updates:
make registry-diffThis command automatically:
- Reads the version from
.semconv-version(e.g.,v1.30.0) - Generates a comparison report: Latest (main branch) vs Current version
- Shows what new features and changes are available
Output file: tmp/registry-diff-latest.md
Example output:
Current project version: v1.30.0
Comparing against latest (main branch)...
Available updates (latest vs v1.30.0):
- Added: db.client.connection.state
- Deprecated: net.peer.name (use server.address)
- Modified: http.response.status_code description
...
When to use:
- Understanding what's in your current semconv version
- Deciding whether to upgrade to a newer version
- Reviewing changes before modifying
pkg/instrumentation/**/semconv/
Requirements:
- Network access to GitHub
- OTel Weaver installed (run
make weaver-installfirst)
Generate a resolved, flattened view of the semantic convention registry for your current version:
make semantic-conventions/resolveThis command:
- Fetches the semantic convention registry at the latest version (main branch)
- Resolves all references and inheritance
- Outputs a single YAML file with all definitions
- Saves the output to
tmp/resolved-schema.yaml
To resolve a specific version (e.g., the version you're using):
# Manually resolve for v1.30.0
weaver registry resolve \
--registry https://github.com/open-telemetry/semantic-conventions.git[model]@v1.30.0 \
--format yaml \
--output tmp/resolved-v1.30.0.yaml \
--futureWhen to use:
- Inspecting the complete schema structure
- Searching for specific attribute definitions
- Debugging attribute inheritance or references
- Understanding available attributes before implementing new features
When adding new semantic convention attributes to this project, follow this workflow:
Before defining a new attribute, check if it already exists in the OpenTelemetry Semantic Conventions:
make semantic-conventions/resolve
# Search the resolved schema for your attribute
grep "your.attribute.name" tmp/resolved-schema.yamlIf the attribute doesn't exist upstream (or you need a project-specific attribute):
- Add your attribute definition to the appropriate file in
pkg/instrumentation/**/semconv/ - Follow the OpenTelemetry attribute naming conventions
- Include proper documentation and examples
Example structure:
// pkg/instrumentation/nethttp/semconv/client.go
package semconv
const (
// HTTPRequestMethod represents the HTTP request method.
// Type: string
// Examples: "GET", "POST", "DELETE"
HTTPRequestMethod = "http.request.method"
// HTTPResponseStatusCode represents the HTTP response status code.
// Type: int
// Examples: 200, 404, 500
HTTPResponseStatusCode = "http.response.status_code"
)Run the validation tool to ensure your definitions are correct:
make lint/semantic-conventionsFix any errors or warnings reported by the validator.
Generate a diff report to document your changes:
make registry-diffReview the diff to ensure only expected changes are present.
Ensure your changes don't break existing functionality:
make testWhen submitting a PR with semantic convention changes:
- The CI will automatically run
lint/semantic-conventions - A registry diff report will be generated and posted as a PR comment
- Review the diff report carefully to ensure all changes are intentional
- Address any CI failures before merging
Semantic convention definitions in this project are located in:
pkg/instrumentation/
├── nethttp/
│ └── semconv/ # HTTP semantic conventions
│ ├── client.go
│ ├── server.go
│ ├── util.go
│ └── ...
├── grpc/
│ └── semconv/ # gRPC semantic conventions (future)
│ └── ...
└── .../
These definitions extend or implement the official OpenTelemetry Semantic Conventions for use in compile-time instrumentation.
The project includes automated checks for semantic conventions:
When you modify files in pkg/instrumentation/**/semconv/ or .semconv-version:
This job ensures your code follows the correct semantic conventions version:
- Read Version: Reads the version from
.semconv-versionfile - Validate Consistency: Checks that Go imports in
pkg/instrumentation/**/semconv/match the version in.semconv-version - Registry Validation: Runs
make registry-checkto validate against the registry- This check is blocking - violations will fail the PR
What This Checks:
- The version in
.semconv-versionmatches thesemconvimports in Go code - The semantic conventions registry at that version is valid (no violations)
- Your code adheres to the conventions for your specified version
This job shows what's new in the latest semantic conventions:
- Generate Diff: Runs
make registry-diffto compare current version vs latest - Upload Report: Uploads the diff report as an artifact
- PR Comment: Posts an informational comment showing:
- What new semantic conventions are available
- Whether you're using the latest version
- Suggestions for updating (if desired)
What This Checks:
- Shows available updates (informational only)
- This check is non-blocking - it will never fail your PR
- Helps you stay informed about new conventions without requiring immediate action
When changes are merged to main:
- Read Version: Reads the version from
.semconv-version - Registry Validation: Validates that version's registry to ensure continued compliance
The CI workflow uses the Make targets defined in the Makefile:
make weaver-install: Installs OTel Weavermake registry-check: Validates the registry (blocking check)make registry-diff: Generates diff report (non-blocking check)
This approach:
- Reduces code duplication between CI and local development
- Ensures CI uses the same validation logic as developers
- Makes it easy to run the same checks locally before pushing
Consider updating your semconv version when:
- The "Available Updates" section shows relevant new conventions
- You need new attributes or metrics added in newer versions
- You want to adopt breaking changes or improvements
Steps to update:
- Review the "Available Updates" diff
- Update Go imports in
pkg/instrumentation/**/semconv/:semconv/v1.30.0→semconv/v1.31.0 - Update the version in
.semconv-versionfile - Update code to handle any breaking changes
- Run
make registry-checkto validate the new version - Run tests:
make test
Always prefer existing semantic conventions from the official registry. Only create custom attributes when necessary.
- Use dot notation:
namespace.concept.attribute - Use snake_case for multi-word attributes:
http.response.status_code - Be specific and avoid abbreviations:
client.addressnotcli.addr
Include:
- Clear description of the attribute's purpose
- Expected type (string, int, boolean, etc.)
- Example values
- Any constraints or valid ranges
When updating semantic conventions:
- Check for breaking changes in the diff report
- Update dependent code accordingly
- Update documentation to reflect changes
After modifying semantic conventions:
- Run all tests:
make test - Test with demo applications:
make build-demo - Verify instrumentation still works correctly
If automatic installation fails:
- Check your platform: Weaver supports macOS (Intel/ARM) and Linux (x86_64)
- Manual installation: Download from weaver releases
- Verify installation: Run
weaver --version
Common validation errors and solutions:
- Invalid attribute name: Ensure you follow the dot notation and naming conventions
- Missing required field: Add all required fields (name, type, description)
- Type mismatch: Ensure attribute type matches the expected schema type
- Deprecated pattern: Update to use current semantic convention patterns
If the diff report shows changes you didn't make:
- Check baseline version: Ensure you're comparing against the correct baseline
- Update local registry: Pull latest changes from the semantic conventions repository
- Review upstream changes: Check the semantic conventions changelog
- OpenTelemetry Semantic Conventions
- Semantic Conventions Repository
- OTel Weaver Documentation
- Attribute Naming Guidelines
If you encounter issues with semantic conventions tooling:
- Check the GitHub Issues
- Ask in the #otel-go-compile-instrumentation Slack channel
- Open a new issue with details about your problem