2019-08-26 18:41:15 +02:00
|
|
|
// Copyright 2019, OpenTelemetry Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2019-10-09 00:45:49 +02:00
|
|
|
// metric package provides an API for reporting diagnostic
|
2020-03-05 22:15:30 +02:00
|
|
|
// measurements using four basic kinds of instruments.
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
2020-03-11 01:00:37 +02:00
|
|
|
// The three basic kinds are:
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
|
|
|
// - counters
|
|
|
|
// - measures
|
2020-03-05 22:15:30 +02:00
|
|
|
// - observers
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
|
|
|
// All instruments report either float64 or int64 values.
|
|
|
|
//
|
2020-03-05 22:15:30 +02:00
|
|
|
// The primary object that handles metrics is Meter. Meter can be
|
|
|
|
// obtained from Provider. The implementations of the Meter and
|
|
|
|
// Provider are provided by SDK. Normally, the Meter is used directly
|
|
|
|
// only for the instrument creation, LabelSet generation and batch
|
|
|
|
// recording.
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
|
|
|
// LabelSet is a set of keys and values that are in a suitable,
|
|
|
|
// optimized form to be used by Meter.
|
|
|
|
//
|
|
|
|
// Counters are instruments that are reporting a quantity or a sum. An
|
|
|
|
// example could be bank account balance or bytes downloaded. Counters
|
|
|
|
// can be created with either NewFloat64Counter or
|
|
|
|
// NewInt64Counter. Counters expect non-negative values by default to
|
2019-10-23 08:29:24 +02:00
|
|
|
// be reported. This can be changed with the WithMonotonic option
|
|
|
|
// (passing false as a parameter) passed to the Meter.New*Counter
|
|
|
|
// function - this allows reporting negative values. To report the new
|
|
|
|
// value, use an Add function.
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
|
|
|
// Measures are instruments that are reporting values that are
|
|
|
|
// recorded separately to figure out some statistical properties from
|
|
|
|
// those values (like average). An example could be temperature over
|
|
|
|
// time or lines of code in the project over time. Measures can be
|
|
|
|
// created with either NewFloat64Measure or NewInt64Measure. Measures
|
|
|
|
// by default take only non-negative values. This can be changed with
|
2019-10-23 08:29:24 +02:00
|
|
|
// the WithAbsolute option (passing false as a parameter) passed to
|
|
|
|
// the New*Measure function - this allows reporting negative values
|
|
|
|
// too. To report a new value, use the Record function.
|
2019-10-09 00:45:49 +02:00
|
|
|
//
|
2020-03-05 22:15:30 +02:00
|
|
|
// Observers are instruments that are reporting a current state of a
|
|
|
|
// set of values. An example could be voltage or
|
|
|
|
// temperature. Observers can be created with either
|
|
|
|
// RegisterFloat64Observer or RegisterInt64Observer. Observers by
|
|
|
|
// default have no limitations about reported values - they can be
|
|
|
|
// less or greater than the last reported value. This can be changed
|
|
|
|
// with the WithMonotonic option passed to the Register*Observer
|
|
|
|
// function - this permits the reported values only to go
|
|
|
|
// up. Reporting of the new values happens asynchronously, with the
|
|
|
|
// use of a callback passed to the Register*Observer function. The
|
|
|
|
// callback can report multiple values. To unregister the observer,
|
|
|
|
// call Unregister on it.
|
|
|
|
//
|
2020-03-11 01:00:37 +02:00
|
|
|
// Counters and measures support creating bound instruments for a
|
|
|
|
// potentially more efficient reporting. The bound instruments have
|
|
|
|
// the same function names as the instruments (so a Counter bound
|
|
|
|
// instrument has Add, and a Measure bound instrument has Record).
|
|
|
|
// Bound Instruments can be created with the Bind function of the
|
|
|
|
// respective instrument. When done with the bound instrument, call
|
|
|
|
// Unbind on it.
|
2019-11-01 20:40:29 +02:00
|
|
|
package metric // import "go.opentelemetry.io/otel/api/metric"
|