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
Release history Release notifications | RSS feed
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
File details
Details for the file openfeature_hooks_opentelemetry-0.1.3.tar.gz
.
File metadata
- Download URL: openfeature_hooks_opentelemetry-0.1.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25f4d10312c1f4e1bf33b6bec1d11d9a5a215be2e124a2819b3458d3904a7940 |
|
MD5 | 8441879bad654ae898a98974da1fc0ea |
|
BLAKE2b-256 | 2cce0bc0810abab2e6bab41efb706d78bd90457ffaf1bc16db0d84a8ce33b063 |
File details
Details for the file openfeature_hooks_opentelemetry-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: openfeature_hooks_opentelemetry-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6cd9fca9124d58372612cc2c52950caf2c9a533fa7f130ed94cb52b4181915c |
|
MD5 | 15d7c09d359f6d2e2bc1251239ec3180 |
|
BLAKE2b-256 | 5e092e0e018512d00b6208c733c5b19aae97bfaf490f877b7b4d2a4463176cf5 |