Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hooks/openfeature-hooks-opentelemetry/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
]
keywords = []
dependencies = [
"openfeature-sdk>=0.4.0",
"openfeature-sdk>=0.6.0",
"opentelemetry-api",
]
requires-python = ">=3.8"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from openfeature.flag_evaluation import FlagEvaluationDetails
from openfeature.hook import Hook, HookContext
from openfeature.hook import Hook, HookContext, HookHints
from opentelemetry import trace

OTEL_EVENT_NAME = "feature_flag"
Expand All @@ -15,7 +15,10 @@ class EventAttributes:

class TracingHook(Hook):
def after(
self, hook_context: HookContext, details: FlagEvaluationDetails, hints: dict
self,
hook_context: HookContext,
details: FlagEvaluationDetails,
hints: HookHints,
) -> None:
current_span = trace.get_current_span()

Expand All @@ -39,7 +42,7 @@ def after(
current_span.add_event(OTEL_EVENT_NAME, event_attributes)

def error(
self, hook_context: HookContext, exception: Exception, hints: dict
self, hook_context: HookContext, exception: Exception, hints: HookHints
) -> None:
current_span = trace.get_current_span()
current_span.record_exception(exception)