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

Add feature flagging semantic conventions #2529

Merged
merged 29 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2fd9ad
Add feature flagging semantic conventions
beeme1mr Aug 31, 2022
ce98e18
Changed context examples
beeme1mr Sep 2, 2022
838035b
Improved ascii diagram
beeme1mr Sep 2, 2022
18cc214
moved the spec into the correct folder
beeme1mr Sep 2, 2022
7704070
updated the diagram note
beeme1mr Sep 2, 2022
659621c
updated based on feedback
beeme1mr Sep 2, 2022
f90931b
reformated with the table generator
beeme1mr Sep 2, 2022
7db4fa5
add type span
beeme1mr Sep 2, 2022
bfdb75f
refactor to one sentence per line
beeme1mr Sep 2, 2022
dc5df80
add additional motivation
beeme1mr Sep 2, 2022
ae151f8
add feature flags PR to the change log
beeme1mr Sep 28, 2022
27db9a8
update span attribute names based on feedback
beeme1mr Sep 28, 2022
914de91
refactor: use events instead of spans
beeme1mr Oct 20, 2022
d45b754
move changelog entry to unreleased
beeme1mr Oct 20, 2022
2378370
Removing trailing whitespace
beeme1mr Oct 24, 2022
5ebd8c9
Removed example from toc
beeme1mr Oct 24, 2022
0de6f40
Merge branch 'main' into feature-flag-support
beeme1mr Oct 24, 2022
ff46b65
fix lint issues
beeme1mr Oct 25, 2022
e336d4f
add new line to yaml
beeme1mr Oct 25, 2022
db4c302
Add log record semconv for feature flags
dyladan Nov 21, 2022
95ba718
Merge remote-tracking branch 'origin/main' into pr/beeme1mr/2529
dyladan Nov 21, 2022
5e8c444
Fix links
dyladan Nov 21, 2022
b2274b4
Merge branch 'main' into feature-flag-support
dyladan Nov 28, 2022
c1b086b
Merge branch 'main' into feature-flag-support
dyladan Nov 30, 2022
2198d30
cross-link feature flag semconv files
dyladan Nov 30, 2022
777d9b9
Merge branch 'main' into feature-flag-support
arminru Dec 1, 2022
a6debfb
Merge remote-tracking branch 'origin/main' into pr/beeme1mr/2529
dyladan Dec 1, 2022
061bafa
Merge branch 'feature-flag-support' of github.com:beeme1mr/openteleme…
dyladan Dec 1, 2022
00a88e7
Merge branch 'main' into feature-flag-support
dyladan Dec 1, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ release.

- Add IBM Cloud as a cloud provider.
([#2965](https://github.com/open-telemetry/opentelemetry-specification/pull/2965))
- Add semantic conventions for Feature Flags
([#2529](https://github.com/open-telemetry/opentelemetry-specification/pull/2529))
- Rename `rpc.request.metadata.<key>` and `rpc.response.metadata.<key>` to
`rpc.grpc.request.metadata.<key>` and `rpc.grpc.response.metadata.<key>`
([#2981](https://github.com/open-telemetry/opentelemetry-specification/pull/2981))
Expand Down
11 changes: 11 additions & 0 deletions semantic_conventions/logs/log-feature_flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
groups:
- id: log-feature_flag
type: event
prefix: feature_flag
brief: >
This document defines attributes for feature flag evaluations
represented using Log Records.
attributes:
- ref: feature_flag.key
- ref: feature_flag.provider_name
- ref: feature_flag.variant
34 changes: 34 additions & 0 deletions semantic_conventions/trace/feature-flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
groups:
- id: feature_flag
prefix: feature_flag
beeme1mr marked this conversation as resolved.
Show resolved Hide resolved
type: event
brief: >
This semantic convention defines the attributes used to represent a
feature flag evaluation as an event.
attributes:
- id: key
type: string
requirement_level: required
brief: The unique identifier of the feature flag.
examples: ["logo-color"]
- id: provider_name
type: string
requirement_level: recommended
brief: The name of the service provider that performs the flag evaluation.
examples: ["Flag Manager"]
- id: variant
type: string
requirement_level: recommended
examples: ["red", "true", "on"]
brief: >
SHOULD be a semantic identifier for a value. If one is unavailable, a
stringified version of the value can be used.
note: |-
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.
53 changes: 53 additions & 0 deletions specification/logs/semantic_conventions/feature-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Semantic Conventions for Feature Flag Evaluations

**Status**: [Experimental](../../document-status.md)

This document defines semantic conventions for recording feature flag evaluations as
a [log record](../api.md#logrecord) emitted through the
[Logger API](../api.md#emit-logrecord).
This is useful when a flag is evaluated outside of a transaction context
such as when the application loads or on a timer.
To record a flag evaluation as a part of a transaction context,
consider [recording it as a span event](../../trace/semantic_conventions/feature-flags.md).

For more information about why it is useful to capture feature flag evaluations,
refer to the [motivation](../../trace/semantic_conventions/feature-flags.md#motivation)
section of the trace semantic convention for feature flag evaluations.

<!-- toc -->

- [Recording an Evaluation](#recording-an-evaluation)
- [Attributes](#attributes)

<!-- tocstop -->

## Recording an Evaluation

Feature flag evaluations SHOULD be recorded as attributes on the
[LogRecord](../api.md#logrecord) passed to the [Logger](../api.md#logger) emit
operations. Evaluations MAY be recorded on "logs" or "events" depending on the
context.

## Attributes

The table below indicates which attributes should be added to the
[LogRecord](../api.md#logrecord) and their types.

<!-- semconv log-feature_flag -->
The event name MUST be `feature_flag`.

| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`feature_flag.key`](../../trace/semantic_conventions/feature-flags.md) | string | The unique identifier of the feature flag. | `logo-color` | Required |
| [`feature_flag.provider_name`](../../trace/semantic_conventions/feature-flags.md) | string | The name of the service provider that performs the flag evaluation. | `Flag Manager` | Recommended |
| [`feature_flag.variant`](../../trace/semantic_conventions/feature-flags.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 |

**[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.
<!-- endsemconv -->
1 change: 1 addition & 0 deletions specification/trace/semantic_conventions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The following semantic conventions for spans are defined:
* [FaaS](faas.md): For [Function as a Service](https://en.wikipedia.org/wiki/Function_as_a_service) (e.g., AWS Lambda) spans.
* [Exceptions](exceptions.md): For recording exceptions associated with a span.
* [Compatibility](compatibility.md): For spans generated by compatibility components, e.g. OpenTracing Shim layer.
* [Feature Flags](feature-flags.md): For recording feature flag evaluations associated with a span.

The following library-specific semantic conventions are defined:

Expand Down
57 changes: 57 additions & 0 deletions specification/trace/semantic_conventions/feature-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Semantic conventions for Feature Flags

beeme1mr marked this conversation as resolved.
Show resolved Hide resolved
**Status**: [Experimental](../../document-status.md)

This document defines semantic conventions for recording dynamic feature flag
evaluations within a transaction as span events.
To record an evaluation outside of a transaction context, consider
[recording it as a log record](../../logs/semantic_conventions/feature-flags.md).

<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` -->

<!-- toc -->

- [Motivation](#motivation)
- [Overview](#overview)
- [Convention](#convention)

<!-- tocstop -->

## Motivation
beeme1mr marked this conversation as resolved.
Show resolved Hide resolved

Features flags are commonly used in modern applications to decouple feature releases from deployments.
Many feature flagging tools support the ability to update flag configurations in near real-time from a remote feature flag management service.
They also commonly allow rulesets to be defined that return values based on contextual information.
For example, a feature could be enabled only for a specific subset of users based on context (e.g. users email domain, membership tier, country).

Since feature flags are dynamic and affect runtime behavior, it's important to collect relevant feature flag telemetry signals.
This can be used to determine the impact a feature has on a request, enabling enhanced observability use cases, such as A/B testing or progressive feature releases.

## Overview

The following semantic convention defines how feature flags can be represented as an `Event` in OpenTelemetry.
The terminology was defined in the [OpenFeature specification](https://docs.openfeature.dev/docs/specification/), which represents an industry consensus.
It's intended to be vendor neutral and provide flexibility for current and future use cases.

## Convention

beeme1mr marked this conversation as resolved.
Show resolved Hide resolved
A flag evaluation SHOULD be recorded as an Event on the span during which it occurred.

<!-- semconv feature_flag -->
The event name MUST be `feature_flag`.

| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `feature_flag.key` | string | The unique identifier of the feature flag. | `logo-color` | Required |
| `feature_flag.provider_name` | string | The name of the service provider that performs the flag evaluation. | `Flag Manager` | Recommended |
| `feature_flag.variant` | 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 |

**[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.
<!-- endsemconv -->
beeme1mr marked this conversation as resolved.
Show resolved Hide resolved