Declare owners and metadata for features.
Features can capture metadata to inform
alerting, monitoring, and discovery.
By default, features are created as any type-annotated
variable of a class decorated with
However, you may also assign these variables to the
result of the
to provide metadata.
Descriptions are parsed from the comments preceding
the feature definition. For example, you can document a
fraud_score feature with information about the values
@features class User: # 0 to 100 score indicating an identity match. # Low scores indicate safer users fraud_score: float ...
You can alternatively provide a description of a feature directly in the code. The following example is equivalent to explicitly providing the description as above:
@features class User: fraud_score: float = feature(description=""" 0 to 100 score indicating an identity match. Low scores indicate safer users """) ...
If both an explicit description and a comment are present,
the description will be set to the explicit value from
You can programmatically access the description for a feature
from chalk.feature import description print(description(User.fraud_score))
You may also specify which person or group is responsible for a feature. The owner tag will be available in Chalk’s web portal. Alerts that do not otherwise have an owner will be assigned to the owner of the monitored feature. Owners are parsed from the source code. For example:
@features class User: # :owner: firstname.lastname@example.org fraud_score: float ...
You may instead choose to specify an owner via a keyword argument to
@features class User: fraud_score: float = feature(owner="email@example.com") ...
Owners can also be assigned to all features in a namespace:
@features(owner="firstname.lastname@example.org") class User: fraud_score: float full_name: str # :owner: email@example.com email: str ...
assume the owner
User.email, which specifies an owner at the feature level,
assumes the owner
You can programmatically access the owner of a feature
from chalk.feature import owner assert owner(User.email) == "firstname.lastname@example.org"
Tags are a way of adding metadata to features for use in filtering, aggregations, and visualizations. For example, you can use tags to assign features to a team and find all features for a given team.
@features class User: # :tags: team:identity, priority:high fraud_score: float ...
Alternatively, you may specify tags via explicit construction:
@features class User: fraud_score: float = feature(tags=[ "team:identity", "priority:high", ]) ...
As with the owner property, tags can be assigned to all features in a namespace:
@features(tags="group:risk") class User: fraud_score: float # :tags: pii email: str ...
User.fraud_score inherits the tag
User.email will also inherit this tag
in addition to the tag
You can programmatically access the tags for a feature
from chalk.feature import tags assert tags(User.email) == ["pii", "group:risk"]