tallyotel

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 3 Imported by: 1

README

tallyotel

PkgGoDev Go Report Card

A Tally/Open Telemetry bridge allowing for code using Open Telemetry instruments to emit metrics with Tally.

A demonstration of emitting metrics from Open Telemetry instruments through Tally to Prometheus can be found at https://github.com/mmcshane/tallyotel-demo.

As Tally contains abstractions for exporting metrics and Open Telemetry also contains abstractions for exporting metrics, the use of this particular bridge library is likely to be a transient period for any given codebase. If your code is instrumented to use Open Telemetry already then you're probably better off migrating to the Open Telemetry native exporter configuration. However, if you're in a situation where the use of Tally is required but you still want to use Open Telemetry metric instruments, then this library is what you need to bridge the two.

Instrument Support and Mappings

As Tally does not support asynchronous instrument types (i.e. the Observer types), this library does not offer them. Here we describe how Open Telemetry instrument types are mapped to Tally instruments.

OTEL Type Tally Type Notes
Counter tally.Counter Only integer counters (number.NumberKindInt64) are supported. Note that OTEL counters are monotonic - use UpDownCounter to both increment and decrement.
Asynchronous Counter Async instruments not supported.
Asynchronous Gauge Async instruments not supported.
Histogram tally.Histogram Histograms using a unit of unit.Millisecond use the Tally Histogram.RecordDuration Histogram API, otherwise Histogram.RecordValue.
UpDownCounter tally.Counter Only integer counters (number.NumberKindInt64) are supported.
Asynchronous UpDownCounter Async instruments not supported.

Tally Scope Usage

Tally makes heavy use of a graph of scope objects for instrument naming and to bundle "tags" with a set of instruments. Open Telemetry does not have a clear analog for Tally scopes but this bridge does use them internally in a predictable way. Here are the rules for how scopes are used within tallyotel.

  1. Every tallyotel.MeterProvider instance has a Scope which is passed to it at construction time. Users can use this scope to make Tally-specific configurations to the metrics supplied by the metric.Meter(s) derived from a given top-level tallyotel.MeterProvider
  2. Every metric.Meter created by a tallyotel.MeterProvider uses the provided Meter name to build a set of nested sub-scopes (see tally.Scope.SubScope) of the parent tallyotel.MeterProvider's scope. Sub-scopes are implied through the Meter name via a separator string (by default: "."). The exact behavior here can be modified through a client-provided tallyotel.MeterScoper.
  3. Instruments created by a metric.Meter and invoked without any attribute.KeyValues use their parent metric.Meter's scope
  4. Instruments invoked with attribute.KeyValues use a scope that is a sub-scope of their parent Meter's scope, tagged with the appropriate key-values (see tally.Scope.Tagged)

Documentation

Overview

Package tallyotel provides a bridge between code instrumented to emit metrics via the the standard Open Telemetry go library/sdk (https://github.com/open-telemetry/opentelemetry-go) and the Tally (https://github.com/uber-go/tally) metrics library. Effectively it allows you to use Open Telmetry to _record_ your metrics and Tally to _emit_ your metrics.

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithHistogramBucketer wraps a HistogramBucketer into a tallyotel Opt so
	// that it can be passed in to a MeterProvider.
	WithHistogramBucketer = bridge.WithHistogramBucketer

	// WithMeterScoper wraps a MeterScoper into a tallyotel Opt so that it can
	// be passed in to a a MeterProvider.
	WithMeterScoper = bridge.WithMeterScoper

	// DefaultBucketer returns the default histogram buckets. It is exposed here
	// for use as a fallback bucketing strategy within a custom
	// HistogramBucketer.
	DefaultBucketer = bridge.DefaultBucketer

	// WithScopeNameSeparator provides a string to a MeterProvider at
	// construction time to be used in splitting child Meter names into scope
	// names.
	WithScopeNameSeparator = bridge.WithScopeNameSeparator
)

Functions

func NewMeterProvider

func NewMeterProvider(scope tally.Scope, opts ...Opt) metric.MeterProvider

NewMeterProvider instantiates a tallyotel bridge metric.MeterProvider that uses the supplied tally.Scope as a base scope for the creation of child Meters and Instruments.

Types

type HistogramBucketer

type HistogramBucketer = bridge.HistogramBucketer

HistogramBucketer is an func allowing client code to pick different bucketization strategies for histograms based on the information in the histogram's sdkapi.Descriptor.

type MeterScoper added in v0.5.0

type MeterScoper = bridge.MeterScoper

MeterScoper allows clients to override the default behavior of creating a named Tally sub-scope for each Meter.

type Opt

type Opt = bridge.Opt

Opt is the type for supplying optional configuration parameters to a `tallyotel.NewMeterProvider`

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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