* pika: added instrumentation for pika.connection.Connection and pika.channel.Channel, thus added instrumentation support to all SelectConnection adapters.
* updated changelog.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Improve asgi instrumentation example
* Fix indentation of asgi instrumentation example
* Improve type hints of asgi instrumentation example
* Ignore pylint too-many-lines
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Update community member listings
* Fix outdated community membership link
---------
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
* resource-detector-containerid: demote failure to read cgroup files to debug
Make the detection more quiet so we can load it on application not
running on linux machines without spamming logs.
* Add changelog
* Allow reraising the root exception if instrumentation fails
I would rather completely fail startup in my services if instrumentation fails for whatever reason instead of just logging an exception and continuing.
Use case:
from opentelemetry import autoinstrumentation
autoinstrumentation.initialize(swallow_exceptions=False)
* Fix lint
* Type hinting, re-raise original exception
* One more type hint to indicate None return
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* opentelemetry-instrumentation-botocore: fix handling of tool input chunked json in converse_stream
We need to accumulate all the tool input as string before decoding it
otherwise we may end up with invalid json.
* Add changelog
* Remove leftover print
* No need for too-many-statements disable
Amazon Bedrock tool use extraction logic doesn't agree with som of the use cases (conversation construction), such as the case with pre-created assistant message:
'messages': [{"role": "user", "content": "Placeholder text."}, {"role": "assistant", "content": "{"}],
This PR addresses this by adding a dict type check on the message content before attempting to get the value of `tool_use`from the content.
* refactor: migrate http_attributes from SpanAttributes to new semantic conventions and refactor tests
* fix precommit linting
* refactor aws lambda to use new semantics
* refactor tests
* update resourceattributes to cloud attrs
* update main for attrs
* ISSUE-3317: Remove maximum version constraint on starlette, by fixing unit tests. Fixed some warnings in unit tests.
* Updae changelog
* Implement code review remarks: update starlette dependencies in bootstrap/test-requirements. Use setUp/tearDown iso decorator on test class
* Increase minimal version of starlette to 0.37.2 to have functional 'oldest' tests.
* add uv.lock
* Revert "add uv.lock"
This reverts commit 08df2bee1e.
* Prevent massive changes of uv.lock due to newer uv which adds upload-time keyword
* Update test-requirements.in file of starlette instrumentation
* fixes
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* fix tests
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* increase delta
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* using same delta as fastapi
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* commit uv.lock back
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* Update CHANGELOG.md
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Update CHANGELOG.md
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* opentelemetry-instrumentation-system-metrics: fix running on Google Cloud Run
psutil fails reading context switches fails on Google Cloud Run, so
before setting up the observable counter trying to read the values check
we are actually being able to do so.
* Please pylint
* Ensure spans end on early stream closure for Bedrock Streaming APIs
* Add changelog
* End span only if it's still recording in stream done callbacks. Assert that span status is unset.
* Extract response output and stream content into helper functions
* Update changelog after 1.33.0 release
* Keep track of bedrock stream ending and close spans accordingly
* Move stream output checks to a single method
* Update CHANGELOG.md
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* fix(grpc): Support non-list interceptors
The GRPC integration assumes that if interceptors are provided, they will be
a list, when GRPC itself types them as Sequence. With this change, we're
making the codepaths using interceptors more robust by explicitly turning them
into lists before manipulating them.
* Add a changelog entry
* .
* Run ruff
* Simplify
* Begin work to instrument tool calls.
* Add tests as well as the ability to record function details in span attributes.
* Add tests for the tool call wrapper utility.
* Update the changelog.
* Reformat with ruff.
* Switch to dictionary comprehension per lint output.
* Address generic names foo, bar flagged by lint.
* Reformat with ruff.
* Update to record function details only on the span.
* Reformat with ruff.
* Fix lint issue with refactoring improvement.
* Reformat with ruff.
* Improve attribute handling and align with 'execute_tool' span spec.
* Pass through the extra span arguments.
* Fix lint issues.
* Reformat with ruff.
* Update instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/tool_call_wrapper.py
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* ref: migrate from SpanAttributes
* B
reverted to SpanAttributes for the SCHEMA_URL
* replace SpanAttributes.SCHEMA_URL
* sort imports
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* refactor(fastapi): migrate HTTP_ROUTE from SpanAttributes to new semantic conventions
Replaced usage of `SpanAttributes.HTTP_ROUTE` with `opentelemetry.semconv.attributes.http_attributes.HTTP_ROUTE`
as part of the migration away from `SpanAttributes`.
Refs: #3475
* refactor(fastapi): refactor tests
* refactor(fastapi): remove duplicated import
* sort imports
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Update botocore instrumentation to use semantic convention attribute for cloud region
* Update changelog
* Move cloud region attribute to the breaking changes in the changelog
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Rough draft of the contribution
* Add connection instrumentation based on the existing pattern.
add a helper function assert_span_count to simplify tests
add unit tests for pipeline hooks
* fix tests to use fake redis
* replace the redis version checks with defines
* Adjust comment and fix one test
* Update documentation with the client method
* Update the changelog
* Update the HTTPX readme to point to proper class method
* Add back the assert_span_count method
* Move the changelog update to the unreleased section
* Remove extra whitespace in the Changelog
* Fix linter complaints
* Remove hasattr assert
* Move the Changelog to Unreleased
* Review comments. Move types to types.py, move some functions to util.py. Tested and verified docs.
* Fix type compatibility
* fix typing and lint
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* Capture server attributes for botocore API calls
* fix: use typing.Dict for 3.8 compatibility and resolve failing tests
* Update changelog
* Add server and port assertions for Bedrock API calls
* Add server address and port to Bedrock metric attributes
* Add license header and deferred type hint evaluation in utils.py
* Refactor metric attributes creation and add linter suppression (too-many-lines) for bedrock.py
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Using click / asyncclick instrumentation in a project that does not
already depend on opentelemetry-instrumentation raises a module
not found error.
Added opentelemetry-instrumentation as a dependency for click &
asyncclick.
* Create a utility to simplify recording request attributes.
* Update recording mechanism to record more request options.
* Improve the recording of span request attributes.
* Reformat with ruff.
* Update TODOs to reflect change made here.
* Update changelog now that PR has been created and can be referenced.
* Fix lint issues.
* Reformat with ruff.
* Add more documentation comments requested in the pull request.
* Add tests and comments that provide some additional clarity regarding the flattening logic in response to PR comments.
* Add tests and comments that provide some additional clarity regarding the flattening logic in response to PR comments.
* Handle corner case where flatten function returns compound output.
* Update prefix to match currently proposed SemConv.
* Update to specify attributes from SemConv constants per PR feedback.
* Use an allowlist for dynamic keys per PR feedback.
* Reformat with ruff.
* Fix lint issues.
* Reformat with ruff.
* Handle flattening errors more gracefully.
* Add support for more wildcards in the allowlist.
* Add a clearer type for the flatten functions.
* Simplify 'exclude_keys' initialization per PR feedback.
* Simplify AllowList constructor type annotation per PR feedback.
* Reformat with ruff.
* Resolve lint error concerning too many returns.
* Reformat with ruff.
* Update name to reflect requested changes in Semantic Conventions pull request #2125.
* Add test to verify correct handling of Unicode.
* Reformat with ruff.
* Remove deuplicated test.
This adds basic request and response gen_ai instrumentation for the following Bedrock model providers:
Cohere Command and Command R, Meta Llama, Mistral AI
* catch ModuleNotFoundError when the library is not installed and prevent exception from bubbling up
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* cleanup
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* remove dup test
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* Update CHANGELOG.md
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* Update version to 1.33.0.dev/0.54b0.dev
* Point CORE_REPO_SHA to opentelemetrybot/update-version-to-1.33.0.dev-0.54b0.dev
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* fix: grpc server ValueError when using unix sockets
with some grpc implementations the full .peer address is available
for unix sockets, which includes the socket path. it seems that
in versions of grpc prior to 1.53.0, the full path is returned by
`context.peer()`. rather than change the dependency of the instrumentation,
this updates it to more gracefully handle the case of the socket path
being present or absent.
Fixes#3393
* add changelog entry
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* botocore: add some more content to the README
This is taken from __init__.py documentation.
* Move the content to the README since it's not really code specific
* Add link to examples
* Apply suggestions from code review
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* botocore: test invokemodel tool calls against amazon nova
* botocore: handle amazon nova tool calls events for InvokeModelWithResponseStream
* Update documentation
* Update Changelog
* Please pylint
* Cleanup
* Reduce branches in tool calls tests
Instead pass down a per-model object that implements the peculiar part.
And fix recording of amazon.nova stream no content test.
* Move stream content extraction for tool calls tests to a couple of helpers
* Add instrumentation example to logging
* Add example output to logging instrumentation example
* Fix logging instrumentation example and output
* Fixing rst syntax for logging instrumentation examples
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Remove bespoke request mocker. Replace with direct mocking of the underlying API.
* Refactor fake credentials to enable reuse.
* Add module to test end to end with a real client.
* Add redaction and minimal OTel mocking/testing in the e2e test.
* Fix wording of the documentation.
* Remove vcr migration from TODOs.
* Improve redaction and test naming.
* Minor tweaks in the code generation. Add casette files.
* Reformat with ruff.
* Fix lint and gzip issue.
* Reformat with ruff.
* Prevent fix for Python 3.9 from breaking tests in other versions.
* Record update in changelog.
* Don't double iterate when redacting by changing the value.
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Handle empty strings
Safer check for a trailing semicolon that could handle
empty strings as well.
* Updated CHANGELOG.md
* Test for empty SQL strings in sqlcommenter
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* instrumentation: rename experimental to development in README
To match the current semantic conventions naming.
* Update generate_instrumentation_readme.py
* Update README.md
* Run generate
* Update the README too
Instead of expecting an entry in a specific bucket, just sum all of them
and assert we have the correct number of entries.
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Begin instrumentation of GenAI SDK.
* Snapshot current state.
* Created minimal tests and got first test to pass.
* Added test for span attributes.
* Ensure that token counts work.
* Add more tests.
* Make it easy to turn off instrumentation for streaming and async to allow for rapid iteration.
* Add licenses and fill out main README.rst.
* Add a changelog file.
* Fill out 'requirements.txt' and 'README.rst' for the manual instrumentation example.
* Add missing exporter dependency for the manual instrumentation example.
* Fill out rest of the zero-code example.
* Add minimal tests for async, streaming cases.
* Update sync test to use indirection on top of 'client.models.generate_content' to simplify test reuse.
* Fix ruff check issues.
* Add subproject to top-level project build mechanism.
* Simplify invocation of pylint.
* Fix 'make test' command and lint issues.
* Add '.dev' suffix to version per feedback on pull request #3256
* Fix README.rst files for the examples.
* Add specific versions for the examples.
* Revamp 'make test' to not require local 'tox.ini' configuration.
* Extend separators per review comment.
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Fix version conflict caused by non-hermetic requirements.
* Fix typo on the comment line.
* Add test for the use of the 'vertex_ai' system, and improve how this system is determined.
* Factor out testing logic to enable sharing with the async code.
* Addressed minor lint issues.
* Make it clearer that nonstreaming_base is a helper module that is not invoked directly.
* Integrate feedback from related pull request #3268.
* Update workflows with 'tox -e generate-workflows'.
* Improve data model and add some rudimentary type checking.
* Accept only 'true' for a true value to align with other code.
* Update the scope name used.
* Add **kwargs to patched methods to prevent future breakage due to the addition of future keyword arguments.
* Remove redundant list conversion in call to "sorted".
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Reformat with 'tox -e ruff'.
* Fix failing lint workflow.
* Fix failing lint workflow.
* Exclude Google GenAI instrumentation from the bootstrap code for now.
* Minor improvements to the tooling shell files.
* Fix typo flagged by codespell spellchecker.
* Increase alignment with broader repo practices.
* Add more TODOs and documentation to clarify the intended work scope.
* Remove unneeded accessor from OTelWrapper.
* Add more comments to the tests.
* Reformat with ruff.
* Change 'desireable' to 'desirable' per codespell spellchecker.
* Make tests pass without pythonpath
* Fix new lint errors showing up after change
* Revert "Fix new lint errors showing up after change"
This reverts commit 567adc62a7.
pylint ignore instead
* Add TODO item required/requested from code review.
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Simplify changelog per PR feedback.
* Remove square brackets from model name in span name per PR feedback.
* Checkpoint current state.
* Misc test cleanup. Now that scripts are invoked solely through pytest via tox, remove main functions and hash bang lines.
* Improve quality of event logging.
* Implement streaming support in RequestsMocker, get tests passing again.
* Add test with multiple responses.
* Remove support for async and streaming from TODOs, since this is now addressed.
* Increase testing coverage for streaming.
* Reformat with ruff.
* Add minor version bump with changelog.
* Change TODOs to bulleted list.
* Update per PR feedback
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Restructure streaming async logic to begin execution earlier.
* Reformat with ruff.
* Disable pylint check for catching broad exception. Should be allowed given exception is re-raised.
* Simplify async streaming solution per PR comment.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Begin instrumentation of GenAI SDK.
* Snapshot current state.
* Created minimal tests and got first test to pass.
* Added test for span attributes.
* Ensure that token counts work.
* Add more tests.
* Make it easy to turn off instrumentation for streaming and async to allow for rapid iteration.
* Add licenses and fill out main README.rst.
* Add a changelog file.
* Fill out 'requirements.txt' and 'README.rst' for the manual instrumentation example.
* Add missing exporter dependency for the manual instrumentation example.
* Fill out rest of the zero-code example.
* Add minimal tests for async, streaming cases.
* Update sync test to use indirection on top of 'client.models.generate_content' to simplify test reuse.
* Fix ruff check issues.
* Add subproject to top-level project build mechanism.
* Simplify invocation of pylint.
* Fix 'make test' command and lint issues.
* Add '.dev' suffix to version per feedback on pull request #3256
* Fix README.rst files for the examples.
* Add specific versions for the examples.
* Revamp 'make test' to not require local 'tox.ini' configuration.
* Extend separators per review comment.
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Fix version conflict caused by non-hermetic requirements.
* Fix typo on the comment line.
* Add test for the use of the 'vertex_ai' system, and improve how this system is determined.
* Factor out testing logic to enable sharing with the async code.
* Addressed minor lint issues.
* Make it clearer that nonstreaming_base is a helper module that is not invoked directly.
* Integrate feedback from related pull request #3268.
* Update workflows with 'tox -e generate-workflows'.
* Improve data model and add some rudimentary type checking.
* Accept only 'true' for a true value to align with other code.
* Update the scope name used.
* Add **kwargs to patched methods to prevent future breakage due to the addition of future keyword arguments.
* Remove redundant list conversion in call to "sorted".
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Reformat with 'tox -e ruff'.
* Fix failing lint workflow.
* Fix failing lint workflow.
* Exclude Google GenAI instrumentation from the bootstrap code for now.
* Minor improvements to the tooling shell files.
* Fix typo flagged by codespell spellchecker.
* Increase alignment with broader repo practices.
* Add more TODOs and documentation to clarify the intended work scope.
* Remove unneeded accessor from OTelWrapper.
* Add more comments to the tests.
* Reformat with ruff.
* Change 'desireable' to 'desirable' per codespell spellchecker.
* Make tests pass without pythonpath
* Fix new lint errors showing up after change
* Revert "Fix new lint errors showing up after change"
This reverts commit 567adc62a7.
pylint ignore instead
* Add TODO item required/requested from code review.
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Simplify changelog per PR feedback.
* Remove square brackets from model name in span name per PR feedback.
* Misc test cleanup. Now that scripts are invoked solely through pytest via tox, remove main functions and hash bang lines.
* Improve quality of event logging.
* Update operation name to use a constant for consistency.
* Reformat with ruff.
* Exclude opentelemetry-instrumentation-google-genai from root uv workspace
Until https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3300 is fixed.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Update doc for OpenAI Instrumentation to support DeepSeek
* Update with Adrian's comments
Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
* rollback the blankspace remove
---------
Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* scripts/generate_instrumentation_bootstrap: don't force genai instrumentations versions
Since genai instrumentations are released on their own we cannot have a
fixed required version on this side.
While at it add vertexai to the list of excluded packages since:
- it has not been released yet
- the name is already claimed by openllmetry
* Regenerate bootstrap_gen
* Please spellcheck
---------
Co-authored-by: Leighton Chen <lechen@microsoft.com>
* opentelemetry-instrumentation-system-metrics: add process metrics
Add process metrics as of 1.30.0 semconv to the system metrics instrumentation.
We still keep around the old process.runtime metrics because the semconv
suggest to not break current users. Still discourage their use in the
doc and state explicitly they are deprecated.
* Add Changelog
* Please pylint
* Apply suggestions from code review
* Remove print
* Remove process.count and fix system metrics enumeration in tests
* Cleanup metrics presence assertions
* Don't touch system metrics descriptions
* Add default for num_cpu in case it returns None to avoid division error
* Use UV to install all needed packages locally
* Add opentelemetry-test-utils
* Add asgi and fastapi
* Add more projects, since it helped me
* add urllib
* Add system metrics
* Add dbapi and sqlite3
* Add sqlalchemy
* add pyramid
* Add pymongo
* Add jinja2
* add lock file
* add falcon as well
* Add uv lock to the pre-commit
* Update uv.lock
* Update lockfile
* remove xray test dependencies
* Add otel-sdk to xray
* Update uv version
* Drop xray from the list of packages
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Follow-up on the apparently abbandonned https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2114.
The asyncpg instrumentation attempts to fall back on using the database
name as the span name in case the first argument to the instrumented
method is falsey.
This has probably never worked since asyncpg defines the `_params`
attribute as an instance of `ConnectionParams`
(https://github.com/MagicStack/asyncpg/blob/master/asyncpg/connection.py#L62)
which is a NamedTuple instance and thus don't define `get`. The proper
way of safely accessing properties on a NamedTuple is using `getattr`.
The only case that I've actually found which triggers this branch is if
the supplied query is an empty string. This is something that causes an
`AttributeError` for `Connection.execute` but is fine for `fetch()`,
`fetchval()`, `fetchrow()` and `executemany()`.
The tests have been expanded to check these cases. Also, more status
code validation has been added where it was missing.
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Create per-extension tracers if there's an extension available
* botocore: add user events for bedrock
* Remove pass of AWS env vars from tox.ini
* Remove handling for other types of messages
* Please pylint
* Add changelog
* Update CHANGELOG.md
Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
---------
Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
* Add Vertex gen AI response span attributes
* Vertex response gen_ai.choice events
* Add todo comment
* Update _map_finish_reason() and use it in span attribute as well
* ruff
* Add basic handling for invoke.model
* Add changelog a please pylint
* Record converse cassettes against us-east-1
* Avoid double copy of streaming body
---------
Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
* Added Vertex AI spans for request parameters
* small fixes, get CI passing
* Use standard OTel tracing error handling
* move nested util
* Actually use GAPIC client since thats what we use under the hood
Also this is what LangChain uses
* Comment out seed for now
* Remove unnecessary dict.get() calls
* Typing improvements to check that we support both v1 and v1beta1
* Add more teest cases for error conditions and fix span name bug
* fix typing
* Add todos for error.type
If we are not running inside AWS Lambda don't print warnings on missing
OTel lambda extension layer.
The instrumentation is installed by the OTel k8s operator and so this
warning may confuse users.
* botocore: add extension for bedrock runtime api
* Add tests and handle only non streaming responses
* Make it explicit we are handling only the converse operation
* Simplify test since all models behaves the same
* Add test for error case and rework things a bit
* Add converse example
* Generate workflows
* Add changelog
* Add type hints to Psycopg
* fix tests
* fix
* Add psycopg.Connection to nitpick
* Add py.typed
* add psycopg to nitpick again
* add psycopg to nitpick again
* move py.typed to the right folder
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Support PEP 561 to `opentelemetry-instrumentation-urllib`
* add future
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* click: ignore click based servers
We don't want to create a root span for long running processes like servers
otherwise all requests would have the same trace id which is unfortunate.
---------
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
* opentelemetry-instrumentation-falcon: expand supported version to v4
Falcon v4 has a mostly identical interface to v3, and is proved to be fully compatible with `opentelemetry-instrumentation-falcon`. Loose the version check to `<5.0.0` to avoid false `DependencyConflict` alarm.
* opentelemetry-instrumentation-falcon: generate tests for v4
* opentelemetry-instrumentation-falcon: prepare tests for v4
* opentelemetry-instrumentation-falcon: add test preset for `~=3.1.2`
* docs: add changelog for Falcon v4 instrumentation
* opentelemetry-instrumentation-falcon: adjust pylint mark for v4
* _has_fixed_http_target property
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* move changelog to the correct section
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* fix test and bootstrap_gen
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: emdneto <9735060+emdneto@users.noreply.github.com>
The copy in markdown file always copy the $ as well when copying the command,
I need to remove the $ manually each time.
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* opentelemetry-sdk-extension-aws: make ec2 resource detector silent when loaded outside AWS
Assume that if we fail to get the token quickly we are not on AWS.
Add "Repository" label to project urls pointing to the
opentelemetry-python repo root url.
Having within project urls one entry with the same value for all
packages released by the project will help tools for automatic
dependency management to suggest coherent upgrades for related packages.
* opentelemetry-sdk-extension-aws: make ecs detector less chatty
Don't print warnings if we are not running inside an ecs instance so we can load the
resource detector more generally and avoid warnings in stderr.
* opentelemetry-sdk-extension-aws: make beanstalk detector less chatty
Don't print warnings if we are not running inside beanstalk so we can load the
resource detector more generally and avoid warnings in stderr.
* Add changelog
* opentelemetry-sdk-extension-aws: make eks detector less chatty
Don't print warnings if we are not running inside an eks instance so we can load the
resource detector more generally and avoid warnings in stderr.
* Update CHANGELOG
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* opentelemetry-instrumentation-openai-v2: coerce openai response_format to semconv format
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
* changelog
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
---------
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
* Add type hints to SQLite3
* Apply suggestions from code review
* Update instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/package.py
* This is a type alias, pylint is dumb
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* CONTRIBUTING: notes abount adding doc for new instrumentation
While at it revise the versioning paragraph to take into account the
openai instrumentation.
* Reword doc paragraph
* Update CONTRIBUTING.md
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* Add autodoc template
* Add notes about tox
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* wrap sqlalchemy.engine.create.create_engine
sqlalchemy.engine_from_config directly calls create_engine imported from that path; if we don't
wrap that copy of the `create_engine` call then engines created via engine_from_config are not
instrumented.
* add changelog entry
* Update CHANGELOG.md
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* Update instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
* make some monkey-patching conditional on the version of SQLAlchemy
* lint
* fix changelog
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* Update CHANGELOG.md
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Remove references to SQLAlchemy engines which are disposed of
EngineTracer in SQLAlchemy keeps weak references to a traced engine forever which
can cause a noticeable memory leak if engines are constantly getting creating.
* Updated changelog
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* starlette: Replace `_meter_provider` by `meter_provider` on `_instrument`
* Add PR on the changelog
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* opentelemetry-instrumentation-httpx: make instrument_client a staticmethod again
* ADd changelog
* Can be a classmethod
---------
Co-authored-by: Leighton Chen <lechen@microsoft.com>
To match the instrumentations.
Will hopefully fix pip not able to handle the situation:
opentelemetry-instrumentation 0.49b0 depends on opentelemetry-semantic-conventions>=0.48b0
opentelemetry-instrumentation-dbapi 0.49b0 depends on opentelemetry-semantic-conventions==0.49b0
* opentelemetry-instrumentation-system-metrics: don't report files descriptors on windows
* Run manually added tox env tests on windows too
* Add jobs for botocore and system-metrics on windows
* Skip open file descriptor test on windows
---------
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
* opentelemetry-instrumentation-openai-v2: format test data as YAML literal block scalar for readability
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
* ruff
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
* Update instrumentation/opentelemetry-instrumentation-openai-v2/tests/conftest.py
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
---------
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
httpx: rewrote patching to use wrapt instead of subclassing client
Porting of httpx instrumentation to patch async transport methods instead of substituting the client. That is because the current approach will instrument httpx by instantianting another client with a custom transport class and this will race with code already subclassing. This one uses wrapt to patch the default httpx transport classes.
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* Added deb to make cassandra tests work with python 3.13
* Bumped cffi to work with Python 3.13
* Fixed some test-requirements for Python 3.13
* Updated typing_extensions everywhere
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Cross-site scripting (XSS) attacks can occur if untrusted input is not escaped. This applies to templates as well as code. The jinja2 templates may be vulnerable to XSS if the environment has autoescape set to False. Unfortunately, jinja2 sets autoescape to False by default. Explicitly setting autoescape to True when creating an Environment object will prevent this.
Signed-off-by: Rajendran, Ramasubramanian <Ramasubramanian.Rajendran@fmr.com>
* fix httpserverduration and httpserverrequestduration
Signed-off-by: Steven Pan <jianqiao.pan@fmr.com>
* add change log
---------
Signed-off-by: Steven Pan <jianqiao.pan@fmr.com>
Congratulations and welcome @aabmass and @xrmx as new Python maintainers! We greatly appreciate your help and expertise.
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Fixing w3c baggage support in opentelemetry-instrumentation-aws-lambda
* Changelog update
* Passing context not needed
* Fixing unit test after rebase
* Update version to 1.27.0.dev/0.48b0.dev
* Update SHA and fix test cases
* Update SHA
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* fix schema url in instrumentation tests
* change core repo sha for test
* Update CORE_REPO_SHA
* Try removing cache
* Clear cache here as well
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* instrumentation/asyncio: catch CancelledError exception in tests
After a29242f493 we are re-raising the
CancelledError so we need to catch it on the caller side.
Fix#2688
* instrument/asyncio: don't test anext on python < 3.10
Since it's not available there.
* instrumentation/asyncio: use unittest.skipIf instead of reimplementing it
---------
Co-authored-by: Leighton Chen <lechen@microsoft.com>
* requirements: bump zipp to 3.19.2
To resolve a dependabot securiy report.
* requirements: bump certifi to 2024.7.4
To resolve a dependabot security report.
* Remove unnecessary dependencies
Fixes#2661
* Separate runs
* Remove dev-requirements from test environment
* Try without negative if
* Remove positive if
* Remove if
* Separate benchmark-containing packages in another file
* Add missing test-requirements.txt file
* Support cursor based queries
* Add unit test
* Start of a test case
* Update tests
* Mock out all connection stuff
* Run black
* Fix typo
* Use old python
* Run black on the tests
* Add changelog
* Fix sorting
* Use python 3.8 as baseline
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Do not run benchmark tests in CI
Fixes#2659
* Add benchmark skip
* Update .github/workflows/test.yml
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Point pylint to the root directories
Fixes#2657
* Use cd with instrumentations
* Do the same for the rest of the components
* Specify pylint configuration file
* Fix tox lint for sio-pika
* Fix commands for util-http and azure detector
* Fix lint for sdk-extension-aws
* Fix lint for opentelemetry-instrumentation
* Fix lint for grpc instrumentation
* Fix lint for opentelemetry-instrumentation
* confluent_kafka: update instruments version declaration to include 2.4.0
* Adjust CHANGELOG.md with actual PR number
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* botocore: remove random packages from test-requirements
Refs #1736
* boto: remove random packages from test requirements
Refs #1736
* tox: re-enable boto3sqs tests with pypy3
* threading: remove confluent-kafka from test requirements
* fix: Ensure compability with Psycopg3 to extract libpq build version
Struggling with getting dbapi and psycopg3 working.
Think this is the error, __libpq_version does not exist on psycopg3
https://github.com/psycopg/psycopg/blob/master/psycopg/psycopg/pq/pq_ctypes.py#L1220
* docs: Add changelog entry
* docs: Fix spelling
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Calling the exception() method when future is in the cancelled state is causing a CancelledError
Calling the exception() method when future is in the cancelled state is causing a CancelledError. we should check the cancelled state first and call f.exception() only if it's not cancelled.
* modify lint
* modify lint
* Update CHANGELOG.md
* remove init()
* add future cancelled test code
* add future cancelled test code
* add future cancelled test code
* add future cancelled test code
* add future cancelled test code
* add future cancelled test code
* lint
* lint
* remove if condition
* modify test code
* lint
* lint
* remove pytest
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Refactor bootstrap generation
This makes the bootstrap script get the package version directly from
pypi instead of from our lists of packages. This makes sure that the
packages are actually available for the end user to install.
Fixes#2053
* Fix lint
* Fix lint
* Remove aiohttp
* Add missing dependency for aiohttp-client
* Use hatch version
* Separate lint for flask
* Seaparate lint for resource-detector-container
* Add linting workflow
* Update contributing documentation
* Fix lint workflow
* Add fix for resource-detector-container
* Separate lint for sdk-extension-aws
* Separate lint for distro
* Separate lint for opentelemetry-instrumentation
* Separate lint for aiohttp-client
* Separate lint for aiohttp-server
* Separate lint for aiopg
* Separate lint for aws-lambda
* Separate lint for botocore
* Separate lint for boto3sqs
* Separate lint for django
* Separate lint for dbapi
* Separate lint for boto
* Separate lint for elasticsearch
* Separate lint for falcon
* Separate lint for fastapi
* Separate lint for urllib
* Separate lint for urllib3
* Separate lint for requests
* Separate lint for starlette
* Separate lint for jinja2
* Seaparate lint for logging and richconsole
* Separate lint for prometheus-remote-write
* Separate lint for mysql
* Separate lint for mysqlclient
* Separate lint for psycopg2
* Separate lint for psycopg
* Separate lint for pymemcache
* Separate lint for pymongo
* Separate lint for pymysql
* Separate lint for pyramid
* Separate lint for asgi
* Separate lint for asyncpg
* Separate lint for sqlite3
* Separate lint for wsgi
* Separate lint for grpc
* Separate lint for sqlalchemy
* Separate lint for redis
* Separate lint for remoulade
* Separate lint for celery and sklearn
* Separate lint for system-metrics
* Separate lint for threading
* Separate lint for tornado
* Separate lint for tortoiseorm
* Separate lint for httpx
* Separate lint for propagator-aws-xray
* Remove lint
* Separate lint for propagator-ot-trace
* Separate lint for sio-pika
* Separate lint for aio-pika
* Fix aio and sio pika
* Separate lint for kafka-python
* Separate lint for confluent-kafka
* Separate lint for asyncio
* Separate lint for cassandra
* Separate lint for processor-baggage
* Remove lint test environment
* Rename lint workflow file
* Fix sio-pika lint testing package path
* More fixes
* Fix linting for opentelemetry-instrumentation
* Add section for linting with 3.8
* Add missing lint install command for elasticsearch
* Sorted packages
* Fix exception handling for events with requestContext
* added entry to changelog
* reformatted with black
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* - fixed compatibility issue in set_channel of span_builder.py
- changed test-requirements-2.txt to use aio-pika==9.0.5
- added test-requirements-3.txt to use aio-pika==9.4.1 (latest atm)
- tox.ini: fixed incorrect commands_pre which would always install test-requirements-2.txt and cause dep installation conflict
- tox.ini: added aio-pika-3 commands
* Add version comment for aio-pika
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version
The SqlAlchemy commenter is currently using the library version in the comment it emits, e.g.:
```
{
'db_driver': 'psycopg2',
'db_framework': 'sqlalchemy:0.45b0'
}
```
We should instead be using the sqlalchemy version here, as SqlCommenter did before
* Fix lint
* Fix lint
* Add CHANGELOG entry
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* [boto3sqs] Instrument `Session` and `resource`
This commit addresses the following open issues:
- https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1699
- https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1996
There are four ways to access the SQS API via `boto3`:
- `client = boto3.client("sqs")`
- `client = boto3.Session().client("sqs")`
- `sqs = boto3.resource("sqs")`
- `sqs = boto3.Session().resource("sqs")`
The existing wrapper tied into `boto3.client` to wrap a generated `botocore.client.SQS` class.
The change here covers the three missing initialization methods.
* update changelog
* rename duplicate test methods
* implement uninstrument
* [boto3sqs] Reduce number of wrapper targets
There are actually 6 ways to initialize a boto3 API object.
```py
boto3.client() # Using default global session
boto3.resource() # Using default global session
boto3.Session().client() # Using "re-exported" session.Session
boto3.Session().resource() # Using "re-exported" session.Session
boto3.session.Session().client() # Using session.Session directly
boto3.session.Session().resource() # Using session.Session directly
```
We only have to patch `session.Session.client` to catch all the cases.
- b3c158c62a/boto3/session.py (L217-L229)
- b3c158c62a/boto3/session.py (L446-L457)
* Remove unused import
---------
Co-authored-by: Matt Oberle <mattoberle@users.noreply.github.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* feat(pika): adding support for channel.consume instrumentation
* updated changelog
* wip tests
* updating docs
* more tests
* removing span member on object proxy
* adding test for ReadyMessagesDequeProxy
* adding tests
* better comment on span.end()
* fixing docs
* ending span even on exceptions
* feat: add opentelemetry-instrumentation-threading library
* fix: update python file with black formatter
* fix: modified title underline too short issue
* fix: modified library sorted via isort tool
* fix: modified CHANGELOG.md and remove unused parameter
* test: migrated unit test cases from the #1582 to this project
* chroe: updated the tox.ini test commands
* fix: fixed the lint issue
* feat: support ThreadPool and update document
* fix: fixed the lint issue
* refactor: remove redundant class and simplify capture OTel context usage
* fix: removed unused parameter
* test: added a new test case for thread pool
* fix: remove unused return response
* refactor: compared the array
* fix: remove f-string
* fix: fixed pylint issue
* fix: test library
* fix: updated CHANGELOG.md
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* fix: retain httpx.URL type on request.url
This fixes a regression caused in #2020 where request.url stopped being of `httpx.URL` type, causing issues with request/response hooks.
* Update CHANGELOG.md
* tests: adding assertions to verify request.url on hooks is a httpx.URL
* fixup: adjust check to consider httpx < 0.20.0
* fixup: keep code dry
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* elasticsearch: don't set body as db statement for bulk requests
bulk requests can be too big and diverse to make sense as db statement.
Other than that the sanitizer currently only handles dicts so it's
crashing.
Closes#2150
Co-authored-by: Jason Mobarak <git@jason.mobarak.name>
Co-authored-by: Quentin Pradet <quentin.pradet@gmail.com>
* Update CHANGELOG
* Please the linter
---------
Co-authored-by: Jason Mobarak <git@jason.mobarak.name>
Co-authored-by: Quentin Pradet <quentin.pradet@gmail.com>
* feat: add http.duration convention
* feat: add http.duration convention
* feat: replace for the last description version Duration of HTTP client requests
* feat: add new description to histogram
Response hook receives a third parameter, Response, and that should be reflected in the _ResponseHook type
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* aiopg: fix runtime warnings when running tests
Fixes:
RuntimeWarning: coroutine 'MockCursor.execute' was never awaited
cursor.execute(query)
* aio-pika: no need to return an awaitable in mocked method
No need to return an awaitable since the mocked method awaits
itself.
Fixes:
RuntimeWarning: coroutine 'sleep' was never awaited
---------
Co-authored-by: Leighton Chen <lechen@microsoft.com>
* chore: fix md based on rules and fix bad links
* chore: add index to contribuiting and readme files
---------
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* * Adding (failing) testcase to cover Issue #2029
* * move Instance variables to class variables. Since the object in question will be a singelton. This will resolve#2029 where multiple calls to the instrumentation will assign Null values.
* * black formatting
* * Changelog stub entry, PR # to follow
* * updating the pullrequest number
* * remove superfluous constructor
* * moving Change log to unreleased section
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
In the test dependencies for `opentelemetry-instrumentation-falcon`,
don’t depend on `parametrized` because `pytest.mark.parametrize` is now
included in `pytest`.
These files do not have the executable bit set in their filesystem
permissions (so the shebang line, `#!`, is useless), and they are not
script-like (do not have `if __name__ == "__main__"` or interesting
side-effects), so making them executable would not make sense.
* support flask 3.0.0
* support flask 3.0.0
* support flask 3.0.0
* modify tox.ini
* modify Werkzeug version
* modify Werkzeug version
* modify flask test version
* modify flask version
* modify flask version
* modify CHANGELOG.md
* include feedback
* include feedback
* Fix lint and generate
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Clean up use of suppress_instrumentation in context and fix httpx bug
* Clean up use of suppress_instrumentation in context and fix httpx bug
* changelog
* fix tests
* fix import
* fmt
* update dep
* lint
* remove unused imports
* apply lint
* Fix version for pika
* Fix lint
---------
* aio-pika instrumentation: Removed check for non-sampled span when inject message headers. Reason to change is that sampled flag can be propagate https://www.w3.org/TR/trace-context/#sampled-flag and be useful when trace is not sampled.
* black formting
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* fix: sync response hooks being used on httpx.AsyncClient
* docs: add changelog
* docs: improved docs a bit more
* docs: fix variable name
---------
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Fix black an isort
* change bootstrap_gen to use a list instead of dict
* Bunch of updates
* Fix build
* fix lint
* Fix docs
* Fix lint
* More fixes
* Fix lint
* fix stupid mistake
---------
Co-authored-by: Christian Hartung <christian.hartung@olist.com>
* Set metric descriptions per semantic conventions
* Set metric descriptions per semantic conventions
* fix spelling
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Added support for pypy3 system metrics
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
* Change in if condition to log warn message for pypy
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
* Added logger to else block if pypy
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
* Reverting the changes
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
* Changes requested by external reviewer
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
---------
Signed-off-by: Rahul Kumar <Rahul.Kumar@fmr.com>
Co-authored-by: Suryanarayana Peri <suryanarayana.peri@fmr.com>
* Unwrap `ExceptionInfo` and `ExceptionWithTraceback`
Instead of reporting the `ExceptionInfo` and `ExceptionWithTraceback`
wrappers raised by Celery, report the exceptions that they wrap.
This ensures that the exception in the OpenTelemetry span has a type
and traceback that are meaningful and relevant to the developer.
* Fix typo
The exception is expected, not excepted. Well, I guess it is also
excepted, because it's an exception, but you get what I mean.
* Reformat file with `black`
Reformat the `__init__.py` file in the Celery instrumentation using
`black`, fixing a CI linter error.
* Address review feedback
Use the VERSION attribute exposed by Billiard to decide whether to
import ExceptionWithTraceback.
Add a test for a failing task and check that the exceptions' type
and message are preserved.
* Amend ExceptionWithTraceback import
* Use a weak reference to sqlalchemy Engine to avoid memory leak
Closes#1761
By using a weak reference to the `Engine` object, we can avoid the memory leak as disposed `Engines` get properly deallocated. Whenever `SQLAlchemy` is uninstrumented, we only trigger a removal for those event listeners which are listening for objects that haven't been garbage-collected yet.
* Made a mistake in resolving the weak reference
* Fixed formatting issues
* Updated changelog
* Added unit test to check that engine was garbage collected
* Do not save engine in EngineTracer to avoid memory leak
* Add an empty line to satisfy black formatter
* Fix isort complaints
* Fixed the issue when pool name is not set and =None
* Fix formatting issue
* Rebased after changes in a recent commit
* Updated PR number in changelog
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* fix(grpc): Allow gRPC connections via Unix socket
This commit addresses issue #1832.
The way `NET_PEER_IP` and `NET_PEER_PORT` are retrieved raises a `ValueError`
when gRPC connections are handled via Unix sockets.
```py
ip, port = (
context.peer().split(",")[0].split(":", 1)[1].rsplit(":", 1)
)
```
When using an address like `unix:///tmp/grpc.sock` the value of `context.peer()` is `"unix:"`.
Substituting that in the function above...
```py
ip, port = "unix:".split(",")[0].split(":", 1)[1].rsplit(":", 1)
ip, port = ["unix:"][0].split(":", 1)[1].rsplit(":", 1)
ip, port = "unix:".split(":", 1)[1].rsplit(":", 1)
ip, port = ["unix", ""][1].rsplit(":", 1)
ip, port = "".rsplit(":", 1)
ip, port = [""] # ValueError
```
I "addressed" the issue by guarding the retrieval of `net.peer.*` values under
an `if` statement that checks if we are using a Unix socket.
I extended the `server_interceptor` tests to run against TCP and Unix socket configurations.
---
**Open Questions**
- [ ] The socket tests will fail on Windows. Is there a way to annotate that?
- [ ] Are there other span values we should be setting for the unix socket?
* Update CHANGELOG
* Add placeholder attributes for linter
* fix lint
---------
Co-authored-by: Matt Oberle <mattoberle@users.noreply.github.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Add http.server.response.size metric to ASGI implementation.
Add new unit tests.
* Update changelog.
* Fix linting by disabling too-many-nested-blocks
* Put new logic in a new method
* Refactor the placement of new logic.
* Fixed the unit tests in FastAPI and Starlette
* Update changelog.
* FIx lint errors.
* Refactor getting content-length header
* Refactor getting content-length header
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Add support for confulent_kafka until 2.1.1 version
* Include 2.1.1 version
* update CHANGELOG.md
* run: 'tox -e generate'
* resolve comments
* update top version to 2.2.0
---------
Co-authored-by: Ran Nozik <ran@gethelios.dev>
* corrected instrumentation example in urllib3
* Remove changelog entry
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Fix falcon usage of Span Status to only set the description if the status code is ERROR
* Update changelog
* Update CHANGELOG.md
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* fix lint
* Use fewer variables to satisfy R0914 lint rule
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Refactor CODEOWNERS file
Fixes#1803
* Remove CODEOWNERS
* Refactor component owners configuration
* Refactor CODEOWNERS to select any file but the ones in instrumentation
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
* Add otelTraceSampled to instrumetation-logging
* Updated code with black
* Added to CHANGELOG.md
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* WIP
* Revert "WIP"
This reverts commit 3ed466348e4c172fd96569a0dcb1b15047760cef.
* Fix expected URL in aiohttp instrumentation test
The underlying cause of the issue here is the update of the yarl package
from 1.8.2 to 1.9.1. yarl is used as a dependency in the
opentelemetry-instrumentation-aiohttp package but it is not there where
the issue happens, but in aiohttp who also has yarl as a dependency.
This is why the fix does not touch any relevant part of any
opentelemetry-* code, since it is the return value of aiohttp code who
now has a different value for the URL.
Fixes#1770
* Allow Kafka producer headers to be dict or list
* modify kafka context getter helper methods to work on dict and list
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Add a test case to reproduce the issue
* Fix the class initialization when parameters are provided
* Update CHANGELOG.md
* Fix linting issues
* Additional test case which inits SystemMetricsInstrumentor twice
* Updated linting following update to black style
* Moved changelog entry to unreleased section
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Several issues have arisen from this bugfix, reverting here until a
better solution can be found.
Fixes#1658
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Support aio_pika 8
- Fix tests for new shape of the AbstractConnection class
- Run tests against aio_pika 7 and 8
* Update CHANGELOG.md
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Audit and test opentelemetry-instrumentation-aiopg NoOpTracerProvider
* Change line length
---------
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* add a test for aws lambda using NoOpTracerProvider
* fix import
* add assert for spans
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Add Redis instrumentation query sanitization
Add a query sanitizer to the Redis instrumentation. This can be disabled
with the `sanitize_query = False` config option.
Given the query `SET key value`, the sanitized query becomes `SET ? ?`.
Both the keys and values are sanitized, as both can contain PII data.
The Redis queries are sanitized by default. This changes the default
behavior of this instrumentation. Previously it reported unsanitized
Redis queries.
This was previously discussed in the previous implementation of this PR
in PR #1571Closes#1548
* Update Redis sanitize_query option documentation
Changes suggested in
https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1572#discussion_r1066069584
* Remove uninstrument & instrument from test setup
The Redis test that performs the tests with the default options, doesn't
need to uninstrument and then instrument the instrumentor. This commit
removes the unnecessary setup code. The setup code is already present at
the top of the file.
* Fix code style formatting
* Update Redis functional tests
- Update the sanitizer to also account for a max `db.statement`
attribute value length. No longer than 1000 characters.
- Update the functional tests to assume the queries are sanitized by
default.
- Add new tests that test the behavior with sanitization turned off.
Only for the tests in the first test class. I don't think it's needed
to duplicate this test for the clustered and async setup combinations.
* Test Redis unsanitized queries by default
Change the Redis functional tests so that they test the unsanitized
query by default, and test the sanitized query results in the separate
test functions.
This is a partial revert of the previous commit
8d56c2f72e
* Fix formatting issue in Redis utils
* Disable Redis query sanitization by default
Update the Redis instrumentation library to not change the default
behavior for the Redis instrumentation. This can be enabled at a later
time when the spec discussion about this topic has concluded.
https://github.com/open-telemetry/opentelemetry-specification/issues/3104
* Fix pylint issue
Remove else statement.
* Update changelog about Redis query sanitization default
[ci skip]
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Fix potential error on Redis args being 0
Check the length of the args array and return an empty string if there
are no args.
That way it won't cause an IndexError if the args array is empty and it
tries to fetch the first element, which should be the Redis command.
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Add tests for errors in Celery tasks
I noticed there were no tests for the error scenario in the Celery
package. This commit adds a basic test, based on the previous test and
how I see other packages test the error status on the span.
Part of #987
* Record exception in Celery instrumentation
In addition to setting the status on the span, also record the exception
on the span. This adds an event to the span with more details about the
error, following the format other instrumentations also use.
* Update CHANGELOG with Celery record exception
* Fix lint code formatting issues
* Move Celery error tests to the functional tests
The celery tests failed on Python 3.11. This is most likely due to this
issue in billiard, a celery dependency, about it not working on Python
3.11 because of the error reported in the CI:
https://github.com/celery/billiard/issues/377
It's been fixed in billiard 4.1.0, but celery is locked on billiard
version lower than 4, so it cannot use this version with the fix.
This issue does not arise on the Docker tests, because they use Python
3.9.16.
I've moved the error test span event assertions to the error test that
is available in the functional tests, and removed the unit test. That
way, the build will run successfully.
* Remove duplicate entry in changelog
This was added in a recent merge commit on this PR branch.
* Remove unused test code
With the move of the tests for tasks with errors to the functional
tests, remove the unit test's error task and unused imports.
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Fix install of Python 3.10 on GitHub Actions
In PR #1604 the Python version was upgraded to Python 3.10 to fix a
local issue on M1 MacBooks.
The GitHub Action workflows now exit with the following message for the
docker-tests, spellcheck and lint checks, skipping these checks.
```
lint create: /home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/lint
SKIPPED: InterpreterNotFound: python3.10
___________________________________ summary ____________________________________
SKIPPED: lint: InterpreterNotFound: python3.10
congratulations :)
```
Upgrade the Python version in the GitHub Actions workflow to fix this.
* Fix YAML interpretation of Python 3.10
* Upgrade Docker tests dependencies
Upgrade the asyncpg and psycopg2 packages, they don't work on Python
3.10.
This also fixes running these tests no M1 MacBooks.
* Fix linter issues merged into main
They went unnoticed while the CI didn't fail on the lint task not
working.
---------
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Flush meter provider at end of lambda function handler
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update `force_flush()` check based on PR feedback
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
---------
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Adds an option to configure `disable_aws_context_propagation` by environment variable
The variable `OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION` can be used to disable aws context propagation. This is similar to the proposed changes in the JS implementation: https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1227
Signed-off-by: Alex Boten <aboten@lightstep.com>
* update changelog
* Apply suggestions from code review
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Minor refactoring across multiple instrumentation libraries
* Reformat using black
* Put span_kind back in aws_lambda
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* `opentelemetry-instrumentation-aws-lambda`: Adding option to disable context propagation
Adding the following option to disable context propagation `disable_aws_context_propagation`. This is similar to the disableAwsContextPropagation option in the nodejs instrumentation.
* update changelog
* lint
* more lint
* fix kafka: wait for metadata
Kafka's instance metadata could be unavailable (because it's being filled asynchronously). extract_send_partition() is based on a metadata, so it may return `None` for partition and later cause all type of warning messages (e.g. `Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types`).
The proposed fix makes sure metadata is pre-populated (based on 4d598055da/kafka/producer/kafka.py (L579)).
I'm just not sure if we should wrap `_wait_on_metadata` into try\except, maybe just passing Exception to the caller would be a better idea...
* upd: changelog
* fix: changelog
* fix: import KafkaErrors
* fix: tox -e lint errors
* fix: refact and added unit test
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Fixes https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1353
Also:
Fix the check for the connection already being instrumented in instrument_connection()
Add tests for commit() and rollback()
Add a couple missing docstring items.
Add basepython to docker-tests to fix running the tests on macOS.
* boto3sqs: Fix various issues
* do not use 'otel' prefix for propagation keys to make propagation
compatible with other SQS instrumentations like Node.Js
Inject propergator.fields keys into the MessageAttributeNames argument
for 'receive_message' calls to retreive the corresponding message attributes
* add 'messaging.url' span attribute to SQS spans
* add boto3sqs instrumentation to tox.ini to run tests in CI
* add some basic unit tests
* changelog
* fix linting issues
* unset instrumented flag on uninstrument
* Use a shorter timeout for AWS EC2 metadata requests
Fix#1088
According to the docs, the value for `timeout` is in seconds: https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen. 1000 seconds seems slow and in some cases can block the startup of the program being instrumented (see #1088 as an example), because the request will hang indefinitely in non-AWS environments. Using a much shorter 1 second timeout seems like a reasonable workaround for this.
* add changelog entry for timeout change
* use 5s timeout for ECS and EKS, update changelog
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* Add Ashutosh Goel and Sanket Mehta to approvers
Fixes#1053Fixes#1054
* Adding company name for ashu658
* adding company name for sanketmehta28
Co-authored-by: Ashutosh Goel <39601429+ashu658@users.noreply.github.com>
Co-authored-by: sanket Mehta <sankmeht@cisco.com>
* code change to add custom http and websocket request and response headers as span attributes. Issue: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/919
* adding entry to changelog
* changes after running "tox -e generate" locally
* - added server_span.is_recording() in _get_otel_send() just to make sure the span is recording before adding the attributes to span.
- changed span to current_span to make sure attributes are being added to proper span.
* removed commented code
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* [instrumentation/wsgi] fix NonRecordingSpan bug
There was a bug caused by accessing `.kind` on a NonRecordingSpan. Added a test to validate the fix.
Fix#956
* fix lint
* use is_recording
* fix lint
* fix lint
* fix lint
We replace Falcon API class with a partial callable. It is safer to
replace it with a sub-class of the base falcon.API class so any other
systems making assumptions about falcon don't fail.
* code changes to resolve conditional server span creation for WSGI (https://github.com/open-telemetry/opentelemetry-python-contrib/issues/454)
* Adding entry to changelog.md
* modifying _start_internal_or_server_span() to add attributes as a parameter. Also calling _start_internal_or_server_span() in WSGI instrumentation
* resolving flake8 and typo issues
Now service name is extracted from the provider defensively and lazily.
This accounts for an SDK that does not provide access to "resource" via
TracerProviders and for lazy initialization of TracerProviders.
Fixes#810
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* adding unit test case for ASGI framework for application wrapped with another framework
* resolving lint errors
* resolving generate build errors
* resolving flake errors
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
* Adding unit tests for conditional server span creation in starlette
* Adding changelog entry and renaming function
* Update CHANGELOG.md
Removing changelog entry
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
_start_internal_or_server_span function for flask, pyramid and django
Adding changelog entry
Adding unit test and fixing lint errors
Refactoring to use _start_internal_or_server_span function
Removing unwanted imports and variables
Fixing lint errors
adding changes from tox -e generate
Fixing build errors
* add note about monthly cadence
Update the release section of the readme to include the monthly cadence of releases.
Fixes#457
* add note about monthly cadence
Update the release section of the readme to include the monthly cadence of releases.
Fixes#457
* code change to resolve the bug https://github.com/open-telemetry/opentelemetry-python-contrib/issues/449
* modifying the changelog file to add entry for PR #869
* removing redundent get statement
* Conditionally create server spans for falcon (#867)
* Making span as internal for falcon in presence of a span in current context
* Updating changelog
* Fixing lint and generate build failures
* Resolving comments: Converting snippet to re-usable function
* Fixing build failures
* Resolving comments: Creating wrapper for start span to make internal/server span
* Rerun docker tests
* Resolving comments: Refactoring
* Fix Django 1.9 issue preventing use of MIDDLEWARE_CLASSES (#870)
* Update CHANGELOG.md
* Fix Django 1.9 issue preventing use of MIDDLEWARE_CLASSES
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
* changing the import trace statement to resolve issue with unit test cases
Co-authored-by: Ashutosh Goel <39601429+ashu658@users.noreply.github.com>
Co-authored-by: Dan <pezzer55@gmail.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Owais Lone <owais@users.noreply.github.com>
* Making span as internal for falcon in presence of a span in current context
* Updating changelog
* Fixing lint and generate build failures
* Resolving comments: Converting snippet to re-usable function
* Fixing build failures
* Resolving comments: Creating wrapper for start span to make internal/server span
* Rerun docker tests
* Resolving comments: Refactoring
* Code changes and pytests for https://github.com/open-telemetry/opentelemetry-python-contrib/issues/448
* removing unnecessary imports
* removing unnecessary imports
* adding wsgi.py file to get the wsgi application object
* Revert "Updating personal fork from public repo"
* Revert "Updating personal fork from public repo"
* Revert "Updating personal fork from public repo"
* Revert "Updating personal fork from public repo"
* Changing the unit test case by removing WSGI instrumentation and make it from generalised
* removing unnecessary import statements
* Revert "Updating personal fork from public repo"
* resolving failed builds for lint and generate
* removing commented code
* removing blank line
* removed unused variable resp from test_middleware.py and modified the CHANGELOG.md with PR entry
* modified the CHANGELOG.md to removed unnecessary entry
* modified the CHANGELOG.md to add proper PR entry
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
This asgi version is modeled after the original wsgi version in #436 and corresponds to the SERVER span. Also cleans up some of the existing ASGI functionality to reduce complexity and make future contributions more straightforward.
* feat: support older pika versions
* update tox.ini
* update changelog
* take version from pika
* avoid exception when property name changes
* add callback attr name test
* Include propagator benchmarks + latest GH action
* When we moved the aws-xray propagator in #720, we needed to update the benchmark step of the workflow
* Additionally, the GH action has evolved since we added benchmarks so we should use the latest version
* Merge all parallel benchmarks after they complete
* Making span as internal in presence of a span in current context
* Updating changelog
* Removing extra print statements
* Resolving comments: Setting current context as parent in its presence
* Ignoring pylint check as django.conf.urls.url is removed in django 4.0
Django release notes: https://docs.djangoproject.com/en/4.0/releases/4.0/
* Removing changes in django files
**Describe your environment** Describe any aspect of your environment relevant to the problem, including your Python version, [platform](https://docs.python.org/3/library/platform.html), version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
**Steps to reproduce**
Describe exactly how to reproduce the error. Include a code sample if applicable.
Thanks for taking the time to fill out this bug report! Please make sure to fill out the entire form below, providing as much context as you can in order to help us triage and track down your bug as quickly as possible.
Before filing a bug, please be sure you have searched through [existing bugs](https://github.com/open-telemetry/opentelemetry-python-contrib/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug) to see if your bug is already addressed.
- type:textarea
id:environment
attributes:
label:Describe your environment
description:|
Please describe any aspect of your environment relevant to the problem, including your Python version, [platform](https://docs.python.org/3/library/platform.html), version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
value:|
OS:(e.g, Ubuntu)
Python version:(e.g., Python 3.9.10)
Package version:(e.g., 0.46.0)
- type:textarea
attributes:
label:What happened?
description:Please provide as much detail as you reasonably can.
validations:
required:true
- type:textarea
attributes:
label:Steps to Reproduce
description:Provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) if possible and the needed steps to reproduce the problem.
validations:
required:true
- type:textarea
attributes:
label:Expected Result
description:What did you expect to see?
validations:
required:true
- type:textarea
attributes:
label:Actual Result
description:What did you see instead?
validations:
required:true
- type:textarea
id:additional-context
attributes:
label:Additional context
description:Add any other context about the problem here.
placeholder:Any additional information...
- type:dropdown
id:contribute
attributes:
label:Would you like to implement a fix?
description:For guidance on how to get started, refer to the [contribution guide](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md).
Before opening a feature request against this repo, consider whether the feature should/could be implemented in the [other OpenTelemetry client libraries](https://github.com/open-telemetry/). If so, please [open an issue on opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification/issues/new) first.
**Is your feature request related to a problem?**
If so, provide a concise description of the problem.
**Describe the solution you'd like**
What do you want to happen instead? What is the expected behavior?
**Describe alternatives you've considered**
Which alternative solutions or features have you considered?
**Additional context**
Add any other context about the feature request here.
Before opening a feature request against this repo, consider whether the feature should/could be implemented in the [other OpenTelemetry client libraries](https://github.com/open-telemetry/). If so, please [open an issue on opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification/issues/new) first.
- type:textarea
id:related-problem
attributes:
label:What problem do you want to solve?
description:Is your feature request related to a problem? If so, provide a concise description of the problem.
placeholder:Describe the problem and include relevant issue IDs
validations:
required:true
- type:textarea
id:solution
attributes:
label:Describe the solution you'd like
description:What do you want to happen instead? What is the expected behavior?
placeholder:I'd like to ...
validations:
required:true
- type:textarea
id:alternatives
attributes:
label:Describe alternatives you've considered
description:Which alternative solutions or features have you considered?
placeholder:Some potential solutions
validations:
required:false
- type:textarea
id:additional-context
attributes:
label:Additional Context
description:Add any other context about the feature request here.
placeholder:Some related requests in other projects or upstream spec proposals.
validations:
required:false
- type:dropdown
id:contribute
attributes:
label:Would you like to implement a fix?
description:|
For guidance on how to get started, refer to the [contribution guide](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md).
run: git checkout ${% raw %}{{ github.event.pull_request.head.sha }}{% endraw %}
{%- endif %}
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install tox
run: pip install tox-uv
- name: Run tests
run: tox -e {{ job_data }}
{%- if job_data == "generate-workflows" %}
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated workflows are out of date, run "tox -e generate-workflows" and commit the changes in this PR.' && exit 1)
{%- endif %}
{%- if job_data == "generate" %}
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated code is out of date, run "tox -e generate" and commit the changes in this PR.' && exit 1)
- [Bumping the Python baseline](#bumping-the-python-baseline)
- [Adding support for a new Python release](#adding-support-for-a-new-python-release)
## Find a Buddy and get Started Quickly
If you are looking for someone to help you find a starting point and be a resource for your first contribution, join our
Slack and find a buddy!
@ -27,33 +59,71 @@ context, reviewing PRs, and helping those get merged. Buddies will not be availa
## Development
To quickly get up and running, you can use the `scripts/eachdist.py` tool that
ships with this project. First create a virtualenv and activate it.
Then run `python scripts/eachdist.py develop` to install all required packages
as well as the project's packages themselves (in `--editable` mode).
You can then run `scripts/eachdist.py test` to test everything or
`scripts/eachdist.py lint` to lint everything (fixing anything that is auto-fixable).
This project uses [tox](https://tox.readthedocs.io) to automate
some aspects of development, including testing against multiple Python versions.
To install `tox`, run:
Additionally, this project uses [`tox`](https://tox.readthedocs.io) to automate some aspects
of development, including testing against multiple Python versions.
```sh
pip install tox
```
You can run:
You can also run tox with `uv` support. By default [tox.ini](./tox.ini) will automatically create a provisioned tox environment with `tox-uv`, but you can install it at host level:
- `tox` to run all existing tox commands, including unit tests for all packages
```sh
pip install tox-uv
```
You can run `tox` with the following arguments:
* `tox` to run all existing tox commands, including unit tests for all packages
under multiple Python versions
- `tox -e py37-test-flask` to e.g. run the Flask tests under a specific
* `tox -e docs` to regenerate all docs
* `tox -e py312-test-instrumentation-aiopg` to e.g. run the aiopg instrumentation unit tests under a specific
Python version
- `tox -e lint` to run lint checks on all code
* `tox -e spellcheck` to run a spellcheck on all the code
* `tox -e lint-some-package` to run lint checks on `some-package`
* `tox -e generate-workflows` to run creation of new CI workflows if tox environments have been updated
* `tox -e ruff` to run ruff linter and formatter checks against the entire codebase
`ruff check` and `ruff format` are executed when `tox -e ruff` is run. We strongly recommend you to configure [pre-commit](https://pre-commit.com/) locally to run `ruff` automatically before each commit by installing it as git hooks. You just need to [install pre-commit](https://pre-commit.com/#install) in your environment:
You can also create a single virtual environment to make it easier to run local tests.
For that, you'll need to install [`uv`](https://docs.astral.sh/uv/getting-started/installation/).
After installing `uv`, you can run the following command:
```sh
uv sync
```
This will create a virtual environment in the `.venv` directory and install all the necessary dependencies.
### Troubleshooting
Some packages may require additional system-wide dependencies to be installed. For example, you may need to install `libpq-dev` to run the postgresql client libraries instrumentation tests or `libsnappy-dev` to run the prometheus exporter tests. If you encounter a build error, please check the installation instructions for the package you are trying to run tests for.
For `docs` building, you may need to install `mysql-client` and other required dependencies as necessary. Ensure the Python version used in your local setup matches the version used in the [CI](./.github/workflows/) to maintain compatibility when building the documentation.
### Benchmarks
Performance progression of benchmarks for packages distributed by OpenTelemetry Python can be viewed as a [graph of throughput vs commit history](https://opentelemetry-python-contrib.readthedocs.io/en/latest/performance/benchmarks.html). From the linked page, you can download a JSON file with the performance results.
Running the `tox` tests also runs the performance tests if any are available. Benchmarking tests are done with `pytest-benchmark` and they output a table with results to the console.
Some packages have benchmark tests. To run them, run `tox -f benchmark`. Benchmark tests use `pytest-benchmark` and they output a table with results to the console.
To write benchmarks, simply use the [pytest benchmark fixture](https://pytest-benchmark.readthedocs.io/en/latest/usage.html#usage) like the following:
@ -159,20 +257,32 @@ For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-sp
2. Make sure you have `tox` installed. `pip install tox`.
3. Run `tox` without any arguments to run tests for all the packages. Read more about [tox](https://tox.readthedocs.io/en/latest/).
Some tests can be slow due to pre-steps that do dependencies installs. To help with that, you can run tox a first time, and after that run the tests using previous installed dependencies in toxdir as following:
1. First time run (e.g., opentelemetry-instrumentation-aiopg)
### Testing against a different Core repo branch/commit
Some of the tox targets install packages from the [OpenTelemetry Python Core Repository](https://github.com/open-telemetry/opentelemetry-python) via pip. The version of the packages installed defaults to the main branch in that repository when tox is run locally. It is possible to install packages tagged with a specific git commit hash by setting an environment variable before running tox as per the following example:
The continuation integration overrides that environment variable with as per the configuration [here](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/test.yml#L9).
The continuous integration overrides that environment variable with as per the configuration [here](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/test_0.yml#L14).
## Style Guide
* docstrings should adhere to the [Google Python Style
extension in [Sphinx](http://www.sphinx-doc.org/en/master/index.html).
@ -181,28 +291,85 @@ The continuation integration overrides that environment variable with as per the
Below is a checklist of things to be mindful of when implementing a new instrumentation or working on a specific instrumentation. It is one of our goals as a community to keep the implementation specific details of instrumentations as similar across the board as possible for ease of testing and feature parity. It is also good to abstract as much common functionality as possible.
- Follow semantic conventions
- The instrumentation should follow the semantic conventions defined [here](https://github.com/open-telemetry/opentelemetry-specification/tree/main/semantic_conventions)
- Extends from [BaseInstrumentor](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L26)
- The instrumentation should follow the semantic conventions defined [here](https://github.com/open-telemetry/semantic-conventions/tree/main/docs).
- To ensure consistency, we encourage contributions that align with [STABLE](https://opentelemetry.io/docs/specs/otel/document-status/#lifecycle-status) semantic conventions if available. This approach helps us avoid potential confusion and reduces the need to support multiple outdated versions of semantic conventions. However, we are still open to considering exceptional cases where changes are well justified.
- Contributions related to outdated HTTP semantic conventions (conventions prior to becoming [stable](https://github.com/open-telemetry/semantic-conventions/tree/v1.23.0)) will likely be discouraged, as they increase complexity and the potential for misconceptions.
- Contains a name that is not already claimed in [Pypi](https://pypi.org/). Contact a maintainer, bring the issue up in the weekly Python SIG or create a ticket in Pypi if a desired name has already been taken.
- Extends from [BaseInstrumentor](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L35)
- Supports auto-instrumentation
- Add an entry point (ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-requests/setup.cfg#L56)
- Run `python scripts/setup.py` followed by `python scripts/generate_instrumentation_bootstrap.py` after adding a new instrumentation package.
- Add an entry point (ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml#L44>)
- Run `python scripts/generate_instrumentation_bootstrap.py` after adding a new instrumentation package.
- Functionality that is common amongst other instrumentation and can be abstracted [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation)
- Request/response [hooks](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/408) for http instrumentations
- For synchronous tests, the typical test case class is inherited from `opentelemetry.test.test_base.TestBase`. However, if you want to write asynchronous tests, the test case class should inherit also from `IsolatedAsyncioTestCase`. Adding asynchronous tests to a common test class can lead to tests passing without actually running, which can be misleading.
- Most of the instrumentations have the same version. If you are going to develop a new instrumentation it would probably have `X.Y.dev` version and depends on `opentelemetry-instrumentation` and `opentelemetry-semantic-conventions` for a [compatible version](https://peps.python.org/pep-0440/#compatible-release). That means that you may need to install the instrumentation dependencies from this repo and the core repo from git.
- Documentation
- When adding a new instrumentation remember to add an entry in `docs/instrumentation/` named `<instrumentation>/<instrumentation>.rst` to have the instrumentation documentation referenced from the index. You can use the entry template available [here](./_template/autodoc_entry.rst)
- Testing
- When adding a new instrumentation remember to update `tox.ini` adding appropriate rules in `envlist`, `command_pre` and `commands` sections
- Navigate to the **instrumentation package directory:**
- Update **`pyproject.toml`** file by modifying _instruments_ entry in the `[project.optional-dependencies]` section with the new version constraint
- Update `_instruments` variable in instrumentation **`package.py`** file with the new version constraint
- At the **root of the project directory**, run `tox -e generate` to regenerate necessary files
If you're adding support for a new version of the instrumentation package, follow these additional steps:
- At the **instrumentation package directory:** Add new test-requirements.txt file with the respective package version required for testing
- At the **root of the project directory**: Add a new test environment entry for the package version in [tox.ini](./tox.ini) and run `tox -e generate-workflows` to regenerate new workflows accordingly. In the same [tox.ini](./tox.ini) file, search for `opentelemetry-instrumentation-{package}/test-requirements` and add a new line to point to the new test-requirements.txt you created in the previous step so tox can install the correct requirements.
Example PRs: [#2976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2976), [#2845](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2845)
## Guideline for GenAI instrumentations
Instrumentations that relate to [Generative AI](https://opentelemetry.io/docs/specs/semconv/gen-ai/) systems will be placed in the [instrumentation-genai](./instrumentation-genai) folder. This section covers contributions related to those instrumentations. Please note that the [guidelines for instrumentations](#guideline-for-instrumentations) and [expectations from contributors](#expectations-from-contributors) still apply.
### Get Involved
* Reviewing PRs: If you would like to be tagged as reviewer in new PRs related to these instrumentations, please submit a PR to add your GitHub handle to [component_owners.yml](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/component_owners.yml) under the corresponding instrumentation folder(s).
* Approving PRs: If you would like to be able to approve PRs related to these instrumentations, you must join [opentelemetry-python-contrib-approvers](https://github.com/orgs/open-telemetry/teams/opentelemetry-python-contrib-approvers) team. Please ask one of the [Python contrib maintainers](https://github.com/orgs/open-telemetry/teams/opentelemetry-python-contrib-maintainers) to be accepted into the team.
* Tracking and Creating Issues: For tracking issues related to Generative AI, please filter or add the label [gen-ai](https://github.com/open-telemetry/opentelemetry-python-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Agen-ai) when creating or searching issues. If you do not see an issue related to an instrumentation you would like to contribute to, please create a new tracking issue so the community is aware of its progress.
## Expectations from contributors
OpenTelemetry is an open source community, and as such, greatly encourages contributions from anyone interested in the project. With that being said, there is a certain level of expectation from contributors even after a pull request is merged, specifically pertaining to instrumentations. The OpenTelemetry Python community expects contributors to maintain a level of support and interest in the instrumentations they contribute. This is to ensure that the instrumentation does not become stale and still functions the way the original contributor intended. Some instrumentations also pertain to libraries that the current memebers of the community are not so familiar with, so it is necessary to rely on the expertise of the original contributing parties.
OpenTelemetry is an open source community, and as such, greatly encourages contributions from anyone interested in the project. With that being said, there is a certain level of expectation from contributors even after a pull request is merged, specifically pertaining to instrumentations. The OpenTelemetry Python community expects contributors to maintain a level of support and interest in the instrumentations they contribute. This is to ensure that the instrumentation does not become stale and still functions the way the original contributor intended. Some instrumentations also pertain to libraries that the current members of the community are not so familiar with, so it is necessary to rely on the expertise of the original contributing parties.
## Updating supported Python versions
### Bumping the Python baseline
When updating the minimum supported Python version remember to:
- Remove the version in `pyproject.toml` trove classifiers
- Remove the version from `tox.ini`
- Update github workflows accordingly with `tox -e generate-workflows`
- Search for `sys.version_info` usage and remove code for unsupported versions
- Bump `py-version` in `.pylintrc` for Python version dependent checks
### Adding support for a new Python release
When adding support for a new Python release remember to:
- Add the version in `tox.ini`
- Add the version in `pyproject.toml` trove classifiers
- Update github workflows accordingly with `tox -e generate-workflows`; lint and benchmarks use the latest supported version
The Python auto-instrumentation libraries for [OpenTelemetry](https://opentelemetry.io/) (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/main/text/0001-telemetry-without-manual-instrumentation.md))
### Installation
## Index
* [Installation](#installation)
* [Releasing](#releasing)
* [Releasing a package as `1.0` stable](#releasing-a-package-as-10-stable)
* [Semantic Convention status of instrumentations](#semantic-convention-status-of-instrumentations)
* [Contributing](#contributing)
* [Thanks to all the people who already contributed](#thanks-to-all-the-people-who-already-contributed)
## Installation
This repository includes installable packages for each instrumented library. Libraries that produce telemetry data should only depend on `opentelemetry-api`,
and defer the choice of the SDK to the application developer. Applications may
@ -49,6 +61,8 @@ depend on `opentelemetry-sdk` or another package that implements the API.
**Please note** that these libraries are currently in _beta_, and shouldn't
generally be used in production environments.
Unless explicitly stated otherwise, any instrumentation here for a particular library is not developed or maintained by the authors of such library.
Maintainers aim to periodically release new versions of the packages in `opentelemetry-python-contrib`.
Maintainers release new versions of the packages in `opentelemetry-python-contrib` on a monthly cadence. See [releases](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) for all previous releases.
Contributions that enhance OTel for Python are welcome to be hosted upstream for the benefit of group collaboration. Maintainers will look for things like good documentation, good unit tests, and in general their own confidence when deciding to release a package with the stability guarantees that are implied with a `1.0` release.
@ -77,6 +91,7 @@ To resolve this, members of the community are encouraged to commit to becoming a
### Releasing a package as `1.0` stable
To release a package as `1.0` stable, the package:
- SHOULD have a CODEOWNER. To become one, submit an issue and explain why you meet the responsibilities found in [CODEOWNERS](.github/CODEOWNERS).
- MUST have unit tests that cover all supported versions of the instrumented library.
- e.g. Instrumentation packages might use different techniques to instrument different major versions of python packages
@ -84,44 +99,60 @@ To release a package as `1.0` stable, the package:
- e.g. If an instrumentation package uses flags, a token as context, or parameters that are not typical of the `BaseInstrumentor` class, these are documented
- After the release of `1.0`, a CODEOWNER may no longer feel like they have the bandwidth to meet the responsibilities of maintaining the package. That's not a problem at all, life happens! However, if that is the case, we ask that the CODEOWNER please raise an issue indicating that they would like to be removed as a CODEOWNER so that they don't get pinged on future PRs. Ultimately, we hope to use that issue to find a new CODEOWNER.
## Semantic Convention status of instrumentations
In our efforts to maintain optimal user experience and prevent breaking changes for transitioning into stable semantic conventions, OpenTelemetry Python is adopting the semantic convention migration plan for several instrumentations. Currently this plan is only being adopted for [HTTP-related instrumentations](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md), but will eventually cover all types. Please refer to the `semconv status` column of the [instrumentation README](instrumentation/README.md) of the current status of instrumentations' semantic conventions. The possible values are `development`, `stable` and `migration` referring to [status](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/document-status.md#lifecycle-status) of that particular semantic convention. `Migration` refers to an instrumentation that currently supports the migration plan.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
We meet weekly on Thursday, and the time of the meeting alternates between 9AM PT and 4PM PT. The meeting is subject to change depending on contributors' availability. Check the [OpenTelemetry community calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com) for specific dates.
Meetings take place via [Zoom video conference](https://zoom.us/j/8287234601?pwd=YjN2MURycXc4cEZlYTRtYjJaM0grZz09). The passcode is _77777_.
We meet weekly on Thursday at 9AM PT. The meeting is subject to change depending on contributors' availability. Check the [OpenTelemetry community calendar](https://calendar.google.com/calendar/embed?src=c_2bf73e3b6b530da4babd444e72b76a6ad893a5c3f43cf40467abc7a9a897f977%40group.calendar.google.com) for specific dates and for the Zoom link.
Meeting notes are available as a public [Google doc](https://docs.google.com/document/d/1CIMGoIOZ-c3-igzbd6_Pnxx1SjAkjwqoYSUWxPY8XIs/edit). For edit access, get in touch on [GitHub Discussions](https://github.com/open-telemetry/opentelemetry-python/discussions).
For more information about the maintainer role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#maintainer).
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*
For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#approver).
## Running Tests Locally
### Emeritus Maintainers
1. Go to your Contrib repo directory. `cd ~/git/opentelemetry-python-contrib`.
2. Create a virtual env in your Contrib repo directory. `python3 -m venv my_test_venv`.
3. Activate your virtual env. `source my_test_venv/bin/activate`.
4. Make sure you have `tox` installed. `pip install tox`.
5. Run tests for a package. (e.g. `tox -e test-instrumentation-flask`.)
### Thanks to all the people who already contributed!
For more information about the emeritus role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#emeritus-maintainerapprovertriager).
For more information about the emeritus role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#emeritus-maintainerapprovertriager).
* Run the [Prepare release branch workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/prepare-release-branch.yml).
* Press the "Run workflow" button, and leave the default branch `main` selected.
* If making a pre-release of stable components (e.g. release candidate),
enter the pre-release version number, e.g. `1.9.0rc2`.
(otherwise the workflow will pick up the version from `main` and just remove the `.dev` suffix).
* Review the two pull requests that it creates.
(one is targeted to the release branch and one is targeted to `main`).
* The builds will fail for the release PR because of validation rules. Follow the [release workflow](https://github.com/open-telemetry/opentelemetry-python/blob/main/RELEASING.md) for the core repo up until this same point.
* Close and reopen the PR so that the workflow will take into account the label automation we have in place
* Merge the release PR.
* Merge the PR to main (this can be done separately from [making the release](#making-the-release))
### Preparing a major or minor release for individual package
> [!NOTE]
> Per-package release is supported for the following packages only:
> - opentelemetry-propagator-aws-xray
> - opentelemetry-resource-detector-azure
> - opentelemetry-sdk-extension-aws
> - opentelemetry-instrumentation-openai-v2
> - opentelemetry-instrumentation-vertexai
> - opentelemetry-instrumentation-google-genai
>
> These libraries are also excluded from the general release.
Package release preparation is handled by the [`[Package] Prepare release`](./.github/workflows/package-prepare-release.yml) workflow that allows
to pick a specific package to release. It follows the same versioning strategy and process as the general release.
The workflow will create two pull requests, one against the `main` and one against the `package-release/` branch; both should be merged in order to proceed with the release.
## Preparing a new patch release
* Backport pull request(s) to the release branch.
* Run the [Backport workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/backport.yml).
* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `release/v1.9.x`, then enter the pull request number that you want to backport,
then click the "Run workflow" button below that.
* Add the label `backport` to the generated pull request.
* In case label automation doesn't work, just close and reopen the PR so that the workflow will take into account the label automation we have in place.
* Review and merge the backport pull request that it generates.
* Merge a pull request to the release branch updating the `CHANGELOG.md`.
* The heading for the unreleased entries should be `## Unreleased`.
* Run the [Prepare patch release workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/prepare-patch-release.yml).
* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
* Review and merge the pull request that it creates for updating the version.
* Note: If you are doing a patch release in `-contrib` repo, you should also do an equivalent patch release in `-core` repo (even if there's no fix to release), otherwise tests in CI will fail.
### Preparing a patch release for individual package
> [!NOTE]
> Per-package release is supported only for packages included in the corresponding workflow. Libraries that support per-package release are currently
> excluded from the general patch release.
Per-package patch release preparation is handled by the [`[Package] Prepare patch release`](./.github/workflows/package-prepare-patch-release.yml) workflow that allows
to pick a specific package to release.
The workflow can only be run against long-term release branch such as `package-release/{package-name}/v{major}.{minor}.x` or `package-release/{package-name}/v{major}.{minor}bx`.
The workflow will create a pull request that should be merged in order to proceed with the release.
## Making the release
* Run the [Release workflow](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/release.yml).
* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
* This workflow will publish the artifacts and publish a GitHub release with release notes based on the change log.
* Review and merge the pull request that it creates for updating the change log in main
(note that if this is not a patch release then the change log on main may already be up-to-date,
in which case no pull request will be created).
* Verify that a new [Github release](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) has been created and that the CHANGELOGs look correct.
### Releasing individual package
> [!NOTE]
> Per-package patch release is supported for the following packages only:
> - opentelemetry-propagator-aws-xray
> - opentelemetry-resource-detector-azure
> - opentelemetry-sdk-extension-aws
> - opentelemetry-instrumentation-openai-v2
> - opentelemetry-instrumentation-vertexai
> - opentelemetry-instrumentation-google-genai
>
> These libraries are also excluded from the general patch release.
Per-package release is handled by the [`[Package] Release`](./.github/workflows/package-release.yml) workflow that allows
to pick a specific package to release.
The workflow can only be run against long-term release branch such as `package-release/{package-name}/v{major}.{minor}.x` or `package-release/{package-name}/v{major}.{minor}bx`.
## After the release
* Check PyPI
* This should be handled automatically on release by the [publish action](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/release.yml).
* Check the [action logs](https://github.com/open-telemetry/opentelemetry-python-contrib/actions/workflows/release.yml) to make sure packages have been uploaded to PyPI
* Check the release history (e.g. https://pypi.org/project/opentelemetry-instrumentation/#history) on PyPI
* If for some reason the action failed, see [Publish failed](#publish-failed) below
## Notes about version numbering for stable components
* The version number for stable components in the `main` branch is always `X.Y.0.dev`,
where `X.Y.0` represents the next minor release.
* When the release branch is created, you can opt to make a "pre-release", e.g. `X.Y.0rc2`.
* If you ARE NOT making a "pre-release":
* A "long-term" release branch will be created, e.g. `release/v1.9.x-0.21bx` (notice the wildcard x's).
Later on, after the initial release, you can backport PRs to a "long-term" release branch and make patch releases
from it.
* The version number for stable components in the release branch will be bumped to remove the `.dev`,
e.g. `X.Y.0`.
* The version number for stable components in the `main` branch will be bumped to the next version,
e.g. `X.{Y+1}.0.dev`.
* If you ARE making a "pre-release":
* A "short-term" release branch will be created, e.g. `release/v1.9.0rc2-0.21b0` (notice the precise version with no
wildcard x's). "Short-term" release branches do not support backports or patch releases after the initial release.
* The version number for stable components in the `main` branch will not be bumped, e.g. it will remain `X.Y.0.dev`
since the next minor release will still be `X.Y.0`.
## Notes about version numbering for unstable components
* The version number for unstable components in the `main` branch is always `0.Yb0.dev`,
where `0.Yb0` represents the next minor release.
* _Question: Is "b" (beta) redundant on "0." releases, or is this a python thing? I'm wondering if we can change it to `0.Y.0` to match up with the practice in js and go repos._
* Unstable components do not need "pre-releases", and so whether or not you are making a "pre-release" of stable
components:
* The version number for unstable components in the release branch will be bumped to remove the `.dev`,
e.g. `0.Yb0`.
* The version number for unstable components in the `main` branch will be bumped to the next version,
e.g. `0.{Y+1}b0.dev`.
## Releasing dev version of new packages to claim namespace
When a contribution introduces a new package, in order to mitigate name-squatting incidents, release the current development version of the new package under the `opentelemetry` user to simply claim the namespace. This should be done shortly after the PR that introduced this package has been merged into `main`.
## Troubleshooting
### Publish failed
If for some reason the action failed, do it manually:
- Switch to the release branch (important so we don't publish packages with "dev" versions)
- Build distributions with `./scripts/build.sh`
- Delete distributions we don't want to push (e.g. `testutil`)
- Push to PyPI as `twine upload --skip-existing --verbose dist/*`