Skip to content

Commit

Permalink
feat: add resolve debugger logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklasl committed Dec 4, 2024
1 parent 47adb2c commit cfea5b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions confidence/confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dataclasses
from datetime import datetime
from enum import Enum
import json
import logging
from typing import (
Any,
Expand Down Expand Up @@ -173,7 +174,13 @@ def _handle_evaluation_result(
value_type: Type[FieldType],
default_value: FieldType,
value_path: Optional[str],
context: Dict[str, FieldType],
) -> FlagResolutionDetails[Any]:
urlEncodedContext = requests.utils.quote(json.dumps((context)))
self.logger.debug(
f"See resolves for '{flag_key}' in Confidence: https://app.confidence.spotify.com/flags/resolver-test?client-key={self._client_secret}&flag=flags/{flag_key}&context={urlEncodedContext}"
)

if result.variant is None or len(str(result.value)) == 0:
return FlagResolutionDetails(
value=default_value,
Expand Down Expand Up @@ -211,7 +218,7 @@ def _evaluate(
value_path = None
result = self._resolve(FlagName(flag_id), context)
return self._handle_evaluation_result(
result, flag_key, value_type, default_value, value_path
result, flag_key, value_type, default_value, value_path, context
)

async def _evaluate_async(
Expand All @@ -228,7 +235,7 @@ async def _evaluate_async(
value_path = None
result = await self._resolve_async(FlagName(flag_id), context)
return self._handle_evaluation_result(
result, flag_key, value_type, default_value, value_path
result, flag_key, value_type, default_value, value_path, context
)

# type-arg: ignore
Expand Down

0 comments on commit cfea5b7

Please sign in to comment.