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
68 changes: 58 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,64 @@ confidence.track("event_name", {
})
```

## OpenFeature

The library includes a `Provider` for
the [OpenFeature Python SDK](https://openfeature.dev/docs/tutorials/getting-started/python), that can be
used to resolve feature flag values from the Confidence platform.

To learn more about the basic concepts (flags, targeting key, evaluation contexts),
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
useful.


## Logging

The SDK includes built-in logging functionality to help with debugging and monitoring. By default, the SDK creates a logger named `confidence_logger` that outputs to the console with DEBUG level logging enabled.

### Default logging behavior

When you create a Confidence client without specifying a logger, debug-level logging is automatically enabled:

```python
from confidence.confidence import Confidence

# Debug logging is enabled by default
confidence = Confidence("CLIENT_TOKEN")
```

This will output log messages such as flag resolution details, error messages, and debug information to help troubleshoot issues.

### Using a custom logger

You can provide your own logger instance to customize the logging behavior:

```python
import logging
from confidence.confidence import Confidence

# Create a custom logger with INFO level (less verbose)
custom_logger = logging.getLogger("my_confidence_logger")
custom_logger.setLevel(logging.INFO)

confidence = Confidence("CLIENT_TOKEN", logger=custom_logger)
```

### Disabling debug logging

To reduce log verbosity, you can configure a logger with a higher log level:

```python
import logging
from confidence.confidence import Confidence

# Create a logger that only shows warnings and errors
quiet_logger = logging.getLogger("quiet_confidence_logger")
quiet_logger.setLevel(logging.WARNING)

confidence = Confidence("CLIENT_TOKEN", logger=quiet_logger)
```

## Telemetry

The SDK includes telemetry functionality that helps monitor SDK performance and usage. By default, telemetry is enabled and collects metrics (anonymously) such as resolve latency and request status. This data is used by the Confidence team to improve the product, and in certain cases it is also available to the SDK adopters.
Expand All @@ -70,13 +128,3 @@ confidence = Confidence("CLIENT_TOKEN",
disable_telemetry=True
)
```

## OpenFeature

The library includes a `Provider` for
the [OpenFeature Python SDK](https://openfeature.dev/docs/tutorials/getting-started/python), that can be
used to resolve feature flag values from the Confidence platform.

To learn more about the basic concepts (flags, targeting key, evaluation contexts),
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
useful.
3 changes: 2 additions & 1 deletion confidence/confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ async def resolve_object_details_async(

def _setup_logger(self, logger: logging.Logger) -> None:
if logger is not None:
logger.setLevel(logging.DEBUG)
if logger.level == logging.NOTSET:
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
Expand Down
Loading