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

feat: add appendix D (observability) #287

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
51 changes: 51 additions & 0 deletions specification/appendix-d-observability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
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:

| Evaluation Details Field | Log Record Attribute | Notes |
| ------------------------ | --------------------------------------- | ---------------------------------------------------- |
| `flag key` | `feature_flag.key` | See: [flag key](./glossary.md#flag-key) |
| `error code` | `error.type` | See: [error code](./types.md#error-code) |
| `variant` | `feature_flag.variant` | See: [variant](./glossary.md#variant) |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's questions about how exactly to represent value (important if provider cannot supply variant):

  • is it represented in the body?
  • can it be of any type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it represented in the body?

Do you mean the body of the log record?

The spec says:

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

And the type is undefined there as there is no any type in OTEL.
Recently there was also opened a PR to add the value_type to the event: open-telemetry/semantic-conventions#1689

| `error message` | `feature_flag.evaluation.error.message` | An error message associated with a failed evaluation |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we here also make clear that it is not recommended to not repat error.type here, like it's stated in the otel semcon?

| `reason` | `feature_flag.evaluation.reason` | 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 Metadata

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

| Flag Metadata Key | Log Record Attribute | Notes |
| ----------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `contextId` | `feature_flag.context.id` | 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. |
| `flagSetId` | `feature_flag.set.id` | A logical identifier for the [flag set](./glossary.md#flag-set). |
| `flagSetVersion` | `feature_flag.version` | A version string (format unspecified) for the [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

| Provider Metadata Field | Log Record Attribute | Notes |
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------ |
| `name` | `feature_flag.provider_name` | The name of the provider as defined in the `provider metadata`, available in the `hook context`. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should add a note that it's recommended to keep provider names consistent across provider implementations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth mentioning. I guess providers can decide for themselves if they want the name to be consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too @toddbaert, it might be interesting for some consumers to see the provider implementations instead of a common name. But I guess @beeme1mr's case is the more common.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also with @toddbaert regarding a provider name. But I can imagine your point @beeme1mr of having an identifiying property for post processing. Maybe there should also be a provider_id property we could propose in otel?

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
Loading