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
Stabilize exemplars #5249
Comments
We need to export an |
We do not comply with this. |
We do not comply with this. |
Our current implementation complies with this. |
We do not comply with this. |
We do not comply with this. This is a clarification of #5249 (comment). |
Our implementation supports these filters. |
opentelemetry-go/sdk/metric/internal/exemplar/reservoir.go Lines 14 to 33 in 7ee6ff1
We comply with this. |
We comply with this. |
We comply with these. |
opentelemetry-go/sdk/metric/exemplar.go Lines 28 to 67 in 7ee6ff1
We comply with this. |
We comply with this:
|
We comply with this: https://github.com/open-telemetry/opentelemetry-go/blob/7ee6ff19b51eb4bffdd48639ac5698c9ee8932d6/sdk/metric/internal/exemplar/hist.go |
We do not comply with this. |
This is going to be a challenge. The Not sure how we can restructure the |
To address the generics, we can create a type ValueType uint8
const (
UnknownValueType ValueType = 0
Int64ValueType ValueType = 1
Float64ValueType ValueType = 2
)
type Value struct {
t ValueType
val uint64
}
func NewValue[N int64 | float64](val N) Value {
switch v := any(val).(type) {
case int64:
return newInt64Value(v)
case float64:
return newFloat64Value(v)
}
return Value{}
}
func newInt64Value(val int64) Value {
return Value{t: Int64ValueType, val: uint64(val)}
}
func newFloat64Value(val float64) Value {
return Value{t: Float64ValueType, val: math.Float64bits(val)}
}
func (v Value) Type() ValueType { return v.t }
func (v Value) Int64() int64 {
if v.t == Int64ValueType {
return v.int64()
}
return 0
}
func (v Value) int64() int64 { return int64(v.val) }
func (v Value) Float64() float64 {
if v.t == Float64ValueType {
return math.Float64frombits(v.val)
}
return 0
}
func (v Value) float64() float64 { return math.Float64frombits(v.val) }
func (v Value) Any() any {
switch v.t {
case Int64ValueType:
return v.int64()
case Float64ValueType:
return v.float64()
}
return nil
} From there we can define an exemplar: // Exemplar is a measurement sampled from a timeseries providing a typical
// example.
type Exemplar struct {
// FilteredAttributes are the attributes recorded with the measurement but
// filtered out of the timeseries' aggregated data.
FilteredAttributes []attribute.KeyValue
// Time is the time when the measurement was recorded.
Time time.Time
// Value is the measured value.
Value Value
// SpanID is the ID of the span that was active during the measurement. If
// no span was active or the span was not sampled this will be empty.
SpanID []byte `json:",omitempty"`
// TraceID is the ID of the trace the active span belonged to during the
// measurement. If no span was active or the span was not sampled this will
// be empty.
TraceID []byte `json:",omitempty"`
} and a // Reservoir holds the sampled exemplar of measurements made.
type Reservoir interface {
// Offer accepts the parameters associated with a measurement. The
// parameters will be stored as an exemplar if the Reservoir decides to
// sample the measurement.
//
// The passed ctx needs to contain any baggage or span that were active
// when the measurement was made. This information may be used by the
// Reservoir in making a sampling decision.
//
// The time t is the time when the measurement was made. The val and attr
// parameters are the value and dropped (filtered) attributes of the
// measurement respectively.
Offer(ctx context.Context, t time.Time, val Value, attr []attribute.KeyValue)
// Collect returns all the held exemplars.
//
// The Reservoir state is preserved after this call.
Collect(dest *[]Exemplar)
} |
I'm working to refactor |
Moving to the v1.28.0 milestone as #5285 needs to be released and used before that code is exported to resolve this. |
Exemplars are now stable in the specification.
Compliance TODOs
ExemplarReservoir
type and accept it as stream configurationExemplarFilter
to be a configured for aMeterProvider
with a default value ofTraceBased
(continue to support environment variable configuration of theExemplarFilter
)Stabilization procedure and plan
TODO:
The text was updated successfully, but these errors were encountered: