Files
opentelemetry-python-contrib/.github/workflows/package-prepare-patch-release.yml
Teja a025a206da Anthropic agents boilerplate (#4179)
* Add initial implementation of Anthropic Agents instrumentation

- Introduced `opentelemetry-instrumentation-anthropic-agents` package for tracing LLM requests using the Anthropic Python SDK.
- Added support for capturing request and response attributes in accordance with GenAI semantic conventions.
- Included examples for both manual and zero-code instrumentation.
- Created a CHANGELOG.md to document notable changes.
- Added LICENSE and README files for package details and usage instructions.

This commit lays the groundwork for enhanced observability in applications utilizing Anthropic's capabilities.

* Enhance instrumentation for Anthropic Agents

- Added support for the `opentelemetry-instrumentation-anthropic-agents` package, enabling tracing of requests made through the Claude Agent SDK.
- Updated `pyproject.toml` and `tox.ini` to include new test environments and dependencies for the Anthropic Agents instrumentation.
- Modified GitHub workflows to incorporate linting and testing for the new instrumentation.
- Improved documentation in README files and examples to reflect changes in usage and setup.
- Introduced new examples demonstrating both manual and zero-code instrumentation approaches.

This commit strengthens observability for applications utilizing Claude Agents, ensuring comprehensive tracing and logging capabilities.

* Remove outdated entries from CHANGELOG.md for Anthropic Agents instrumentation, streamlining the document to reflect current features and improvements.

* Update Anthropic Agents instrumentation to use Claude Agent SDK

- Changed dependency from `anthropic >= 0.16.0` to `claude-agent-sdk >= 0.1.14` in `README.md`, `pyproject.toml`, and related files.
- Refactored `AnthropicAgentsInstrumentor` to align with the new SDK, including updates to initialization and logging.
- Removed unused utility functions and cleaned up test configurations to reflect the new dependency.
- Updated tests to ensure compatibility with the Claude Agent SDK.

This commit enhances the instrumentation for applications using the Claude Agent SDK, ensuring accurate tracing and logging capabilities.

* Update Python version requirements and clean up workflows for Anthropic Agents instrumentation

- Updated `tox.ini` and `pyproject.toml` to require Python 3.10 or higher, removing support for Python 3.9.
- Cleaned up GitHub workflows by removing outdated test jobs for Python 3.9 and adding new jobs for Python 3.10.
- Updated `README.md` to reflect the new dependency on `claude-agent-sdk` and removed references to the old SDK.
- Made minor code cleanups in example scripts and test files to improve readability.

These changes ensure compatibility with the latest Python versions and streamline the testing process for the Anthropic Agents instrumentation.

* Add Anirudha as a component owner for Anthropic instrumentation.

* fixing precommit errors.

* Update version comment in `version.py` to indicate future stable release

* Refactor imports in `__init__.py` for Anthropic Agents instrumentation.

* regenerate uv.lock file.

* Update uv.lock to standardize package source URLs with trailing slashes

* Rename instrumentation for Anthropic Agents to Claude Agent SDK, updating references in configuration files, workflows, and documentation. Add new files for the Claude Agent SDK instrumentation, including README, examples, and changelog. Ensure proper setup for testing and linting in CI/CD workflows.

* Update release documentation and workflows to include new instrumentation for Anthropic and Claude Agent SDK.

* Add Mike Goldsmith as a component owner for Anthropic and Claude Agent SDK instrumentation

* Revert "Merge remote-tracking branch 'upstream/main' into feat/anthropic-agents-boilerplate"

This reverts commit 7ed01ecb2d, reversing
changes made to 7e83cd7d74.

* Reapply "Merge remote-tracking branch 'upstream/main' into feat/anthropic-agents-boilerplate"

This reverts commit 7714e3c544.

* Update Python version in workflows and adjust dependencies in uv.lock.

* Fix source URLs in uv.lock to ensure proper registry formatting.
2026-02-19 20:57:06 -05:00

137 lines
5.1 KiB
YAML

name: "[Package] Prepare patch release"
on:
workflow_dispatch:
inputs:
package:
type: choice
options:
- opentelemetry-propagator-aws-xray
- opentelemetry-resource-detector-azure
- opentelemetry-sdk-extension-aws
- opentelemetry-instrumentation-openai-v2
- opentelemetry-instrumentation-openai-agents-v2
- opentelemetry-instrumentation-vertexai
- opentelemetry-instrumentation-anthropic
- opentelemetry-instrumentation-claude-agent-sdk
- opentelemetry-instrumentation-google-genai
- opentelemetry-util-genai
description: 'Package to be released'
required: true
permissions:
contents: read
run-name: "[Package][${{ inputs.package }}] Prepare patch release"
jobs:
prepare-patch-release:
permissions:
contents: write # required for pushing branches
pull-requests: write # required for creating pull requests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify prerequisites
run: |
if [[ $GITHUB_REF_NAME != package-release/${{ inputs.package }}/v* ]]; then
echo this workflow should only be run against package-release/${{ inputs.package }}* branches, but is running on $GITHUB_REF_NAME
exit 1
fi
path=./$(./scripts/eachdist.py find-package --package ${{ inputs.package }})
changelog=$path/CHANGELOG.md
if [ ! -f $changelog ]; then
echo "missing $changelog file"
exit 1
fi
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
echo the $changelog is missing an \"Unreleased\" section
exit 1
fi
version=$(./scripts/eachdist.py version --package ${{ inputs.package }})
version_file=$(find $path -type f -path "**/version.py")
file_count=$(echo "$version_file" | wc -l)
if [ "$file_count" -ne 1 ]; then
echo "Error: expected one version file, found $file_count"
echo "$version_file"
exit 1
fi
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
# 1.2.3 or 1.2.3rc1
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
next_version="$major.$minor.$((patch + 1))"
release_branch_name="package-release/${{ inputs.package }}/v$major.$minor.x"
elif [[ $version =~ ^([0-9]+)\.([0-9]+)b([0-9]+)$ ]]; then
# 0.1b1
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
next_version="$major.${minor}b$((patch + 1))"
release_branch_name="package-release/${{ inputs.package }}/v$major.${minor}bx"
else
echo "unexpected version: '$version'"
exit 1
fi
if [[ $GITHUB_REF_NAME != $release_branch_name ]]; then
echo this workflow should only be run against $release_branch_name branch, but is running on $GITHUB_REF_NAME
exit 1
fi
echo "PACKAGE_NAME=${{ inputs.package }}" >> $GITHUB_ENV
echo "VERSION=$version" >> $GITHUB_ENV
echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
echo "VERSION_FILE=$version_file" >> $GITHUB_ENV
- name: Update version
run: |
# replace the version in the version file (1.2.3 -> 1.2.4)
sed -i -E "s/__version__\s*=\s*\"${VERSION}\"/__version__ = \"${NEXT_VERSION}\"/g" $VERSION_FILE
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install tox
run: pip install tox
- name: run tox
run: tox -e generate
- name: Update the change log with the approximate release date
run: |
# the actual release date on main will be updated at the end of the release workflow
date=$(date "+%Y-%m-%d")
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version ${NEXT_VERSION} ($date)/" ${CHANGELOG}
- name: Use CLA approved github bot
run: .github/scripts/use-cla-approved-github-bot.sh
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
id: otelbot-token
with:
app-id: ${{ vars.OTELBOT_APP_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
- name: Create pull request
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
message="Prepare patch release for ${PACKAGE_NAME} v${NEXT_VERSION}"
branch="otelbot/patch-${PACKAGE_NAME}-version-to-v${NEXT_VERSION}"
git commit -a -m "$message"
git push origin HEAD:$branch
gh pr create --title "[$GITHUB_REF_NAME] $message" \
--body "$message." \
--head $branch \
--base $GITHUB_REF_NAME