golang-apm-gin

module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0

README

golang-apm-gin

go get github.com/middleware-labs/golang-apm-gin


package main

import (
	"github.com/gin-gonic/gin"
	g "github.com/middleware-labs/golang-apm-gin/gin"
	track "github.com/middleware-labs/golang-apm/tracker"
	"net/http"
)

func main() {
	go track.Track(
		track.WithConfigTag("service", "service1"),
		track.WithConfigTag("projectName", "demo-agent-apm"),
	)
	r := gin.Default()
	r.Use(g.Middleware("serviceName"))
	r.GET("/books", FindBooks)
	r.Run(":8090")
}

func FindBooks(c *gin.Context) {
	span := track.SpanFromContext(c.Request.Context())
	span.SetAttributes(track.String("controller", "books"))
	c.JSON(http.StatusOK, gin.H{"data": "ok"})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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