Skip to content

Commit 5ae437f

Browse files
committed
refactor: parameterise stage value
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
1 parent 8db2fc2 commit 5ae437f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ The Python SDK includes a `LoggingHook`, which logs detailed information at key
196196

197197
```python
198198
from openfeature import api
199-
from openfeature.hook import LoggingHook
199+
from openfeature.hook.logging_hook import LoggingHook
200200

201201
api.add_hooks([LoggingHook()])
202202
```

openfeature/hook/logging_hook.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def error(
6161
self, hook_context: HookContext, exception: Exception, hints: HookHints
6262
) -> None:
6363
args = self._build_args(hook_context, "error")
64-
args["stage"] = "error"
6564
args["error_code"] = (
6665
exception.error_code
6766
if isinstance(exception, OpenFeatureError)

tests/hook/test_logging_hook.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,35 +141,38 @@ def test_build_args_without_metadata():
141141
client_metadata=None,
142142
provider_metadata=None,
143143
)
144-
result = hook._build_args(ctx)
144+
result = hook._build_args(ctx, "before")
145145
assert result == {
146146
"flag_key": "flag",
147147
"default_value": "default",
148148
"domain": None,
149149
"provider_name": None,
150+
"stage": "before",
150151
}
151152

152153

153154
def test_build_args_excludes_evaluation_context_by_default(hook_context):
154155
hook = LoggingHook()
155-
result = hook._build_args(hook_context)
156+
result = hook._build_args(hook_context, "before")
156157
assert result == {
157158
"flag_key": "my-flag",
158159
"default_value": False,
159160
"domain": "my-domain",
160161
"provider_name": "my-provider",
162+
"stage": "before",
161163
}
162164

163165

164166
def test_build_args_includes_evaluation_context_when_enabled(hook_context):
165167
hook = LoggingHook(include_evaluation_context=True)
166-
result = hook._build_args(hook_context)
168+
result = hook._build_args(hook_context, "after")
167169
assert result == {
168170
"flag_key": "my-flag",
169171
"default_value": False,
170172
"domain": "my-domain",
171173
"provider_name": "my-provider",
172174
"evaluation_context": '{"targeting_key": "user-1", "attributes": {"env": "prod"}}',
175+
"stage": "after",
173176
}
174177

175178

0 commit comments

Comments
 (0)