Skip to content

chore: switch to SPDX license headers#5177

Open
MikeGoldsmith wants to merge 2 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/spdx-license-headers
Open

chore: switch to SPDX license headers#5177
MikeGoldsmith wants to merge 2 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/spdx-license-headers

Conversation

@MikeGoldsmith
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith commented May 5, 2026

Summary

  • Replace the 13-line Apache 2.0 license header with the 2-line SPDX equivalent (# SPDX-License-Identifier: Apache-2.0) across all Python files
  • Add scripts/check_license_header.py enforcement script and lint-license-header-check tox env to catch missing headers in CI
  • Document the required header format in CONTRIBUTING.md

541 files had their existing Apache header replaced with the SPDX equivalent. During the migration, 31 files were found with missing or inconsistent headers:

  • 15 source/test files had no header at all (e.g. opentelemetry-api/src/opentelemetry/trace/span.py, files in tests/events/, tests/metrics/, shim/tests/testbed/)
  • 4 exporter files had a compact Apache header variant (missing the blank # line after the copyright)
  • 12 scripts and docs/examples files had no header

All of these now have the correct SPDX header. Generated files (*_pb2.py, *_pb2_grpc.py, datamodel-codegen output) and empty __init__.py files are excluded from the check.

Motivation

Other OTel SDKs have already adopted SPDX headers:

  • Go: Already uses SPDX format
  • Java: Already uses SPDX format

The SPDX format is functionally and legally equivalent. It reduces visual noise and aligns Python with the rest of the OTel ecosystem.

Closes #5170

Changes

Area Detail
541 files Replaced standard 13-line Apache header with 2-line SPDX
4 files Fixed compact Apache header variant (missing blank comment line)
15 files Added SPDX header to source/test files that never had one
12 files Added SPDX header to scripts and docs/examples
CI New lint-license-header-check tox env + regenerated lint.yml
Docs Updated CONTRIBUTING.md Style Guide section

Replace the 13-line Apache 2.0 license header with the 2-line SPDX
equivalent across all Python files. Add a CI check to enforce the
header on new files going forward.

Closes open-telemetry#5170

Assisted-by: Claude Opus 4.6
Assisted-by: Claude Opus 4.6


def main():
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit, but you could make this a bit less verbose:

Suggested change
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
root = str(Path(__file__).resolve().parents[1])

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

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Switch to SPDX license headers

2 participants