jsonapi

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jsonapi implements the json api related metrics

Index

Constants

View Source
const (
	TypeRequest  = "req"
	TypeResponse = "resp"
)

Variables

This section is empty.

Functions

func AddPaceAPIHTTPRequestDurationSeconds

func AddPaceAPIHTTPRequestDurationSeconds(duration float64, method, path, service string)

AddPaceAPIHTTPRequestDurationSeconds adds an observed value for the pace_api_http_request_duration_seconds histogram metric

func AddPaceAPIHTTPSizeBytes added in v0.1.12

func AddPaceAPIHTTPSizeBytes(size float64, method, path, service, requestOrResponse string)

AddPaceAPIHTTPSizeBytes adds an observed value for the pace_api_http_size_bytes histogram metric.

func IncPaceAPIHTTPRequestTotal

func IncPaceAPIHTTPRequestTotal(code, method, path, service, clientID string)

IncPaceAPIHTTPRequestTotal increments the pace_api_http_request_total counter metric

Types

type Metric

type Metric struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

Metric is an http.ResponseWriter implementing metrics collector because the metrics depend on the http StatusCode.

func NewMetric

func NewMetric(serviceName, path string, w http.ResponseWriter, r *http.Request) *Metric

NewMetric creates a new metric collector (per request) with given service and path (pattern! not the request path) and collects the pace_api_http_size_bytes histogram metric.

func (*Metric) Write added in v0.1.12

func (m *Metric) Write(p []byte) (int, error)

Write captures the length of the response body.

func (*Metric) WriteHeader

func (m *Metric) WriteHeader(statusCode int)

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

Jump to

Keyboard shortcuts

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