autometrics

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutometricsLinkCommentGenerator

type AutometricsLinkCommentGenerator interface {
	GenerateAutometricsComment(ctx GeneratorContext, funcName, moduleName string) []string
	// Generated Links returns the list of text from links created by
	// GenerateAutometricsComment.
	//
	// As gofmt will move the links outside the fences for Autometrics
	// documentation, we add a helper to track the links to delete/recreate
	// in the links section when calling the generator multiple times.
	GeneratedLinks() []string
}

type GeneratorContext

type GeneratorContext struct {
	// RuntimeCtx holds the runtime context to build from in the generated code.
	RuntimeCtx autometrics.Context
	// FuncCtx holds the function specific information for the detected autometrics directive.
	//
	// Notably, it contains all the data relative to the parsing of the arguments in the directive.
	FuncCtx GeneratorFunctionContext
	// Implementation is the metrics library we expect to use in the instrumented code.
	Implementation autometrics.Implementation
	// DocumentationGenerator is the generator to use to generate comments.
	DocumentationGenerator AutometricsLinkCommentGenerator
	// Allow the autometrics directive to have latency targets outside the default buckets.
	AllowCustomLatencies bool
	// Flag to disable/remove the documentation links when calling the generator.
	//
	// This can be set in the command for the generator or through the environment.
	DisableDocGeneration bool
}

GeneratorContext contains the complete command-line and environment context from the generator invocation.

This context contains all the information necessary to properly process the `autometrics` directives over each instrumented function in the file.

func NewGeneratorContext

func NewGeneratorContext(implementation autometrics.Implementation, prometheusUrl string, allowCustomLatencies, disableDocGeneration bool) (GeneratorContext, error)

func (*GeneratorContext) ResetFuncCtx

func (c *GeneratorContext) ResetFuncCtx()

func (*GeneratorContext) SetCommentIdx

func (c *GeneratorContext) SetCommentIdx(i int)

type GeneratorFunctionContext

type GeneratorFunctionContext struct {
	CommentIndex         int
	FunctionName         string
	ModuleName           string
	ImplImportName       string
	DisableDocGeneration bool
}

type Prometheus

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

func NewPrometheusDoc

func NewPrometheusDoc(instanceUrl url.URL) Prometheus

NewPrometheusDoc builds a documentation comment generator that creates Prometheus links.

The document generator implements the AutometricsLinkCommentGenerator interface.

func (Prometheus) GenerateAutometricsComment

func (p Prometheus) GenerateAutometricsComment(ctx GeneratorContext, funcName, moduleName string) []string
func (p Prometheus) GeneratedLinks() []string

Jump to

Keyboard shortcuts

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