Documentation
¶
Index ¶
- Variables
- func AddNewTagKey(views []*view.View, key *tag.Key) []*view.View
- func AddSpanToRequest(r *http.Request, span trace.Span)
- func BinaryFromSpanContext(sc trace.SpanContext) []byte
- func CreateRulesMap(rules []config.MetricsRule) error
- func GetTraceSamplingRate(rate string) float64
- func IsTracingEnabled(rate string) bool
- func NewMeasureView(measure stats.Measure, keys []tag.Key, aggregation *view.Aggregation) *view.View
- func NormalizeTagValue(name string, key tag.Key, value string) string
- func SpanContextFromBinary(b []byte) (sc trace.SpanContext, ok bool)
- func SpanFromContext(ctx context.Context) trace.Span
- func WithTags(name string, opts ...any) []tag.Mutator
- type CachedFloat64Recorder
- type CachedInt64Counter
- type CachedInt64Recorder
- type CachedTagMaps
- type NullExporter
- type StdoutExporter
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddNewTagKey ¶
AddNewTagKey adds new tag keys to existing view.
func AddSpanToRequest ¶ added in v1.12.0
AddSpanToRequest sets span into a request context.
func BinaryFromSpanContext ¶ added in v1.9.0
func BinaryFromSpanContext(sc trace.SpanContext) []byte
BinaryFromSpanContext returns the binary format representation of a SpanContext.
If sc is the zero value, Binary returns nil.
func CreateRulesMap ¶ added in v1.10.0
func CreateRulesMap(rules []config.MetricsRule) error
CreateRulesMap generates a fast lookup map for metrics regex.
func GetTraceSamplingRate ¶ added in v0.7.0
GetTraceSamplingRate parses the given rate and returns the parsed rate.
func IsTracingEnabled ¶ added in v0.8.0
IsTracingEnabled parses the given rate and returns false if sampling rate is explicitly set 0.
func NewMeasureView ¶
func NewMeasureView(measure stats.Measure, keys []tag.Key, aggregation *view.Aggregation) *view.View
NewMeasureView creates opencensus View instance using stats.Measure.
func NormalizeTagValue ¶
NormalizeTagValue applies the configured metric rules (regex label rewrites) for the measure and tag key to value, exactly as the per-record WithTags path does.
func SpanContextFromBinary ¶ added in v1.9.0
func SpanContextFromBinary(b []byte) (sc trace.SpanContext, ok bool)
SpanContextFromBinary returns the SpanContext represented by b.
If b has an unsupported version ID or contains no TraceID, SpanContextFromBinary returns with ok==false.
func SpanFromContext ¶ added in v0.8.0
SpanFromContext returns the Span stored in a context, or nil or trace.noopSpan{} if there isn't one.
Types ¶
type CachedFloat64Recorder ¶
type CachedFloat64Recorder struct {
// contains filtered or unexported fields
}
CachedFloat64Recorder records float64 measurements (histograms, gauges) through cached tag maps: one small slice allocation per record.
func NewCachedFloat64Recorder ¶
func NewCachedFloat64Recorder(meter stats.Recorder, measure *stats.Float64Measure, base ...any) *CachedFloat64Recorder
NewCachedFloat64Recorder builds the recorder; base holds the constant tag pairs.
func (*CachedFloat64Recorder) Record0 ¶
func (c *CachedFloat64Recorder) Record0(v float64)
Record0 records with only the base tags.
type CachedInt64Counter ¶
type CachedInt64Counter struct {
// contains filtered or unexported fields
}
CachedInt64Counter records a constant-increment counter through cached tag maps: zero allocations on the cached path.
func NewCachedInt64Counter ¶
func NewCachedInt64Counter(meter stats.Recorder, measure *stats.Int64Measure, base ...any) *CachedInt64Counter
NewCachedInt64Counter builds the counter recorder; base holds the constant tag pairs.
func (*CachedInt64Counter) Record1 ¶
func (c *CachedInt64Counter) Record1(k tag.Key, v string)
Record1 records +1 with one varying tag.
func (*CachedInt64Counter) Zero1 ¶
func (c *CachedInt64Counter) Zero1(k tag.Key, v string)
Zero1 records 0 with one varying tag, pre-registering the series so it is exported at value 0 before its first increment. Only meaningful for views with a Sum aggregation: under Count every record, including a zero, counts.
type CachedInt64Recorder ¶
type CachedInt64Recorder struct {
// contains filtered or unexported fields
}
CachedInt64Recorder records variable int64 measurements (byte sizes) through cached tag maps: one small slice allocation per record.
func NewCachedInt64Recorder ¶
func NewCachedInt64Recorder(meter stats.Recorder, measure *stats.Int64Measure, base ...any) *CachedInt64Recorder
NewCachedInt64Recorder builds the recorder; base holds the constant tag pairs.
type CachedTagMaps ¶
type CachedTagMaps struct {
// contains filtered or unexported fields
}
CachedTagMaps caches fully-built *tag.Map values keyed by their varying tag values, so hot-path metric records can call stats.Recorder.Record directly instead of paying the RecordWithOptions chain (mutator closures, option closures, a fresh tag map and value context) on every record: ~18-20 allocations per record down to zero for cached counters.
Base tags (typically app_id and namespace, constant for the process) are applied once per rules generation. Cache keys are the RULE-NORMALIZED values, so the cache's cardinality mirrors the exported view's even when a cardinality rule collapses many raw values into one label, and a rules installation after construction rebuilds the base tags and drops stale entries. Intended for low-cardinality exported discriminators (statuses, kinds, bounded method sets).
func NewCachedTagMaps ¶
func NewCachedTagMaps(measureName string, base ...any) *CachedTagMaps
NewCachedTagMaps builds the cache with constant base tag pairs (key1, value1, key2, value2, ...).
func (*CachedTagMaps) Base ¶
func (c *CachedTagMaps) Base() *tag.Map
Base returns the tag map holding only the constant base tags, for measures with no varying discriminator.
type NullExporter ¶ added in v1.11.0
type NullExporter struct{}
NullExporter implements an open telemetry span exporter that discards all telemetry.
func NewNullExporter ¶ added in v1.11.0
func NewNullExporter() *NullExporter
NewNullExporter returns a NullExporter
func (*NullExporter) ExportSpans ¶ added in v1.11.0
func (e *NullExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error
ExportSpans implements the open telemetry span exporter interface.
type StdoutExporter ¶ added in v0.10.0
type StdoutExporter struct {
// contains filtered or unexported fields
}
StdoutExporter implements an open telemetry span exporter that writes to stdout.
func NewStdOutExporter ¶ added in v1.9.0
func NewStdOutExporter() *StdoutExporter
NewStdOutExporter returns a StdOutExporter
func (*StdoutExporter) ExportSpans ¶ added in v1.9.0
func (e *StdoutExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error
ExportSpans implements the open telemetry span exporter interface.