Version: v0.19.2 Latest Latest

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 2 Imported by: 0



Package exemplar implements support for exemplars. Exemplars are additional data associated with each measurement.

Their purpose it to provide an example of the kind of thing (request, RPC, trace span, etc.) that resulted in that measurement.



View Source
const (
	KeyTraceID   = "trace_id"
	KeySpanID    = "span_id"
	KeyPrefixTag = "tag:"

Exemplars keys.


This section is empty.


func RegisterAttachmentExtractor

func RegisterAttachmentExtractor(e AttachmentExtractor)

RegisterAttachmentExtractor registers the given extractor associated with the exemplar type name.

Extractors will be used to attempt to extract exemplars from the context associated with each recorded measurement.

Packages that support exemplars should register their extractor functions on initialization.

RegisterAttachmentExtractor should not be called after any measurements have been recorded.


type AttachmentExtractor

type AttachmentExtractor func(ctx context.Context, a Attachments) Attachments

AttachmentExtractor is a function capable of extracting exemplar attachments from the context used to record measurements. The map passed to the function should be mutated and returned. It will initially be nil: the first AttachmentExtractor that would like to add keys to the map is responsible for initializing it.

type Attachments

type Attachments map[string]string

Attachments is a map of extra values associated with a recorded data point. The map should only be mutated from AttachmentExtractor functions.

func AttachmentsFromContext

func AttachmentsFromContext(ctx context.Context) Attachments

AttachmentsFromContext extracts exemplars from the given context. Each registered AttachmentExtractor (see RegisterAttachmentExtractor) is called in an unspecified order to add attachments to the exemplar.

type Exemplar

type Exemplar struct {
	Value       float64     // the value that was recorded
	Timestamp   time.Time   // the time the value was recorded
	Attachments Attachments // attachments (if any)

Exemplar is an example data point associated with each bucket of a distribution type aggregation.

Source Files

Jump to

Keyboard shortcuts

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