Skip to content

ronald05arias/gin-gorelic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GoRelic

NewRelic middleware for gin-gonic framework.

Usage

import(
	"github.com/gin-gonic/gin"
	"github.com/brandfolder/gin-gorelic"
)

func main(){
	g := gin.Default()

	handler, err := gorelic.InitNewrelicAgent("YOUR_NEWRELIC_LICENSE_KEY", "YOUR_APP_NAME", true, nil)
	if err == nil {
		router.Use(handler)
	} else {
		fmt.Printf("Something went wrong initialising NewRelic %v\n", err)
	}

	g.Run()
}

Defining custom metrics

Here's a general definition. For more details take a look into the examples.

import(
	"github.com/gin-gonic/gin"
	"github.com/brandfolder/gin-gorelic"
)

type M struct {
	name        string
	units       string
	counter     float64
}

func (_m *M) GetName() string  { return "CustomCounters/" + _m.name }
func (_m *M) GetUnits() string { return _m.units }
func (_m *M) GetValue() (float64, error) {
	//Method body...
}

func main(){
	g := gin.Default()
	
	m1 := &M{name: "custom_metric_1", units: "unit", counter: 1}
	m2 := &M{name: "custom_metric_2", units: "unit", counter: 2}
	customMetrics := []gorelic.Metric{m1, m2}

	handler, err := gorelic.InitNewrelicAgent("YOUR_NEWRELIC_LICENSE_KEY", "YOUR_APPLICATION_NAME", true, customMetrics)
	if err == nil {
		router.Use(handler)
	} else {
		fmt.Printf("Something went wrong initialising NewRelic %v\n", err)
	}

	g.Run()
}

Authors

Contributions

About

Middleware to support Gorelic using the Gin framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%