Help us shape the future of Go! Take the 2026 Go Developer Survey

factory

package
v0.10.154 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package factory constructs a metrics.Sink from a URL, so the sink can be selected by configuration instead of by import.

sink, err := factory.NewMetricSinkFromURL("inmem://localhost?interval=10s&retain=1m")
if err != nil {
	return err
}
if _, err := metrics.NewGlobal(metrics.DefaultConfig("billing"), sink); err != nil {
	return err
}

Only the "inmem" scheme is registered; the Prometheus and CloudWatch sinks need options that do not map onto a URL and must be constructed directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricSinkFromURL

func NewMetricSinkFromURL(urlStr string) (metrics.Sink, error)

NewMetricSinkFromURL allows a generic URL input to configure any of the supported sinks. The scheme of the URL identifies the type of the sink, and the query parameters are used to set options.

Supported schemes:

"inmem://" - Initializes an InmemSink. The host and port are ignored. The
"interval" and "retain" query parameters must be specified with valid
durations, see metrics.NewInmemSink for details.

The Prometheus and CloudWatch sinks are not available here: they need options, such as a registerer or an AWS namespace, that do not map onto a URL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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