Skip to content

Conversation

@zoftdev
Copy link

@zoftdev zoftdev commented May 4, 2021

This feature is about to override code label base on context value.

use StatusOverrideFromContext

p := ginprometheus.NewPrometheus("gin")
p.StatusOverrideFromContext = append(p.StatusOverrideFromContext, "code")
p.StatusOverrideFromContext = append(p.StatusOverrideFromContext, "mycode")

and set gin's context

        r.GET("/", func(c *gin.Context) {
		c.Set("code", "888")
		c.JSON(200, "Hello world!")
	})

See example at here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant