Skip to content

Commit

Permalink
feat: add appendix D (observability) (#287)
Browse files Browse the repository at this point in the history
- adds small appendix section to spec that defines how particular SDK
fields are mapped to the recently merge OTel semantics
- this allows providers and hooks to export OTel data consistently for
easy interop
- adds a couple supporting glossary liks

---------

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert authored Jan 15, 2025
1 parent c287b58 commit 6c673d7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions specification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ sidebar_position: 0
- [Evaluation Context](./sections/03-evaluation-context.md)
- [Hooks](./sections/04-hooks.md)
- [Events](./sections/05-events.md)
- [Tracking](./sections/06-tracking.md)
- [Appendix A: Included Utilities](./appendix-a-included-utilities.md)
- [Appendix B: Gherkin Suites](./appendix-b-gherkin-suites.md)
- [Appendix C: OFREP](./appendix-c-ofrep.md)
- [Appendix D: Observability](./appendix-d-observability.md)

## Conformance

Expand Down
60 changes: 60 additions & 0 deletions specification/appendix-d-observability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: appendix-d
title: "Appendix D: Observability"
description: Conventions for OpenFeature telemetry signals
sidebar_position: 5
---

# Appendix D: Observability

This document describes conventions for extracting data from the OpenFeature SDK for use in telemetry signals.
It primarily focuses on providing recommendations for mapping well-known fields in OpenFeature to [OpenTelemetry feature-flag log records](https://opentelemetry.io/docs/specs/semconv/feature-flags/feature-flags-logs/) and other semantic conventions.

## Evaluations

Flag evaluation telemetry comprises data resolved from the provider resolution (evaluation details and flag metadata) as well as metadata about the provider itself.
This is particularly relevant to telemetry-related [hooks](./sections/04-hooks.md).

### Evaluation Details

The following describes how fields on the [evaluation details](types.md#evaluation-details) are mapped to feature flag log records:

| Log Record Attribute | Source Field or Derived Value from Evaluation Details | Notes |
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `feature_flag.key` | `flag key` | See: [flag key](./glossary.md#flag-key) |
| `error.type` | `error code` | See: [error code](./types.md#error-code) |
| `feature_flag.variant` | `variant` | See: [variant](./glossary.md#variant) |
| `feature_flag.evaluation.error.message` | `error message` | A human-readable error message associated with a failed evaluation. For programmatic purposes, refer to `error code`. |
| `feature_flag.evaluation.reason` | `reason` | See: [reason](./types.md#resolution-reason) |
| `feature_flag.evaluation.value.type` | One of `"array"`, `"boolean"`, `"byte_array"`, `"float"`, `"int"`, `"map"`, `"null"`, `"string"` or `"unknown"`, representing the type of the `evaluation details'` `value` field | See: [reason](./types.md#resolution-reason) |

> [!NOTE]
> The `error.type` and `feature_flag.evaluation.reason` enumerations use a lowercase "snake_case" convention (see [OpenTelemetry feature-flag log records](https://opentelemetry.io/docs/specs/semconv/feature-flags/feature-flags-logs/)).
> OpenFeature [error codes](types.md#error-code) and [resolution reasons](./types.md#resolution-reason) should be transformed accordingly by integrations which include this data.
#### Flag Value

The flag value is required if the `feature_flag.variant` is not set (and optional otherwise), and is defined in a the event body:

| Body Field | Source Field from Evaluation Details | Notes |
| ---------- | ------------------------------------ | ------------------------------------------- |
| `value` | `value` | The type of the `value` field is undefined. |

### Flag Metadata

The following describes how keys in [flag metadata](types.md#flag-metadata) are mapped to feature flag log records:

| Log Record Attribute | Flag Metadata Key | Notes |
| ------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `feature_flag.context.id` | `contextId` | The context identifier returned in the flag metadata uniquely identifies the subject of the flag evaluation. If not available, the [targeting key](./glossary.md#targeting-key) should be used. |
| `feature_flag.set.id` | `flagSetId` | A logical identifier for the [flag set](./glossary.md#flag-set). |
| `feature_flag.version` | `version` | A version string (format unspecified) for the flag or [flag set](./glossary.md#flag-set). |

> [!NOTE]
> Keys in flag metadata use the "camelCase" casing convention, while the OpenTelemetry standard uses a namespaced "snake_case" convention.
### Provider Metadata

| Log Record Attribute | Provider Metadata Field | Notes |
| ---------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------ |
| `feature_flag.provider_name` | `name` | The name of the provider as defined in the `provider metadata`, available in the `hook context`. |
2 changes: 2 additions & 0 deletions specification/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ A structure which contains a subset of the fields defined in the `evaluation det
- variant (string, optional)
- flag metadata ([flag metadata](#flag-metadata), optional)

#### Resolution Reason

A set of pre-defined reasons is enumerated below:

| Reason | Explanation |
Expand Down

0 comments on commit 6c673d7

Please sign in to comment.