telemetry

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: BSD-3-Clause Imports: 17 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppMetrics

type AppMetrics interface {
	GetMeter() metric2.Meter
	Close() error
	Expose(port int, endpoint string) error
	IDPMetrics() *IDPMetrics
	HTTPMiddleware() *HTTPMiddleware
	GRPCMetrics() *GRPCMetrics
}

AppMetrics is metrics interface

func NewDefaultAppMetrics

func NewDefaultAppMetrics(ctx context.Context) (AppMetrics, error)

NewDefaultAppMetrics and expose them via defaultEndpoint on a given HTTP port

type GRPCMetrics

type GRPCMetrics struct {
	// contains filtered or unexported fields
}

GRPCMetrics are gRPC server metrics

func NewGRPCMetrics

func NewGRPCMetrics(ctx context.Context, meter metric.Meter) (*GRPCMetrics, error)

NewGRPCMetrics creates new GRPCMetrics struct and registers common metrics of the gRPC server

func (*GRPCMetrics) CountGetKeyRequest

func (grpcMetrics *GRPCMetrics) CountGetKeyRequest()

CountGetKeyRequest counts the number of gRPC get server key requests coming to the gRPC API

func (*GRPCMetrics) CountLoginRequest

func (grpcMetrics *GRPCMetrics) CountLoginRequest()

CountLoginRequest counts the number of gRPC login requests coming to the gRPC API

func (*GRPCMetrics) CountSyncRequest

func (grpcMetrics *GRPCMetrics) CountSyncRequest()

CountSyncRequest counts the number of gRPC sync requests coming to the gRPC API

func (*GRPCMetrics) RegisterConnectedStreams

func (grpcMetrics *GRPCMetrics) RegisterConnectedStreams(producer func() int64) error

RegisterConnectedStreams registers a function that collects number of active streams and feeds it to the metrics gauge.

type HTTPMiddleware

type HTTPMiddleware struct {
	// contains filtered or unexported fields
}

HTTPMiddleware handler used to collect metrics of every request/response coming to the API. Also adds request tracing (logging).

func NewMetricsMiddleware

func NewMetricsMiddleware(ctx context.Context, meter metric.Meter) (*HTTPMiddleware, error)

NewMetricsMiddleware creates a new HTTPMiddleware

func (*HTTPMiddleware) AddHTTPRequestResponseCounter

func (m *HTTPMiddleware) AddHTTPRequestResponseCounter(endpoint string, method string) error

AddHTTPRequestResponseCounter adds a new meter for an HTTP defaultEndpoint and Method (GET, POST, etc) Creates one request counter and multiple response counters (one per http response status code).

func (*HTTPMiddleware) Handler

func (m *HTTPMiddleware) Handler(h http.Handler) http.Handler

Handler logs every request and response and adds the, to metrics.

type IDPMetrics

type IDPMetrics struct {
	// contains filtered or unexported fields
}

IDPMetrics is common IdP metrics

func NewIDPMetrics

func NewIDPMetrics(ctx context.Context, meter metric.Meter) (*IDPMetrics, error)

NewIDPMetrics creates new IDPMetrics struct and registers common

func (*IDPMetrics) CountAuthenticate

func (idpMetrics *IDPMetrics) CountAuthenticate()

CountAuthenticate ...

func (*IDPMetrics) CountCreateUser

func (idpMetrics *IDPMetrics) CountCreateUser()

CountCreateUser ...

func (*IDPMetrics) CountGetAccount

func (idpMetrics *IDPMetrics) CountGetAccount()

CountGetAccount ...

func (*IDPMetrics) CountGetAllAccounts

func (idpMetrics *IDPMetrics) CountGetAllAccounts()

CountGetAllAccounts ...

func (*IDPMetrics) CountGetUserByEmail

func (idpMetrics *IDPMetrics) CountGetUserByEmail()

CountGetUserByEmail ...

func (*IDPMetrics) CountGetUserDataByID

func (idpMetrics *IDPMetrics) CountGetUserDataByID()

CountGetUserDataByID ...

func (*IDPMetrics) CountRequestError

func (idpMetrics *IDPMetrics) CountRequestError()

CountRequestError counts number of error that happened when doing http request (httpClient.Do)

func (*IDPMetrics) CountRequestStatusError

func (idpMetrics *IDPMetrics) CountRequestStatusError()

CountRequestStatusError counts number of responses that came from IdP with non success status code

func (*IDPMetrics) CountUpdateUserAppMetadata

func (idpMetrics *IDPMetrics) CountUpdateUserAppMetadata()

CountUpdateUserAppMetadata ...

type MockAppMetrics

type MockAppMetrics struct {
	GetMeterFunc       func() metric2.Meter
	CloseFunc          func() error
	ExposeFunc         func(port int, endpoint string) error
	IDPMetricsFunc     func() *IDPMetrics
	HTTPMiddlewareFunc func() *HTTPMiddleware
	GRPCMetricsFunc    func() *GRPCMetrics
}

MockAppMetrics mocks the AppMetrics interface

func (*MockAppMetrics) Close

func (mock *MockAppMetrics) Close() error

Close mocks the Close function of the AppMetrics interface

func (*MockAppMetrics) Expose

func (mock *MockAppMetrics) Expose(port int, endpoint string) error

Expose mocks the Expose function of the AppMetrics interface

func (*MockAppMetrics) GRPCMetrics

func (mock *MockAppMetrics) GRPCMetrics() *GRPCMetrics

GRPCMetrics mocks the GRPCMetrics function of the IDPMetrics interface

func (*MockAppMetrics) GetMeter

func (mock *MockAppMetrics) GetMeter() metric2.Meter

GetMeter mocks the GetMeter function of the AppMetrics interface

func (*MockAppMetrics) HTTPMiddleware

func (mock *MockAppMetrics) HTTPMiddleware() *HTTPMiddleware

HTTPMiddleware mocks the HTTPMiddleware function of the IDPMetrics interface

func (*MockAppMetrics) IDPMetrics

func (mock *MockAppMetrics) IDPMetrics() *IDPMetrics

IDPMetrics mocks the IDPMetrics function of the IDPMetrics interface

type WrappedResponseWriter

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

WrappedResponseWriter is a wrapper for http.ResponseWriter that allows the written HTTP status code to be captured for metrics reporting or logging purposes.

func WrapResponseWriter

func WrapResponseWriter(w http.ResponseWriter) *WrappedResponseWriter

WrapResponseWriter wraps original http.ResponseWriter

func (*WrappedResponseWriter) Status

func (rw *WrappedResponseWriter) Status() int

Status returns response status

func (*WrappedResponseWriter) WriteHeader

func (rw *WrappedResponseWriter) WriteHeader(code int)

WriteHeader wraps http.ResponseWriter.WriteHeader method

Jump to

Keyboard shortcuts

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