Skip to main content

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

openfeature_hooks_opentelemetry-0.3.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file openfeature_hooks_opentelemetry-0.3.0.tar.gz.

File metadata

File hashes

Hashes for openfeature_hooks_opentelemetry-0.3.0.tar.gz
Algorithm Hash digest
SHA256 333b6b20433b980548c4a6dd873046a8c07b4a1bfc1e3b885ecf1b3ebbb392e4
MD5 f0a08fbed6d8f65b5381ec4857d19d6c
BLAKE2b-256 b6dd49f199a23f19f1d8c69a9c365f151461c48318798c18cceb464f4bcfeb45

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfeature_hooks_opentelemetry-0.3.0.tar.gz:

Publisher: release.yml on open-feature/python-sdk-contrib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openfeature_hooks_opentelemetry-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openfeature_hooks_opentelemetry-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90b4e3ad8e83222c49f01820c19c9c77e031ac5bd1be66eff4454daaf0d875f3
MD5 18570e81ce9ab98b7b5ded33d615077a
BLAKE2b-256 ad217d60ba64fdd0d0afd426e2f0a441fe8361faafc0ae395fe436bd2d33c7e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfeature_hooks_opentelemetry-0.3.0-py3-none-any.whl:

Publisher: release.yml on open-feature/python-sdk-contrib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page