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.
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 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
.
- 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 themetric.Meter
(s) derived from a given top-leveltallyotel.MeterProvider
- Every
metric.Meter
created by atallyotel.MeterProvider
uses the provided Meter name to build a set of nested sub-scopes (seetally.Scope.SubScope
) of the parenttallyotel.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-providedtallyotel.MeterScoper
. - Instruments created by a
metric.Meter
and invoked without anyattribute.KeyValue
s use their parentmetric.Meter
's scope - Instruments invoked with
attribute.KeyValue
s use a scope that is a sub-scope of their parent Meter's scope, tagged with the appropriate key-values (seetally.Scope.Tagged
)