MCPcopy Create free account
hub / github.com/pace/bricks / WriteHeader

Method WriteHeader

maintenance/metric/jsonapi/jsonapi.go:105–111  ·  view source on GitHub ↗

WriteHeader captures the status code for metric submission and collects the pace_api_http_request_total counter and pace_api_http_request_duration_seconds histogram metric

(statusCode int)

Source from the content-addressed store, hash-verified

103// collects the pace_api_http_request_total counter and
104// pace_api_http_request_duration_seconds histogram metric
105func (m *Metric) WriteHeader(statusCode int) {
106 clientID, _ := oauth2.ClientID(m.request.Context())
107 IncPaceAPIHTTPRequestTotal(strconv.Itoa(statusCode), m.request.Method, m.path, m.serviceName, clientID)
108 duration := float64(time.Since(m.requestStart).Nanoseconds()) / float64(time.Second)
109 AddPaceAPIHTTPRequestDurationSeconds(duration, m.request.Method, m.path, m.serviceName)
110 m.ResponseWriter.WriteHeader(statusCode)
111}
112
113// Write captures the length of the response body.
114func (m *Metric) Write(p []byte) (int, error) {

Callers 11

HandlerMethod · 0.45
Test_SinkFunction · 0.45
TestLoggingHandlerFunction · 0.45
TestHandlerWithLogSinkFunction · 0.45
TestMetricFunction · 0.45
livenessFunction · 0.45
TestHandlerReadinessFunction · 0.45
JSONHealthHandlerFunction · 0.45
writeResultFunction · 0.45
ServeHTTPMethod · 0.45
TestHandlerFunction · 0.45

Calls 4

ClientIDFunction · 0.92
ContextMethod · 0.80

Tested by 7

Test_SinkFunction · 0.36
TestLoggingHandlerFunction · 0.36
TestHandlerWithLogSinkFunction · 0.36
TestMetricFunction · 0.36
TestHandlerReadinessFunction · 0.36
ServeHTTPMethod · 0.36
TestHandlerFunction · 0.36