Skip to content

linting: add depguard rule to enforce semconv version - #8041

Merged
dmathieu merged 5 commits into
open-telemetry:mainfrom
ajuijas:add-semconv-depguard-rule
Mar 12, 2026
Merged

linting: add depguard rule to enforce semconv version#8041
dmathieu merged 5 commits into
open-telemetry:mainfrom
ajuijas:add-semconv-depguard-rule

Conversation

@ajuijas

@ajuijas ajuijas commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a depguard linter rule to .golangci.yml to enforce the use of the latest semantic convention version (v1.40.0).

This rule ensures that:

  • Any new code importing otel/semconv must use v1.40.0.
  • The semconv/ directory itself is excluded from this check to avoid linting legacy definitions.
  • The zipkin exporter is excluded from this check
  • Updated semconv version to v1.40.0 in the sdk/log/logger_bench_test.go test.

Verification Results

I verified this change locally using the following steps:

  1. Full Linter Run: Ran make precommit (which executes golangci-lint run). It passed with 0 issues across the entire repository.
  2. Smoke Test: Added a temporary import of go.opentelemetry.io/otel/semconv/v1.20.0 in trace.go. The linter correctly reported the violation:

    trace.go:7:2: import 'go.opentelemetry.io/otel/semconv/v1.20.0' is not allowed from list 'semconv': Use go.opentelemetry.io/otel/semconv/v1.40.0 instead. (depguard)

This change is not performance-critical and does not affect the library's runtime behavior.

Checklist

  • Signed CLA
  • make precommit passes.
  • CHANGELOG.md updated. (Not required)

Fixes #7842

@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 11, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: dmathieu / name: Damien Mathieu (1df7a66)

@dmathieu dmathieu added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Mar 11, 2026
Comment thread CHANGELOG.md Outdated
Comment thread .golangci.yml Outdated
@codecov

codecov Bot commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.6%. Comparing base (ddd2b0e) to head (1df7a66).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8041   +/-   ##
=====================================
  Coverage   81.6%   81.6%           
=====================================
  Files        304     304           
  Lines      23448   23448           
=====================================
+ Hits       19135   19136    +1     
+ Misses      3927    3925    -2     
- Partials     386     387    +1     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@dmathieu

dmathieu commented Mar 11, 2026

Copy link
Copy Markdown
Member

An exception needs to be added for the zipkin exporter.
Note that you can run the linter locally to ensure your changes work properly.

@ajuijas
ajuijas force-pushed the add-semconv-depguard-rule branch 2 times, most recently from 9dc88ac to aaf0ece Compare March 11, 2026 10:01
@dmathieu

Copy link
Copy Markdown
Member

You force-pushed the wrong commit.

@ajuijas

ajuijas commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

I just messed my local branch with changes in remote :(
I'll fix it and let you know.

- Add Zipkin exporter exception to depguard.
- Update sdk/log benchmarks to use semconv/v1.40.0.
- Remove manual CHANGELOG entry.
@ajuijas

ajuijas commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@dmathieu

Fixed

  • An exception added for the zipkin exporter
  • Updated semconv version to v1.40.0 in the sdk/log/logger_bench_test.go test.
@dmathieu
dmathieu merged commit 88f8c10 into open-telemetry:main Mar 12, 2026
31 checks passed
@pellared pellared added this to the v1.43.0 milestone Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

3 participants