6.0.2 • Published 2 years ago

@openfeature/open-telemetry-hook v6.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

:warning: This package will be deprecated. Please use the telemetry hooks package from @openfeature/open-telemetry-hooks.

OpenTelemetry Hook

The OpenTelemetry hook for OpenFeature provides a spec compliant way to automatically add a feature flag evaluation to a span as a span event. 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.

Installation

$ npm install @openfeature/open-telemetry-hook

Peer dependencies

Confirm that the following peer dependencies are installed.

$ npm install @openfeature/js-sdk @opentelemetry/api

Usage

OpenFeature provides various ways to register hooks. The location that a hook is registered affects when the hook is run. It's recommended to register the OpenTelemetryHook globally in most situations but it's possible to only enable the hook on specific clients. You should never register the OpenTelemetryHook globally and on a client.

More information on hooks can be found in the OpenFeature documentation.

Register Globally

The OpenTelemetryHook can be set on the OpenFeature singleton. This will ensure that every flag evaluation will always create a span event, if am active span is available.

import { OpenFeature } from '@openfeature/js-sdk';
import { OpenTelemetryHook } from '@openfeature/open-telemetry-hook';

OpenFeature.addHooks(new OpenTelemetryHook());

Register Per Client

The OpenTelemetryHook can be set on an individual client. This should only be done if it wasn't set globally and other clients shouldn't use this hook. Setting the hook on the client will ensure that every flag evaluation performed by this client will always create a span event, if am active span is available.

import { OpenFeature } from '@openfeature/js-sdk';
import { OpenTelemetryHook } from '@openfeature/open-telemetry-hook';

const client = OpenFeature.getClient('my-app');
client.addHooks(new OpenTelemetryHook());

Development

Building

Run nx package hooks-open-telemetry to build the library.

Running unit tests

Run nx test hooks-open-telemetry to execute the unit tests via Jest.

6.0.2

2 years ago

5.1.1

3 years ago

5.1.0

3 years ago

6.0.1

2 years ago

6.0.0

2 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.2.3-alpha

3 years ago

1.2.2-alpha

3 years ago

1.2.1-alpha

3 years ago

1.2.0-alpha

3 years ago

1.1.0-alpha

3 years ago

0.2.1-alpha.6

3 years ago

0.2.0-test

3 years ago

0.0.1-test

3 years ago

1.0.0-alpha.6

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago