Back to godoc.org

Package jsonapi

v0.1.74
Latest Go to latest

The latest major version is .

Published: Sep 23, 2020 | License: MIT | Module: github.com/pace/bricks

Overview

Package jsonapi implements the json api related metrics documented here: https://lab.jamit.de/pace/web/meta/wikis/concept/metrics#m2-microservice-any-pace-microservice

Index

Constants

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

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

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

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier