otelfeature

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package otelfeature implements tracing and metric collection for feature flag usage using OpenTelemetry.

Index

Examples

Constants

View Source
const (
	// AttributeFeatureEnabled is true if a flag was enabled or if running the experimental case in an Experiment.
	AttributeFeatureEnabled = attribute.Key("feature.enabled")

	// AttributeFeatureName contains the name of the used feature flag.
	AttributeFeatureName = attribute.Key("feature.name")

	// AttributeExperimentSuccess is true if an experiment ran with not errors and the results are considered equal.
	AttributeExperimentSuccess = attribute.Key("feature.experiment.success")

	// AttributeRecoveredValue contains the recovered value from a panic converted into a string using fmt.Sprint.
	AttributeRecoveredValue = attribute.Key("feature.case.recovered")
)

Variables

This section is empty.

Functions

func Tracer

func Tracer(opts *Opts) (feature.Tracer, error)

Tracer returns a pre-configured feature.Tracer that automatically traces all feature.Flag and feature.Case usage while also gathering metrics.

An optional Opts struct can be given to customize the providers for the created metric.Meter and trace.Tracer.

Example
package main

import (
	"github.com/nussjustin/feature"
	"github.com/nussjustin/feature/otelfeature"
)

func main() {
	tracer, err := otelfeature.Tracer(nil)
	if err != nil {
		// Handle the error
	}
	feature.SetTracer(tracer)
}
Output:

Types

type Opts added in v0.2.0

type Opts struct {
	// MeterProvider is used for creating meters for all tracked metrics.
	//
	// If nil the global provider is used.
	MeterProvider metric.MeterProvider

	// TracerProvider is used for creating a [trace.Tracer].
	//
	// If nil the global provider is used.
	TracerProvider trace.TracerProvider
}

Opts can be used to customize the feature.Tracer returned by Tracer.

All fields are optional.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL