Skip to content

Feature flag reference


FeatureFlagManager

A class for querying feature flags.

enabled

enabled(
    flag: str,
    *,
    default: bool = False,
    scopes: dict[str, str] | None = None,
) -> FeatureFlagEvaluationResult

Check if a feature flag is enabled.

Parameters:

Name Type Description Default
flag str

The name of the feature flag to check.

required
default bool

The default value to return if the feature flag is not found.

False
scopes dict[str, str] | None

Additional targeting attributes to use for feature flag evaluation.

None

Examples:

result = app.features.enabled(
    "test-flag", default=False, scopes={"user": "user1"}
)

FeatureFlagEvaluationResult

A result of a feature flag evaluation.

value

value: Any

The value of the feature flag.

defaulted

defaulted: bool

Whether the feature flag was defaulted.

error

error: str | None = None

The error message if the feature flag evaluation failed.

DatadogFeatureFlag

Direct HTTP client for Datadog Feature Flag API

get_flag_value

get_flag_value(
    flag: str,
    targeting_key: str,
    targeting_attributes: dict[str, Any],
) -> bool | None

Get a flag value by key

Parameters:

Name Type Description Default
flag str

The flag key to evaluate

required
targeting_key str

The targeting key to use for feature flag evaluation

required
targeting_attributes dict[str, Any]

The targeting attributes to use for feature flag evaluation

required

Returns:

Type Description
bool | None

The flag value or None if the flag is not found

Raises:

Type Description
HTTPError

If the request fails

ValueError

If the flag is not found

RuntimeError

If an unexpected error occurs