mqmetrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mqmetrics holds the instruments every messagequeue broker records, so that the four brokers agree on what each number means.

Index

Constants

View Source
const (
	MessagesPublished = "messagequeue.messages_published"
	PublishErrors     = "messagequeue.publish_errors"
	PublishLatencyMS  = "messagequeue.publish_latency_ms"
	MessagesConsumed  = "messagequeue.messages_consumed"
	HandlerErrors     = "messagequeue.handler_errors"
	ConsumeLatencyMS  = "messagequeue.consume_latency_ms"
	ReceiveErrors     = "messagequeue.receive_errors"
)

The instrument names, one set shared by every broker.

These used to be built per topic — fmt.Sprintf("%s_consumed", topic) — which cost two things. A dashboard had no single series to aggregate over, because every topic was its own instrument rather than one instrument with a topic attribute. And the instrument name became a function of runtime config: OpenTelemetry accepts [A-Za-z][A-Za-z0-9_./-]{0,254} for an instrument name, which a PubSub subscription path ("projects/p/subscriptions/s") satisfies only by accident and an SQS queue URL does not satisfy at all, so a queue name that the broker was perfectly happy with failed instrument construction at startup. SQS documented that hazard against itself; it applied to all four.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

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

Consumer is the instrument set a broker's consumer records.

func NewConsumer

func NewConsumer(metricsProvider metrics.Provider, topic string) (*Consumer, error)

NewConsumer builds the consumer instrument set for a topic.

func (*Consumer) Handled

func (c *Consumer) Handled(ctx context.Context, startedAt time.Time, err error)

Handled records the outcome of one handler invocation: latency either way, then one of the two counters.

MessagesConsumed counts here rather than on arrival. Incrementing it before calling the handler made it a count of messages received, which is a number the broker already reports and which cannot go down when the handler starts failing — so a consumer whose handler errored on every message showed a healthy climbing "consumed" line with nothing beside it to contradict that.

func (*Consumer) ReceiveFailed

func (c *Consumer) ReceiveFailed(ctx context.Context)

ReceiveFailed counts a failure to read from the broker, as distinct from a handler that was given a message and failed on it.

type Publisher

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

Publisher is the instrument set a broker's publisher records.

func NewPublisher

func NewPublisher(metricsProvider metrics.Provider, topic string) (*Publisher, error)

NewPublisher builds the publisher instrument set for a topic.

func (*Publisher) Failed

func (p *Publisher) Failed(ctx context.Context)

Failed counts a publish that did not happen.

func (*Publisher) Published

func (p *Publisher) Published(ctx context.Context, startedAt time.Time)

Published counts a publish that did, and records how long it took.

Jump to

Keyboard shortcuts

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