metrics

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Stats Reporter

This code provides the ability to register with OpenCensus the Views required to have the various metrics associated with eventing-kafka exported to whatever backend is configured (Prometheus by default). The METRICS_DOMAIN and METRICS_PORT environment variables will be used by Knative to produce unique metrics names and start the metrics service when InitializeObservability is called.

Note that this will serve only to expose the metrics on the specified port. The creation of the K8S Service and any external monitoring is left up to the individual component to provide.

Metrics Endpoint

Assuming the use of the default Prometheus backend and port, you may manually test the exposed /metrics endpoint by running a Kubernetes port forward to the service.

kubectl port-forward svc/<service> -n <namespace> 8081:8081

...and point your browser at http://localhost:8081/metrics, or you can use telepresence and curl...

telepresence
curl http://<service>.<namespace>.svc.cluster.local:8081/metrics

Documentation

Index

Constants

View Source
const (

	// LabelTopic is the label for the immutable name of the topic.
	LabelTopic = "topic"

	// Sarama Metrics
	RecordSendRateForTopicPrefix = "record-send-rate-for-topic-"
)

Variables

View Source
var RecordWrapper = metrics.Record

Our RecordWrapper, which defaults to the knative metrics.Record() This wrapper function facilitates minimally-invasive unit testing of the Report functionality without requiring live servers to be started.

Functions

This section is empty.

Types

type Reporter

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

Define StatsReporter Structure

func (*Reporter) Report

func (r *Reporter) Report(stats map[string]map[string]interface{})

Report The Sarama Metrics (go-metrics) Via Knative / OpenCensus Metrics

NOTE - Sarama provides lots of metrics which would be good to expose, but for now

       we're just quickly parsing out message counts.  This is for rough parity
       with the prior Confluent implementation and due to uncertainty around
       integrating with Knative Observability and potentially Sarama v2 using
       OpenTelemetry directly as described here...

			https://github.com/Shopify/sarama/issues/1340

       If we do decide to expose all available metrics, the following library might be useful...

         https://github.com/deathowl/go-metrics-prometheus

       Further the Sarama Consumer metrics don't track messages so we might need/want
       to manually track produced/consumed messages at the Topic/Partition/ConsumerGroup
       level.

type StatsReporter

type StatsReporter interface {
	Report(map[string]map[string]interface{})
}

StatsReporter defines the interface for sending ingress metrics.

func NewStatsReporter

func NewStatsReporter(log *zap.Logger) StatsReporter

StatsReporter Constructor

Jump to

Keyboard shortcuts

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