Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
enzowritescode committed Aug 20, 2024
1 parent c627378 commit fbd2e64
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ func (p *Plugin) GetMetrics() metrics.Metrics {
}

func (p *Plugin) metricsMiddleware(c *gin.Context) {
if p.GetMetrics() == nil {
llmMetrics := p.GetMetrics()
if llmMetrics == nil {
c.Next()
return
}
p.GetMetrics().IncrementHTTPRequests()
llmMetrics.IncrementHTTPRequests()
now := time.Now()

c.Next()
Expand All @@ -33,9 +34,9 @@ func (p *Plugin) metricsMiddleware(c *gin.Context) {
status := c.Writer.Status()

if status < 200 || status > 299 {
p.GetMetrics().IncrementHTTPErrors()
llmMetrics.IncrementHTTPErrors()
}

endpoint := c.HandlerName()
p.GetMetrics().ObserveAPIEndpointDuration(endpoint, c.Request.Method, strconv.Itoa(status), elapsed)
llmMetrics.ObserveAPIEndpointDuration(endpoint, c.Request.Method, strconv.Itoa(status), elapsed)
}

0 comments on commit fbd2e64

Please sign in to comment.