Documentation
¶
Overview ¶
Package openfeature provides a lightweight bridge between the tracer's early Remote Config subscription and the late-created OpenFeature DatadogProvider.
This package intentionally has minimal dependencies (only internal/remoteconfig) so the tracer can import it without pulling in the OpenFeature SDK or OTel.
Index ¶
- Constants
- func AddSpanEnrichment(key any, eval *FeatureFlagEvaluation)
- func AttachCallback(cb Callback) bool
- func GetBufferedForTest() remoteconfig.ProductUpdate
- func ResetForTest()
- func SetBufferedForTest(u remoteconfig.ProductUpdate)
- func SetSubscribedForTest(v bool)
- func SubscribeProvider(cb remoteconfig.ProductCallback) (tracerOwnsSubscription bool, err error)
- func SubscribeRC() error
- type Callback
- type FeatureFlagEvaluation
- type SpanEnrichment
Constants ¶
const (
// FFEProductName is the RC product name for feature flag evaluation.
FFEProductName = "FFE_FLAGS"
)
Variables ¶
This section is empty.
Functions ¶
func AddSpanEnrichment ¶
func AddSpanEnrichment(key any, eval *FeatureFlagEvaluation)
AddSpanEnrichment records eval in the global span enrichment store.
func AttachCallback ¶
AttachCallback wires the given callback to the global RC subscription. If SubscribeRC() was called (i.e. the tracer subscribed), it replays any buffered config and returns true. Otherwise returns false, meaning the caller should fall back to its own RC subscription.
func GetBufferedForTest ¶
func GetBufferedForTest() remoteconfig.ProductUpdate
GetBufferedForTest returns the current buffered update for testing.
func SetBufferedForTest ¶
func SetBufferedForTest(u remoteconfig.ProductUpdate)
SetBufferedForTest sets a buffered update for testing.
func SetSubscribedForTest ¶
func SetSubscribedForTest(v bool)
SetSubscribedForTest sets the subscribed flag without actually calling Subscribe.
func SubscribeProvider ¶
func SubscribeProvider(cb remoteconfig.ProductCallback) (tracerOwnsSubscription bool, err error)
SubscribeProvider attempts to subscribe a provider callback to RC. It holds the subscription mutex to prevent races with SubscribeRC.
func SubscribeRC ¶
func SubscribeRC() error
SubscribeRC subscribes to the FFE_FLAGS RC product using a forwarding callback. It is called by the tracer during startRemoteConfig() so that FFE_FLAGS is included in the first RC poll.
Types ¶
type Callback ¶
type Callback func(update remoteconfig.ProductUpdate) map[string]rc.ApplyStatus
Callback is a function that processes an RC product update and returns apply statuses. This matches the signature of DatadogProvider.rcCallback.
type FeatureFlagEvaluation ¶
type FeatureFlagEvaluation struct {
FlagKey string
// SerialId is the optional serial ID from flag metadata. Nil for runtime defaults.
SerialID *uint32
// Subject is the targeting key / subject of experiment. Non-empty only when evaluation
// should be logged (doLog=true).
Subject string
// DefaultValue is the default value used. Non-nil only when a runtime default was used.
DefaultValue any
}
FeatureFlagEvaluation represents a single feature flag evaluation to be recorded in span enrichment.
type SpanEnrichment ¶
type SpanEnrichment struct {
// contains filtered or unexported fields
}
SpanEnrichment accumulates feature flag evaluations to be encoded as span tags.
SpanEnrichment is not safe for concurrent use on its own. Thread safety is provided externally: every caller must hold the owning span's mu (ddtrace/tracer.Span.mu) before calling any method.
func DrainSpanEnrichment ¶
func DrainSpanEnrichment(key any) *SpanEnrichment
DrainSpanEnrichment removes and returns enrichment from the global span enrichment store.
func (*SpanEnrichment) GetSpanTags ¶
func (se *SpanEnrichment) GetSpanTags() map[string]string
GetSpanTags returns span tags encoding accumulated feature flag evaluations. The caller must hold the owning span's mu.