Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Flag evaluation event #1440

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
64cc6e1
Feature Flag: feature_flag.evaluation event
dyladan Sep 30, 2024
9d70d52
Remove ff events.yaml for now
dyladan Sep 30, 2024
17661ad
Deprecate
dyladan Sep 30, 2024
5a1315f
Fix lint errors
dyladan Sep 30, 2024
778a506
Add changelog entry
dyladan Sep 30, 2024
955784e
Merge branch 'main' into ff-evaluation-event
dyladan Sep 30, 2024
5353b33
Merge remote-tracking branch 'origin/main' into ff-evaluation-event
dyladan Oct 14, 2024
1b2d939
Update ff version to be clear a hash is not a specific recommendation
dyladan Oct 14, 2024
49bbdff
Merge remote-tracking branch 'origin/main' into ff-evaluation-event
dyladan Oct 28, 2024
ab16aba
Rename environment to flag set
dyladan Oct 28, 2024
4ffa81c
Describe feature_flag.key as lookup key
dyladan Oct 28, 2024
97b68d8
Update requirement level for variant and value
dyladan Oct 28, 2024
4e70d70
Avoid word repetition
dyladan Oct 28, 2024
78938e0
Clarify permissiveness of provider id
dyladan Oct 28, 2024
5e4bf75
Merge branch 'main' into ff-evaluation-event
dyladan Nov 4, 2024
e9e209e
Rename flag_set to just set
dyladan Nov 4, 2024
9e68f15
Use system terminology to match db and gen_ai
dyladan Nov 4, 2024
25f4783
Expand brief for flag evaluation event
dyladan Nov 4, 2024
51b7e45
Move feature_flag.value to body field
dyladan Nov 5, 2024
f12c1cf
Add evaluation reason
dyladan Nov 5, 2024
7555d86
Generate tables
dyladan Nov 5, 2024
9ef0ba1
Add feature flag error code
dyladan Nov 5, 2024
ebab494
Add feature flag evaluation log motivation
dyladan Nov 5, 2024
fcca5a6
Fix: provider.id renamed to system
dyladan Nov 5, 2024
5513c81
Add flag evaluation error message
dyladan Nov 5, 2024
27aa56a
Misspell
dyladan Nov 6, 2024
5ae514a
Apply suggestions from code review and remove broken links
dyladan Nov 6, 2024
2e7ca66
Merge branch 'main' into ff-evaluation-event
dyladan Nov 6, 2024
118ce57
Fix issue number
dyladan Nov 6, 2024
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
4 changes: 4 additions & 0 deletions .chloggen/1140.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
change_type: enhancement
component: feature_flag
note: Define `feature_flag.evaluation` event.
issues: [1140]
37 changes: 31 additions & 6 deletions docs/attributes-registry/feature-flag.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,46 @@

# Feature Flag

- [Feature Flag Attributes](#feature-flag-attributes)
- [Deprecated Feature Flag Attributes](#deprecated-feature-flag-attributes)

## Feature Flag Attributes

This document defines attributes for Feature Flags.

| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| <a id="feature-flag-key" href="#feature-flag-key">`feature_flag.key`</a> | string | The unique identifier of the feature flag. | `logo-color` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-provider-name" href="#feature-flag-provider-name">`feature_flag.provider_name`</a> | string | The name of the service provider that performs the flag evaluation. | `Flag Manager` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-variant" href="#feature-flag-variant">`feature_flag.variant`</a> | string | SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the value can be used. [1] | `red`; `true`; `on` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-context-id" href="#feature-flag-context-id">`feature_flag.context.id`</a> | string | The unique identifier for the flag evaluation context. For example, the targeting key. | `5157782b-2203-4c80-a857-dbbd5e7761db` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-key" href="#feature-flag-key">`feature_flag.key`</a> | string | The lookup key of the feature flag. | `logo-color` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-reason" href="#feature-flag-reason">`feature_flag.reason`</a> | string | The reason code which shows how a feature flag value was determined. | `static`; `targeting_match`; `error`; `default` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-set-id" href="#feature-flag-set-id">`feature_flag.set.id`</a> | string | The identifier of the [flag set](https://openfeature.dev/specification/glossary/#flag-set) which the feature flag belongs to in a flag management system. | `proj-1`; `ab98sgs`; `service1/dev` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
dyladan marked this conversation as resolved.
Show resolved Hide resolved
| <a id="feature-flag-system" href="#feature-flag-system">`feature_flag.system`</a> | string | Identifies the feature flag provider. | `Flag Manager` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-variant" href="#feature-flag-variant">`feature_flag.variant`</a> | string | A semantic identifier for an evaluated flag value. [1] | `red`; `true`; `on` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="feature-flag-version" href="#feature-flag-version">`feature_flag.version`</a> | string | The version of the ruleset used during the evaluation. This may be any stable value which uniquely identifies the ruleset. | `1`; `01ABCDEF` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** A semantic identifier, commonly referred to as a variant, provides a means
for referring to a value without including the value itself. This can
provide additional context for understanding the meaning behind a value.
For example, the variant `red` maybe be used for the value `#c05543`.

A stringified version of the value can be used in situations where a
semantic identifier is unavailable. String representation of the value
should be determined by the implementer.
`feature_flag.reason` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
|---|---|---|
| `cached` | The resolved value was retrieved from cache. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `default` | The resolved value fell back to a pre-configured value (no dynamic evaluation occurred or dynamic evaluation yielded no result). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `disabled` | The resolved value was the result of the flag being disabled in the management system. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `error` | The resolved value was the result of an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `split` | The resolved value was the result of pseudorandom assignment. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `stale` | The resolved value is non-authoritative or possibly out of date | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `static` | The resolved value is static (no dynamic evaluation). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `targeting_match` | The resolved value was the result of a dynamic evaluation, such as a rule or specific user-targeting. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `unknown` | The reason for the resolved value could not be determined. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

## Deprecated Feature Flag Attributes

Describes deprecated Feature Flag attributes.

| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| <a id="feature-flag-provider-name" href="#feature-flag-provider-name">`feature_flag.provider_name`</a> | string | Deprecated, use `feature_flag.provider.id` instead. | `Flag Manager` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `feature_flag.provider.id`. |
dyladan marked this conversation as resolved.
Show resolved Hide resolved
42 changes: 33 additions & 9 deletions docs/feature-flags/feature-flags-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ context.
The table below indicates which attributes should be added to the
[LogRecord](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.37.0/specification/logs/data-model.md#log-and-event-record-definition) and their types.

<!-- semconv log-feature_flag -->
<!-- semconv feature_flag.evaluation -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
Expand All @@ -46,24 +46,48 @@ The table below indicates which attributes should be added to the

**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

The event name MUST be `feature_flag`.
The event name MUST be `feature_flag.evaluation`.

This event describes feature flag evaluation representation on a Log Record.
This semantic convention defines the attributes used to represent a feature flag evaluation as an event. A `feature_flag.evaluation` event SHOULD be emitted whenever a feature flag value is evaluated, which may happen many times over the course of an application lifecycle. For example, a website A/B testing different animations may evaluate a flag each time a button is clicked. A `feature_flag.evaluation` event is emitted on each evaluation even if the result is the same.

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`feature_flag.key`](/docs/attributes-registry/feature-flag.md) | string | The unique identifier of the feature flag. | `logo-color` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.provider_name`](/docs/attributes-registry/feature-flag.md) | string | The name of the service provider that performs the flag evaluation. | `Flag Manager` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.variant`](/docs/attributes-registry/feature-flag.md) | string | SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the value can be used. [1] | `red`; `true`; `on` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.key`](/docs/attributes-registry/feature-flag.md) | string | The lookup key of the feature flag. | `logo-color` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.variant`](/docs/attributes-registry/feature-flag.md) | string | A semantic identifier for an evaluated flag value. [1] | `red`; `true`; `on` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.context.id`](/docs/attributes-registry/feature-flag.md) | string | The unique identifier for the flag evaluation context. For example, the targeting key. | `5157782b-2203-4c80-a857-dbbd5e7761db` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.reason`](/docs/attributes-registry/feature-flag.md) | string | The reason code which shows how a feature flag value was determined. | `static`; `targeting_match`; `error`; `default` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.set.id`](/docs/attributes-registry/feature-flag.md) | string | The identifier of the [flag set](https://openfeature.dev/specification/glossary/#flag-set) which the feature flag belongs to in a flag management system. | `proj-1`; `ab98sgs`; `service1/dev` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.system`](/docs/attributes-registry/feature-flag.md) | string | Identifies the feature flag provider. | `Flag Manager` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`feature_flag.version`](/docs/attributes-registry/feature-flag.md) | string | The version of the ruleset used during the evaluation. This may be any stable value which uniquely identifies the ruleset. | `1`; `01ABCDEF` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** A semantic identifier, commonly referred to as a variant, provides a means
for referring to a value without including the value itself. This can
provide additional context for understanding the meaning behind a value.
For example, the variant `red` maybe be used for the value `#c05543`.

A stringified version of the value can be used in situations where a
semantic identifier is unavailable. String representation of the value
should be determined by the implementer.
**[2]:** If feature flag provider supplies a variant or equivalent concept.

`feature_flag.reason` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

| Value | Description | Stability |
|---|---|---|
| `cached` | The resolved value was retrieved from cache. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `default` | The resolved value fell back to a pre-configured value (no dynamic evaluation occurred or dynamic evaluation yielded no result). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `disabled` | The resolved value was the result of the flag being disabled in the management system. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `error` | The resolved value was the result of an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `split` | The resolved value was the result of pseudorandom assignment. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `stale` | The resolved value is non-authoritative or possibly out of date | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `static` | The resolved value is static (no dynamic evaluation). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `targeting_match` | The resolved value was the result of a dynamic evaluation, such as a rule or specific user-targeting. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `unknown` | The reason for the resolved value could not be determined. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**Body fields:**

| Body Field | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `value` | undefined | The evaluated value of the feature flag. | `#ff0000`; `1`; `true` | `Conditionally Required` [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** If and only if feature flag provider does not supply variant or equivalent concept. Otherwise, `value` should be treated as opt-in.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
Expand Down
80 changes: 0 additions & 80 deletions docs/feature-flags/feature-flags-spans.md

This file was deleted.

12 changes: 12 additions & 0 deletions model/feature-flag/deprecated/registry-deprecated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
groups:
- id: registry.feature_flag.deprecated
type: attribute_group
display_name: Deprecated Feature Flag Attributes
brief: "Describes deprecated Feature Flag attributes."
attributes:
- id: feature_flag.provider_name
type: string
brief: 'Deprecated, use `feature_flag.provider.id` instead.'
stability: experimental
deprecated: "Replaced by `feature_flag.provider.id`."
dyladan marked this conversation as resolved.
Show resolved Hide resolved
examples: ["Flag Manager"]
14 changes: 0 additions & 14 deletions model/feature-flag/events.yaml

This file was deleted.

42 changes: 37 additions & 5 deletions model/feature-flag/logs.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
groups:
- id: log-feature_flag
- id: feature_flag.evaluation
type: event
stability: experimental
name: feature_flag
name: feature_flag.evaluation
brief: >
This event describes feature flag evaluation representation on a Log Record.
This semantic convention defines the attributes used to represent a
dyladan marked this conversation as resolved.
Show resolved Hide resolved
feature flag evaluation as an event.
A `feature_flag.evaluation` event SHOULD be emitted whenever a feature flag
value is evaluated, which may happen many times over the course of an
application lifecycle.
For example, a website A/B testing different animations may evaluate a
flag each time a button is clicked.
A `feature_flag.evaluation` event is emitted on each evaluation even if the result is the same.
attributes:
- ref: feature_flag.key
- ref: feature_flag.provider_name
requirement_level: required
- ref: feature_flag.variant
requirement_level:
conditionally_required: If feature flag provider supplies a variant or equivalent concept.
- ref: feature_flag.system
requirement_level: recommended
- ref: feature_flag.context.id
requirement_level: recommended
- ref: feature_flag.version
requirement_level: recommended
- ref: feature_flag.set.id
requirement_level: recommended
- ref: feature_flag.reason
requirement_level: recommended
body:
id: feature_flag.evaluation
type: map
requirement_level: recommended
fields:
- id: value
type: undefined
stability: experimental
brief: The evaluated value of the feature flag.
requirement_level:
conditionally_required: >
If and only if feature flag provider does not supply variant or equivalent concept.
Otherwise, `value` should be treated as opt-in.
examples: ["#ff0000", "1", "true"]
Loading
Loading