telemetry

package
Version: v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 17 Imported by: 23

README

telemetry

This package provides basic interaction with the New Relic Metrics and Spans HTTP APIs, automatic batch harvesting on a given schedule, and handling of errors from the API response.

Usage

Create a Harvester. It will store your metrics and spans and send this data in the background.

harvester := telemetry.NewHarvester(
  telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")),
)

Record metrics and/or spans.

harvester.RecordMetric(Gauge{
  Name:       "Temperature",
  Attributes: map[string]interface{}{"zip": "zap"},
  Value:      55.62,
  Timestamp:  time.Now(),
})
harvester.RecordSpan(Span{
  ID:          "12345",
  TraceID:     "67890",
  Name:        "mySpan",
  Timestamp:   time.Now(),
  Duration:    time.Second,
  ServiceName: "Getting-Started",
  Attributes: map[string]interface{}{
    "color": "purple",
  },
  Events: []Event{
  		Event{
  			Name:      "Series",
  			Timestamp: tm,
  			Attributes: map[string]interface{}{
  				"exception.message": "Unfortunate event occurred",
  				"exception.type":    "Unfortunate",
  			},
  		},
  	},
})

Data will be sent to New Relic every 5 seconds by default.

Documentation

Overview

Package telemetry is a client for the New Relic Metrics and Spans HTTP APIs.

This package stores metrics and spans, harvests them on a given schedule, and handles errors from the API response.

Example
h, err := NewHarvester(
	// APIKey is the only required field and refers to your New Relic Insert API key.
	ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")),
	ConfigCommonAttributes(map[string]interface{}{
		"app.name": "myApplication",
	}),
	ConfigBasicErrorLogger(os.Stderr),
	ConfigBasicDebugLogger(os.Stdout),
)
if err != nil {
	fmt.Println(err)
}

// Record Gauge, Count, and Summary metrics using RecordMetric. These
// metrics are not aggregated.  This is useful for exporting metrics
// recorded by another system.
h.RecordMetric(Gauge{
	Timestamp: time.Now(),
	Value:     1,
	Name:      "myMetric",
	Attributes: map[string]interface{}{
		"color": "purple",
	},
})

// Record spans using RecordSpan.
h.RecordSpan(Span{
	ID:          "12345",
	TraceID:     "67890",
	Name:        "purple-span",
	Timestamp:   time.Now(),
	Duration:    time.Second,
	ServiceName: "ExampleApplication",
	Attributes: map[string]interface{}{
		"color": "purple",
	},
})

// Aggregate individual datapoints into metrics using the
// MetricAggregator.  You can do this in a single line:
h.MetricAggregator().Count("myCounter", map[string]interface{}{"color": "pink"}).Increment()
// Or keep a metric reference for fast accumulation:
counter := h.MetricAggregator().Count("myCounter", map[string]interface{}{"color": "pink"})
for i := 0; i < 100; i++ {
	counter.Increment()
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigAPIKey

func ConfigAPIKey(key string) func(*Config)

ConfigAPIKey sets the Config's APIKey which is required and refers to your New Relic Insert API key.

func ConfigBasicAuditLogger

func ConfigBasicAuditLogger(w io.Writer) func(*Config)

ConfigBasicAuditLogger sets the audit logger to a simple logger that logs to the writer provided.

func ConfigBasicDebugLogger

func ConfigBasicDebugLogger(w io.Writer) func(*Config)

ConfigBasicDebugLogger sets the debug logger to a simple logger that logs to the writer provided.

func ConfigBasicErrorLogger

func ConfigBasicErrorLogger(w io.Writer) func(*Config)

ConfigBasicErrorLogger sets the error logger to a simple logger that logs to the writer provided.

func ConfigCommonAttributes

func ConfigCommonAttributes(attributes map[string]interface{}) func(*Config)

ConfigCommonAttributes adds the given attributes to the Config's CommonAttributes.

func ConfigEventsURLOverride added in v0.5.0

func ConfigEventsURLOverride(url string) func(*Config)

ConfigEventsURLOverride sets the Config's EventsURLOverride field which overrides the events endpoint if not empty.

func ConfigHarvestPeriod

func ConfigHarvestPeriod(period time.Duration) func(*Config)

ConfigHarvestPeriod sets the Config's HarvestPeriod field which controls the rate data is reported to New Relic. If it is set to zero then the Harvester will never report data unless HarvestNow is called.

func ConfigLogsURLOverride added in v0.6.0

func ConfigLogsURLOverride(url string) func(*Config)

ConfigLogsURLOverride sets the Config's LogsURLOverride field which overrides the logs endpoint if not empty.

func ConfigMetricsURLOverride added in v0.5.2

func ConfigMetricsURLOverride(url string) func(*Config)

ConfigMetricsURLOverride sets the Config's MetricsURLOverride field which overrides the metrics endpoint if not empty.

func ConfigSpansURLOverride added in v0.3.0

func ConfigSpansURLOverride(url string) func(*Config)

ConfigSpansURLOverride sets the Config's SpansURLOverride field which overrides the spans endpoint if not empty.

Example
h, _ := NewHarvester(
	ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")),
	// Use ConfigSpansURLOverride to enable Infinite Tracing on the New
	// Relic Edge by passing it your Trace Observer URL, including scheme
	// and path.
	ConfigSpansURLOverride("https://nr-internal.aws-us-east-1.tracing.edge.nr-data.net/trace/v1"),
)
h.RecordSpan(Span{
	ID:          "12345",
	TraceID:     "67890",
	Name:        "purple-span",
	Timestamp:   time.Now(),
	Duration:    time.Second,
	ServiceName: "ExampleApplication",
	Attributes: map[string]interface{}{
		"color": "purple",
	},
})
Output:

Types

type AggregatedCount

type AggregatedCount struct {
	// contains filtered or unexported fields
}

AggregatedCount is the metric type that counts the number of times an event occurred. This counter is reset every time the data is reported, meaning the value reported represents the difference in count over the reporting time window.

Example possible uses:

  • the number of messages put on a topic
  • the number of HTTP requests
  • the number of errors thrown
  • the number of support tickets answered

func (*AggregatedCount) Increase

func (c *AggregatedCount) Increase(val float64)

Increase increases the Count value by the number given. The value must be non-negative.

func (*AggregatedCount) Increment

func (c *AggregatedCount) Increment()

Increment increases the Count value by one.

type AggregatedGauge

type AggregatedGauge struct {
	// contains filtered or unexported fields
}

AggregatedGauge is the metric type that records a value that can increase or decrease. It generally represents the value for something at a particular moment in time. One typically records a AggregatedGauge value on a set interval.

Only the most recent AggregatedGauge metric value is reported over a given harvest period, all others are dropped.

Example possible uses:

  • the temperature in a room
  • the amount of memory currently in use for a process
  • the bytes per second flowing into Kafka at this exact moment in time
  • the current speed of your car

func (*AggregatedGauge) Value

func (g *AggregatedGauge) Value(val float64)

Value records the value given.

type AggregatedSummary

type AggregatedSummary struct {
	// contains filtered or unexported fields
}

AggregatedSummary is the metric type used for reporting aggregated information about discrete events. It provides the count, average, sum, min and max values over time. All fields are reset to 0 every reporting interval.

The final metric reported at the end of a harvest period is an aggregation. Values reported are the count of the number of metrics recorded, sum of all their values, minimum value recorded, and maximum value recorded.

Example possible uses:

  • the duration and count of spans
  • the duration and count of transactions
  • the time each message spent in a queue

func (*AggregatedSummary) Record

func (s *AggregatedSummary) Record(val float64)

Record adds an observation to a summary.

func (*AggregatedSummary) RecordDuration

func (s *AggregatedSummary) RecordDuration(val time.Duration)

RecordDuration adds a duration observation to a summary. It records the value in milliseconds, New Relic's recommended duration units.

type Batch added in v0.7.0

type Batch = []MapEntry

A Batch is an array of MapEntry. A single HTTP request body is composed of an array of Batch.

type ClientOption added in v0.5.2

type ClientOption func(o *requestFactory)

ClientOption is a function that can be used to configure the RequestFactory or a generated request.

func WithEndpoint added in v0.5.2

func WithEndpoint(endpoint string) ClientOption

WithEndpoint creates a ClientOption to specify the hostname and port to use for the generated requests.

func WithGzipCompressionLevel added in v0.6.0

func WithGzipCompressionLevel(level int) ClientOption

WithGzipCompressionLevel creates a ClientOption to specify the level of gzip compression that should be used for the request.

func WithInsecure added in v0.5.2

func WithInsecure() ClientOption

WithInsecure creates a ClientOption to specify that requests should be sent over http instead of https.

func WithInsertKey added in v0.5.2

func WithInsertKey(insertKey string) ClientOption

WithInsertKey creates a ClientOption to specify the insert key to use when generating requests.

func WithLicenseKey added in v0.7.0

func WithLicenseKey(licenseKey string) ClientOption

WithLicenseKey creates a ClientOption to specify the license key to use when generating requests.

func WithNoDefaultKey added in v0.5.2

func WithNoDefaultKey() ClientOption

WithNoDefaultKey creates a ClientOption to specify that each time a request is generated the api key will need to be provided as a ClientOption to BuildRequest.

func WithUserAgent added in v0.5.2

func WithUserAgent(userAgent string) ClientOption

WithUserAgent creates a ClientOption to specify additional user agent information for the generated requests.

type Config

type Config struct {
	// APIKey is required and refers to your New Relic Insert API key.
	APIKey string
	// Client is the http.Client used for making requests.
	Client *http.Client
	// HarvestTimeout is the total amount of time including retries that the
	// Harvester may use trying to harvest data.  By default, HarvestTimeout
	// is set to 15 seconds.
	HarvestTimeout time.Duration
	// CommonAttributes are the attributes to be applied to all metrics that
	// use this Config. They are not applied to spans.
	CommonAttributes map[string]interface{}
	// HarvestPeriod controls how frequently data will be sent to New Relic.
	// If HarvestPeriod is zero then NewHarvester will not spawn a goroutine
	// to send data and it is incumbent on the consumer to call
	// Harvester.HarvestNow when data should be sent. By default, HarvestPeriod
	// is set to 5 seconds.
	HarvestPeriod time.Duration
	// ErrorLogger receives errors that occur in this sdk.
	ErrorLogger func(map[string]interface{})
	// DebugLogger receives structured debug log messages.
	DebugLogger func(map[string]interface{})
	// AuditLogger receives structured log messages that include the
	// uncompressed data sent to New Relic.  Use this to log all data sent.
	AuditLogger func(map[string]interface{})
	// MetricsURLOverride overrides the metrics endpoint if not empty.
	MetricsURLOverride string
	// SpansURLOverride overrides the spans endpoint if not empty.
	//
	// To enable Infinite Tracing on the New Relic Edge, set this field to your
	// Trace Observer URL.  See
	// https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/enable-configure/enable-distributed-tracing
	SpansURLOverride string
	// EventsURLOverride overrides the events endpoint if not empty
	EventsURLOverride string
	// LogsURLOverride overrides the logs endpoint if not empty.
	LogsURLOverride string
	// Product is added to the User-Agent header. eg. "NewRelic-Go-OpenCensus"
	Product string
	// ProductVersion is added to the User-Agent header. eg. "0.1.0".
	ProductVersion string
}

Config customizes the behavior of a Harvester.

type Count

type Count struct {
	// Name is the name of this metric.
	Name string
	// Attributes is a map of attributes for this metric.
	Attributes map[string]interface{}
	// AttributesJSON is a json.RawMessage of attributes for this metric. It
	// will only be sent if Attributes is nil.
	AttributesJSON json.RawMessage
	// Value is the value of this metric.
	Value float64
	// Timestamp is the start time of this metric's interval.  If Timestamp
	// is unset then the Harvester's period start will be used.
	Timestamp time.Time
	// Interval is the length of time for this metric.  If Interval is unset
	// then the time between Harvester harvests will be used.
	Interval time.Duration
	// Set to true to force the value of interval to be written to the payload
	ForceIntervalValid bool
}

Count is the metric type that counts the number of times an event occurred. This counter should be reset every time the data is reported, meaning the value reported represents the difference in count over the reporting time window.

Example possible uses:

  • the number of messages put on a topic
  • the number of HTTP requests
  • the number of errors thrown
  • the number of support tickets answered

type Event added in v0.5.0

type Event struct {
	// Required Fields:
	//
	// EventType is the name of the event
	EventType string
	// Timestamp is when this event happened.  If Timestamp is not set, it
	// will be assigned to time.Now() in Harvester.RecordEvent.
	Timestamp time.Time

	// Recommended Fields:
	//
	// Attributes is a map of user specified data on this event.  The map
	// values can be any of bool, number, or string.
	Attributes map[string]interface{}
	// AttributesJSON is a json.RawMessage of attributes for this metric. It
	// will only be sent if Attributes is nil.
	AttributesJSON json.RawMessage
}

Event is a unique set of data that happened at a specific point in time

type Gauge

type Gauge struct {
	// Name is the name of this metric.
	Name string
	// Attributes is a map of attributes for this metric.
	Attributes map[string]interface{}
	// AttributesJSON is a json.RawMessage of attributes for this metric. It
	// will only be sent if Attributes is nil.
	AttributesJSON json.RawMessage
	// Value is the value of this metric.
	Value float64
	// Timestamp is the time at which this metric was gathered.  If
	// Timestamp is unset then the Harvester's period start will be used.
	Timestamp time.Time
}

Gauge is the metric type that records a value that can increase or decrease. It generally represents the value for something at a particular moment in time. One typically records a Gauge value on a set interval.

Example possible uses:

  • the temperature in a room
  • the amount of memory currently in use for a process
  • the bytes per second flowing into Kafka at this exact moment in time
  • the current speed of your car

type Harvester

type Harvester struct {
	// contains filtered or unexported fields
}

Harvester aggregates and reports metrics and spans.

func NewHarvester

func NewHarvester(options ...func(*Config)) (*Harvester, error)

NewHarvester creates a new harvester.

Example
h, err := NewHarvester(
	ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")),
)
if err != nil {
	fmt.Println(err)
}
h.RecordMetric(Gauge{
	Timestamp: time.Now(),
	Value:     1,
	Name:      "myMetric",
	Attributes: map[string]interface{}{
		"color": "purple",
	},
})
Output:

func (*Harvester) HarvestNow

func (h *Harvester) HarvestNow(ct context.Context)

HarvestNow sends metric and span data to New Relic. This method blocks until all data has been sent successfully or the Config.HarvestTimeout timeout has elapsed. This method can be used with a zero Config.HarvestPeriod value to control exactly when data is sent to New Relic servers.

func (*Harvester) MetricAggregator

func (h *Harvester) MetricAggregator() *MetricAggregator

MetricAggregator returns a metric aggregator. Use this instead of RecordMetric if you have individual data points that you would like to combine into metrics.

func (*Harvester) RecordEvent added in v0.5.0

func (h *Harvester) RecordEvent(e Event) error

RecordEvent records the given event.

func (*Harvester) RecordLog added in v0.6.0

func (h *Harvester) RecordLog(l Log) error

RecordLog records the given log message.

func (*Harvester) RecordMetric

func (h *Harvester) RecordMetric(m Metric)

RecordMetric adds a fully formed metric. This metric is not aggregated with any other metrics and is never dropped. The timestamp field must be specified on Gauge metrics. The timestamp/interval fields on Count and Summary are optional and will be assumed to be the harvester batch times if unset. Use MetricAggregator() instead to aggregate metrics.

Example
h, _ := NewHarvester(
	ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")),
)
start := time.Now()
h.RecordMetric(Count{
	Name:           "myCount",
	AttributesJSON: json.RawMessage(`{"zip":"zap"}`),
	Value:          123,
	Timestamp:      start,
	Interval:       5 * time.Second,
})
Output:

func (*Harvester) RecordSpan

func (h *Harvester) RecordSpan(s Span) error

RecordSpan records the given span.

type Log added in v0.6.0

type Log struct {
	// Required Fields:
	//
	// Message is the log message.
	Message string

	// Recommended Fields:
	//
	// Timestamp of the log message.  If Timestamp is not set, it
	// will be assigned to time.Now() in Harvester.RecordLog.
	Timestamp time.Time

	// Additional Fields:
	//
	// Attributes is a map of user specified tags on this log message.  The map
	// values can be any of bool, number, or string.
	Attributes map[string]interface{}
}

Log is a log.

type LogCommonBlockOption added in v0.7.0

type LogCommonBlockOption func(*logCommonBlock) error

LogCommonBlockOption is a function that can be used to configure a log common block

func WithLogAttributes added in v0.7.0

func WithLogAttributes(commonAttributes map[string]interface{}) LogCommonBlockOption

WithLogAttributes creates a LogCommonBlockOption to specify the common attributes of the common block. Invalid attributes will be detected and ignored

type MapEntry added in v0.7.0

type MapEntry interface {
	// Type returns the type of data contained in this MapEntry.
	DataTypeKey() string

	// WriteDataEntry writes the json serialized bytes of the MapEntry to the buffer.
	// It returns the input buffer for chaining.
	WriteDataEntry(*bytes.Buffer) *bytes.Buffer
}

MapEntry represents a piece of the telemetry data that is included in a single request that should be sent to New Relic. Example MapEntry types include SpanGroup and the internal spanCommonBlock.

func NewEventGroup added in v0.7.1

func NewEventGroup(events []Event) MapEntry

NewEventGroup creates a new MapEntry representing a group of events in a batch.

func NewLogCommonBlock added in v0.7.0

func NewLogCommonBlock(options ...LogCommonBlockOption) (MapEntry, error)

NewLogCommonBlock creates a new MapEntry representing data common to all members of a group.

func NewLogGroup added in v0.7.0

func NewLogGroup(logs []Log) MapEntry

NewLogGroup creates a new MapEntry representing a group of logs in a batch.

func NewMetricCommonBlock added in v0.7.0

func NewMetricCommonBlock(options ...MetricCommonBlockOption) (MapEntry, error)

NewMetricCommonBlock creates a new MapEntry representing data common to all metrics in a group.

func NewMetricGroup added in v0.7.0

func NewMetricGroup(metrics []Metric) MapEntry

NewMetricGroup creates a new MapEntry representing a group of metrics in a batch.

func NewSpanCommonBlock added in v0.7.0

func NewSpanCommonBlock(options ...SpanCommonBlockOption) (MapEntry, error)

NewSpanCommonBlock creates a new MapEntry representing data common to all spans in a group.

func NewSpanGroup added in v0.7.0

func NewSpanGroup(spans []Span) MapEntry

NewSpanGroup creates a new MapEntry representing a group of spans in a batch.

type Metric

type Metric interface {
	// contains filtered or unexported methods
}

Metric is implemented by Count, Gauge, and Summary.

type MetricAggregator

type MetricAggregator struct {
	// contains filtered or unexported fields
}

MetricAggregator is used to aggregate individual data points into metrics.

func (*MetricAggregator) Count

func (ag *MetricAggregator) Count(name string, attributes map[string]interface{}) *AggregatedCount

Count creates a new AggregatedCount metric.

Example
h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")))
count := h.MetricAggregator().Count("myCount", map[string]interface{}{"zip": "zap"})
count.Increment()
Output:

func (*MetricAggregator) Gauge

func (ag *MetricAggregator) Gauge(name string, attributes map[string]interface{}) *AggregatedGauge

Gauge creates a new AggregatedGauge metric.

Example
h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")))
gauge := h.MetricAggregator().Gauge("temperature", map[string]interface{}{"zip": "zap"})
gauge.Value(23.4)
Output:

func (*MetricAggregator) Summary

func (ag *MetricAggregator) Summary(name string, attributes map[string]interface{}) *AggregatedSummary

Summary creates a new AggregatedSummary metric.

Example
h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSERT_API_KEY")))
summary := h.MetricAggregator().Summary("mySummary", map[string]interface{}{"zip": "zap"})
summary.RecordDuration(3 * time.Second)
Output:

type MetricCommonBlockOption added in v0.7.0

type MetricCommonBlockOption func(block *metricCommonBlock) error

MetricCommonBlockOption is a function that can be used to configure a metric common block

func WithMetricAttributes added in v0.7.0

func WithMetricAttributes(commonAttributes map[string]interface{}) MetricCommonBlockOption

WithMetricAttributes creates a MetricCommonBlockOption to specify the common attributes of the common block. Invalid attributes will be detected and ignored

func WithMetricInterval added in v0.7.0

func WithMetricInterval(interval time.Duration) MetricCommonBlockOption

WithMetricInterval sets the interval in a common block for metrics.

func WithMetricTimestamp added in v0.7.0

func WithMetricTimestamp(startTime time.Time) MetricCommonBlockOption

WithMetricTimestamp sets the timestamp (start time) in a common block for metrics.

type RequestFactory added in v0.5.2

type RequestFactory interface {
	// BuildRequest converts the telemetry payload slice into an http.Request.
	// Do not mix telemetry data types in a single call to build request. Each
	// telemetry data type has its own RequestFactory.
	BuildRequest(context.Context, []Batch, ...ClientOption) (*http.Request, error)
}

RequestFactory is used for sending telemetry data to New Relic when you want to have direct access to the http.Request and you want to manually send the request using a http.Client. Consider using the Harvester if you do not want to manage the requests and corresponding responses manually.

func NewEventRequestFactory added in v0.5.2

func NewEventRequestFactory(options ...ClientOption) (RequestFactory, error)

NewEventRequestFactory creates a new instance of a RequestFactory that can be used to send Event data to New Relic.

func NewLogRequestFactory added in v0.6.0

func NewLogRequestFactory(options ...ClientOption) (RequestFactory, error)

NewLogRequestFactory creates a new instance of a RequestFactory that can be used to send Log data to New Relic.

func NewMetricRequestFactory added in v0.5.2

func NewMetricRequestFactory(options ...ClientOption) (RequestFactory, error)

NewMetricRequestFactory creates a new instance of a RequestFactory that can be used to send Metric data to New Relic.

func NewSpanRequestFactory added in v0.5.2

func NewSpanRequestFactory(options ...ClientOption) (RequestFactory, error)

NewSpanRequestFactory creates a new instance of a RequestFactory that can be used to send Span data to New Relic,

type Span

type Span struct {
	// Required Fields:
	//
	// ID is a unique identifier for this span.
	ID string
	// TraceID is a unique identifier shared by all spans within a single
	// trace.
	TraceID string
	// Timestamp is when this span started.  If Timestamp is not set, it
	// will be assigned to time.Now() in Harvester.RecordSpan.
	Timestamp time.Time

	// Recommended Fields:
	//
	// Name is the name of this span.
	Name string
	// ParentID is the span id of the previous caller of this span.  This
	// can be empty if this is the first span.
	ParentID string
	// Duration is the duration of this span.  This field will be reported
	// in milliseconds.
	Duration time.Duration
	// ServiceName is the name of the service that created this span.
	ServiceName string

	// Additional Fields:
	//
	// Attributes is a map of user specified tags on this span.  The map
	// values can be any of bool, number, or string.
	Attributes map[string]interface{}
	// Events is a slice of events that occurred during the execution of a span.
	// This feature is a work in progress.
	Events []Event
}

Span is a distributed tracing span.

type SpanCommonBlockOption added in v0.7.0

type SpanCommonBlockOption func(scb *spanCommonBlock) error

SpanCommonBlockOption is a function that can be used to configure a span common block

func WithSpanAttributes added in v0.7.0

func WithSpanAttributes(commonAttributes map[string]interface{}) SpanCommonBlockOption

WithSpanAttributes creates a SpanCommonBlockOption to specify the common attributes of the common block. Invalid attributes will be detected and ignored

type Summary

type Summary struct {
	// Name is the name of this metric.
	Name string
	// Attributes is a map of attributes for this metric.
	Attributes map[string]interface{}
	// AttributesJSON is a json.RawMessage of attributes for this metric. It
	// will only be sent if Attributes is nil.
	AttributesJSON json.RawMessage
	// Count is the count of occurrences of this metric for this time period.
	Count float64
	// Sum is the sum of all occurrences of this metric for this time period.
	Sum float64
	// Min is the smallest value recorded of this metric for this time period.
	Min float64
	// Max is the largest value recorded of this metric for this time period.
	Max float64
	// Timestamp is the start time of this metric's interval.   If Timestamp
	// is unset then the Harvester's period start will be used.
	Timestamp time.Time
	// Interval is the length of time for this metric.  If Interval is unset
	// then the time between Harvester harvests will be used.
	Interval time.Duration
	// Set to true to force the value of interval to be written to the payload
	ForceIntervalValid bool
}

Summary is the metric type used for reporting aggregated information about discrete events. It provides the count, average, sum, min and max values over time. All fields should be reset to 0 every reporting interval.

Example possible uses:

  • the duration and count of spans
  • the duration and count of transactions
  • the time each message spent in a queue

Jump to

Keyboard shortcuts

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