Documentation
¶
Overview ¶
Package instrumentscan reads the OpenTelemetry instruments a Go package creates from its sources. The sources are parsed, not type-checked, so every creation call must keep one shape: the name a string constant of the package, the description and the unit string literals, the bucket boundaries number literals, and every other option a callback. A call of another shape fails the scan at its position rather than being misread.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePackage ¶
ParsePackage parses every non-test Go file in dir without type checking. Positions carry the paths as dir joined with the file name.
Types ¶
type Instrument ¶
type Instrument struct {
Name string
NameConst string
Constructor string
Unit string
Boundaries []float64
Callbacks int
Description string
Pos token.Position
}
Instrument is one instrument creation call as the sources declare it. NameConst is the constant the name was read from and Pos the position of the call.
func Scan ¶
func Scan(fset *token.FileSet, files []*ast.File, constants []StringConstant) ([]Instrument, error)
Scan reads every call of an instrument constructor in files and returns the instruments sorted by name. constants are the package's string constants, which the names are read from.
func (*Instrument) Kind ¶
func (i *Instrument) Kind() string
Kind is the constructor without its number type: Counter, Histogram, ObservableGauge and so on.
type StringConstant ¶
StringConstant is a top-level constant whose value is a string literal. Type is the type as written and nil for an untyped constant.
func StringConstants ¶
func StringConstants(files []*ast.File) []StringConstant
StringConstants collects the top-level constants whose value is a string literal, typed or untyped, in declaration order.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
metricsdoc
command
Command metricsdoc writes the metrics table of a package, rendered from the OpenTelemetry instruments its sources create.
|
Command metricsdoc writes the metrics table of a package, rendered from the OpenTelemetry instruments its sources create. |