Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MetricParser = &resourceparser.Parser{ Name: "Metric", InterestingImports: []paths.Pkg{"encore.dev/metrics"}, Run: func(p *resourceparser.Pass) { var ( names []pkginfo.QualifiedName specs = make(map[pkginfo.QualifiedName]*parseutil.ReferenceSpec) ) for _, c := range metricConstructors { name := pkginfo.QualifiedName{PkgPath: "encore.dev/metrics", Name: c.FuncName} names = append(names, name) numTypeArgs := 1 if c.HasLabels { numTypeArgs = 2 } c := c parseFn := func(d parseutil.ReferenceInfo) { parseMetric(c, d) } spec := &parseutil.ReferenceSpec{ MinTypeArgs: numTypeArgs, MaxTypeArgs: numTypeArgs, Parse: parseFn, } specs[name] = spec } parseutil.FindPkgNameRefs(p.Pkg, names, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) { spec := specs[name] parseutil.ParseReference(p, spec, parseutil.ReferenceData{ File: file, Stack: stack, ResourceFunc: name, }) }) }, }
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric struct { AST *ast.CallExpr Name string // The unique name of the metric Doc string // The documentation on the metric Type MetricType // the type of metric it is // File is the file the metric is declared in. File *pkginfo.File // LabelType is the label type of the metric, // if the metric is a group. LabelType option.Option[schema.Type] // Labels is the list of parsed labels. Labels []Label ValueType schema.BuiltinType // The struct literal for the config. Used to inject additional configuration // at compile-time. ConfigLiteral *ast.CompositeLit }
func (*Metric) ResourceName ¶
type MetricType ¶
type MetricType int
const ( Counter MetricType = iota Gauge )
func (MetricType) String ¶
func (i MetricType) String() string
Click to show internal directories.
Click to hide internal directories.