Skip to content

Code generation tool to instrument interfaces

License

Notifications You must be signed in to change notification settings

squat/genstrument

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Genstrument

Generate code to instrument an interface.

Supported Interfaces

Binary

An interface with methods that return an error as the last return value. Depending if the error is nil, the corresponding counter vector will be increased.

Handler

An interface with methods that have no return values, the first argument is an http.ResponseWriter and the second argument is an *http.Request.

Install

Install with

go install github.com/leonnicolas/genstrument@latest

or add github.com/leonnicolas/genstrument to your tools.go file.

Usage

Run

genstrument --file-path <file-path-to-interface> -p <interface-name> --metric-help <help text> --metric-name <metric-name> -o -

to print the generated code to stdout.

Or add something like

//go:generate go run github.com/leonnicolas/genstrument --file-path <file-name> -p <interface-name> --metric-help <help text> --metric-name <metric-name> -o gen.go

into the go file, that contains the interface you want to instrument.

About

Code generation tool to instrument interfaces

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%