observability

package
v0.0.0-...-a294835 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package observability is for Prometheus

Index

Constants

View Source
const (
	AzureMonitor = "azure_monitor"
	Datadog      = "datadog"
	Jaeger       = "jaeger"
	Prometheus   = "prometheus"
	Stackdriver  = "stackdriver"
	Zipkin       = "zipkin"
)

Known exporters

Variables

View Source
var (
	KeyListenPath, _             = tag.NewKey("path")
	KeyUpstreamPath, _           = tag.NewKey("upstream_path")
	KeyJWTValidationErrorType, _ = tag.NewKey("error")
)

Tags

View Source
var (
	MJWTManagerValidationErrors = stats.Int64(
		"plugin_jwt_manager_validation_error_total",
		"Number of validation errors by error type",
		dimensionless,
	)
	MOAuth2MissingHeader = stats.Int64(
		"plugin_oauth2_missing_header_total",
		"Number of failed oauth2 authentication due to missing header",
		dimensionless,
	)
	MOAuth2MalformedHeader = stats.Int64(
		"plugin_oauth2_malformed_header_total",
		"Number of failed oauth2 authentication due to malformed bearer header",
		dimensionless,
	)
	MOAuth2Authorized = stats.Int64(
		"plugin_oauth2_authorized_request_total",
		"Number of successful and authorized oauth2 authentication",
		dimensionless,
	)
	MOAuth2Unauthorized = stats.Int64(
		"plugin_oauth2_unauthorized_request_total",
		"Number of successful but unauthorized oauth2 authentication",
		dimensionless,
	)
)

Metrics

View Source
var AllViews = []*view.View{
	{
		Name:        "plugin_jwt_manager_validation_error_total",
		TagKeys:     []tag.Key{KeyJWTValidationErrorType},
		Measure:     MJWTManagerValidationErrors,
		Aggregation: view.Count(),
	},
	{
		Name:        "plugin_oauth2_missing_header_total",
		Measure:     MOAuth2MissingHeader,
		Aggregation: view.Count(),
	},
	{
		Name:        "plugin_oauth2_malformed_header_total",
		Measure:     MOAuth2MalformedHeader,
		Aggregation: view.Count(),
	},
	{
		Name:        "plugin_oauth2_authorized_request_total",
		Measure:     MOAuth2Authorized,
		Aggregation: view.Count(),
	},
	{
		Name:        "plugin_oauth2_unauthorized_request_total",
		Measure:     MOAuth2Unauthorized,
		Aggregation: view.Count(),
	},
	{
		Name:        "http_server_response_count_by_path_code_and_method",
		TagKeys:     []tag.Key{KeyListenPath, ochttp.StatusCode, ochttp.Method},
		Measure:     ochttp.ServerLatency,
		Aggregation: view.Count(),
	},
	{
		Name:        "http_server_request_latency_by_path_and_method",
		TagKeys:     []tag.Key{KeyListenPath, ochttp.Method},
		Measure:     ochttp.ServerLatency,
		Aggregation: ochttp.DefaultLatencyDistribution,
	},
	{
		Name:        "http_server_request_size",
		Measure:     ochttp.ServerRequestBytes,
		Aggregation: ochttp.DefaultSizeDistribution,
	},
	{
		Name:        "http_proxy_request_count_by_path",
		TagKeys:     []tag.Key{KeyUpstreamPath},
		Measure:     ochttp.ClientRequestCount,
		Aggregation: view.Count(),
	},
	{
		Name:        "http_proxy_request_latency_by_path",
		TagKeys:     []tag.Key{KeyUpstreamPath},
		Measure:     ochttp.ClientLatency,
		Aggregation: ochttp.DefaultLatencyDistribution,
	},
}

AllViews aggregates the metrics

View Source
var PrometheusExporter *prometheus.Exporter

PrometheusExporter is the prometheus exporter containing HTTP handler for "/metrics"

Functions

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext tries to extract request ID from context if present, otherwise returns empty string

func RequestIDToContext

func RequestIDToContext(ctx context.Context, requestID string) context.Context

RequestIDToContext puts a request ID to context for future use

Types

This section is empty.

Jump to

Keyboard shortcuts

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