You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| ✅ |[Providers](#providers)| Integrate with a commercial, open source, or in-house feature management tool. |
153
153
| ✅ |[Targeting](#targeting)| Contextually-aware flag evaluation using [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context). |
154
-
|❌|[Hooks](#hooks)| Add functionality to various stages of the flag evaluation life-cycle. |
155
-
|❌|[Logging](#logging)| Integrate with popular logging packages. |
154
+
|✅|[Hooks](#hooks)| Add functionality to various stages of the flag evaluation life-cycle. |
155
+
|✅|[Logging](#logging)| Integrate with popular logging packages. |
156
156
| ✅ |[Named clients](#named-clients)| Utilize multiple providers in a single application. |
157
157
| ❌ |[Eventing](#eventing)| React to state changes in the provider or flag management system. |
158
158
| ✅ |[Shutdown](#shutdown)| Gracefully clean up a provider during application shutdown. |
159
-
|❌|[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
159
+
|✅|[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
160
160
161
161
<sub>Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌</sub>
[Hooks](https://openfeature.dev/docs/reference/concepts/hooks) allow for custom logic to be added at well-defined points of the flag evaluation life-cycle.
218
215
Look [here](https://openfeature.dev/ecosystem/?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Hook&instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=Rust) for a complete list of available hooks.
219
216
If the hook you're looking for hasn't been created yet, see the [develop a hook](#develop-a-hook) section to learn how to build it yourself.
220
217
221
218
Once you've added a hook as a dependency, it can be registered at the global, client, or flag invocation level.
222
-
-->
223
219
224
-
<!-- TODO: code example of setting hooks at all levels -->
Example of a hook implementation you can find in [examples/hooks.rs](https://github.com/open-feature/rust-sdk/blob/main/examples/hooks.rs).
236
+
237
+
To run the example, execute the following command:
238
+
239
+
```shell
240
+
cargo run --example hooks
241
+
```
225
242
226
243
### Logging
227
244
228
-
Logging customization is not yet available in the Rust SDK.
245
+
Note that in accordance with the OpenFeature specification, the SDK doesn't generally log messages during flag evaluation.
246
+
247
+
#### Logging hook
248
+
249
+
The Rust SDK provides a logging hook that can be used to log messages during flag evaluation.
250
+
This hook is not enabled by default and must be explicitly set.
Both **text** and **structured** logging are supported.
264
+
To enable **structured** logging, enable feature `structured-logging` in your `Cargo.toml`:
265
+
266
+
```toml
267
+
open-feature = { version = "0.2.4", features = ["structured-logging"] }
268
+
```
269
+
270
+
Example of a logging hook usage you can find in [examples/logging.rs](https://github.com/open-feature/rust-sdk/blob/main/examples/logging.rs).
271
+
272
+
To run the example, execute the following command:
{"default_value":"Some(Bool(false))","domain":"","error_message":"Some(\"No-op provider is never ready\")","evaluation_context":"EvaluationContext { targeting_key: None, custom_fields: {} }","file":"src/hooks/logging.rs","flag_key":"my_feature","level":"ERROR","line":162,"message":"Error stage","module":"open_feature::hooks::logging::structured","provider_name":"No-op Provider","target":"open_feature","timestamp":1736537120828}
296
+
```
229
297
230
298
### Named clients
231
299
@@ -281,21 +349,59 @@ Check the source of [`NoOpProvider`](https://github.com/open-feature/rust-sdk/bl
281
349
282
350
### Develop a hook
283
351
284
-
Hooks are not yet available in the Rust SDK.
285
-
286
-
<!-- TOOD: Uncomment it when we support events
287
352
To develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.
288
353
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/rust-sdk-contrib) available under the OpenFeature organization.
289
354
Implement your own hook by conforming to the `Hook interface`.
290
-
To satisfy the interface, all methods (`Before`/`After`/`Finally`/`Error`) need to be defined.
291
-
To avoid defining empty functions make use of the `UnimplementedHook` struct (which already implements all the empty functions).
292
-
-->
355
+
To satisfy the interface, all methods (`before`/`after`/`finally`/`error`) need to be defined.
293
356
294
-
<!-- TODO: code example of hook implementation -->
> Built a new hook? [Let us know](https://github.com/open-feature/openfeature.dev/issues/new?assignees=&labels=hook&projects=&template=document-hook.yaml&title=%5BHook%5D%3A+) so we can add it to the docs!
0 commit comments