OpenTelemetry hooks for the OpenFeature Python SDK
Project description
OpenTelemetry Hook
The OpenTelemetry tracing hook for OpenFeature provides a spec compliant way to automatically add a feature flag evaluation to a span as a span event. Since feature flags are dynamic and affect runtime behavior, it’s important to collect relevant feature flag telemetry signals. This can be used to determine the impact a feature has on a request, enabling enhanced observability use cases, such as A/B testing or progressive feature releases.
Installation
pip install openfeature-hooks-opentelemetry
Usage
OpenFeature provides various ways to register hooks. The location that a hook is registered affects when the hook is run. It's recommended to register the TracingHook globally in most situations but it's possible to only enable the hook on specific clients. You should never register the TracingHook globally and on a client.
More information on hooks can be found in the OpenFeature documentation.
Register Globally
The TracingHook can be set globally. This will ensure that every flag evaluation will always create a span event, if an active span is available.
from openfeature import api
from openfeature.contrib.hook.opentelemetry import TracingHook
api.add_hooks([TracingHook()])
Register Per Client
The TracingHook can also be set on an individual client. This should only be done if it wasn't set globally and other clients shouldn't use this hook. Setting the hook on the client will ensure that every flag evaluation performed by this client will always create a span event, if an active span is available.
from openfeature import api
from openfeature.contrib.hook.opentelemetry import TracingHook
client = api.get_client("my-app")
client.add_hooks([TracingHook()])
License
Apache 2.0 - See LICENSE for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openfeature_hooks_opentelemetry-0.3.1.tar.gz.
File metadata
- Download URL: openfeature_hooks_opentelemetry-0.3.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d399244a6f5408f474ae2b0233257e30d8a041d635f71c2727c033dbfe1fe92
|
|
| MD5 |
7a515098c58c51af9f4d591be29b76de
|
|
| BLAKE2b-256 |
4a3c2841238b88d4ddd28e7cab23c14d3c44723a007d4b82c44f7349ab352d05
|
Provenance
The following attestation bundles were made for openfeature_hooks_opentelemetry-0.3.1.tar.gz:
Publisher:
release.yml on open-feature/python-sdk-contrib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openfeature_hooks_opentelemetry-0.3.1.tar.gz -
Subject digest:
6d399244a6f5408f474ae2b0233257e30d8a041d635f71c2727c033dbfe1fe92 - Sigstore transparency entry: 957466457
- Sigstore integration time:
-
Permalink:
open-feature/python-sdk-contrib@80da6b94fe63690751ba4df7985c96d992582f68 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-feature
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@80da6b94fe63690751ba4df7985c96d992582f68 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openfeature_hooks_opentelemetry-0.3.1-py3-none-any.whl.
File metadata
- Download URL: openfeature_hooks_opentelemetry-0.3.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef4cddec8d328a9b6b738494de3aed623a9917d3b83b2e6b0377e4d2a21d3b22
|
|
| MD5 |
237702a9461b0920af4a4da804dfd54e
|
|
| BLAKE2b-256 |
87426d0b50f261ffaac3db7626673a3edeb18cacf2202c804337a58d8db86a94
|
Provenance
The following attestation bundles were made for openfeature_hooks_opentelemetry-0.3.1-py3-none-any.whl:
Publisher:
release.yml on open-feature/python-sdk-contrib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openfeature_hooks_opentelemetry-0.3.1-py3-none-any.whl -
Subject digest:
ef4cddec8d328a9b6b738494de3aed623a9917d3b83b2e6b0377e4d2a21d3b22 - Sigstore transparency entry: 957466462
- Sigstore integration time:
-
Permalink:
open-feature/python-sdk-contrib@80da6b94fe63690751ba4df7985c96d992582f68 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-feature
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@80da6b94fe63690751ba4df7985c96d992582f68 -
Trigger Event:
push
-
Statement type: