mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* [Generator] Add DRAIN span_name sanitizer * Fix linter * Fix formatting * Update default manifest * Fix build error in update-fixtures * Remove bad test * Remove misleading comment * Add per-tenant override for drain mode * Do a machines job * Address PR feedback * Address PR review: rename drain_mode config and improve sanitizer - Rename `drain_mode` to `span_name_sanitization` across all config, legacy config, interfaces, and overrides for better user-facing clarity - Add explicit default value "disabled" in RegisterFlagsAndApplyDefaults - Add ValidateSpanNameSanitization function in validation/fields.go - Rename metrics to remove DRAIN reference: `drain_spans_compacted_total` -> `spans_sanitized_total` `post_drain_demand_estimate` -> `post_sanitization_demand_estimate` - Pass configured staleDuration to NewDrainSanitizer instead of hardcoded 15min, consistent with other registry components - Extract "span_name" magic string to labelSpanName constant - Update all tests with new names and signatures * Update manifest * Use empty string as disabled * Update CHANGELOG.md Co-authored-by: Suraj Nath <[email protected]> * Update manifest --------- Co-authored-by: Suraj Nath <[email protected]>
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package otter
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"runtime/debug"
|
|
)
|
|
|
|
const (
|
|
// ErrNotFound should be returned from a Loader.Load/Loader.Reload to indicate that an entry is
|
|
// missing at the underlying data source. This helps the cache to determine
|
|
// if an entry should be deleted.
|
|
//
|
|
// NOTE: this only applies to Cache.Get/Cache.Refresh/Loader.Load/Loader.Reload. For Cache.BulkGet/Cache.BulkRefresh,
|
|
// this works implicitly if you return a map without the key.
|
|
ErrNotFound strError = "otter: the entry was not found in the data source"
|
|
)
|
|
|
|
// strError allows declaring errors as constants.
|
|
type strError string
|
|
|
|
func (err strError) Error() string { return string(err) }
|
|
|
|
// A panicError is an arbitrary value recovered from a panic
|
|
// with the stack trace during the execution of given function.
|
|
type panicError struct {
|
|
value any
|
|
stack []byte
|
|
}
|
|
|
|
// Error implements error interface.
|
|
func (p *panicError) Error() string {
|
|
return fmt.Sprintf("%v\n\n%s", p.value, p.stack)
|
|
}
|
|
|
|
func (p *panicError) Unwrap() error {
|
|
err, ok := p.value.(error)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func newPanicError(v any) error {
|
|
stack := debug.Stack()
|
|
|
|
// The first line of the stack trace is of the form "goroutine N [status]:"
|
|
// but by the time the panic reaches cache the goroutine may no longer exist
|
|
// and its status will have changed. Trim out the misleading line.
|
|
if line := bytes.IndexByte(stack, '\n'); line >= 0 {
|
|
stack = stack[line+1:]
|
|
}
|
|
return &panicError{value: v, stack: stack}
|
|
}
|