Conversation
ea9e0ef to
d01c936
Compare
| - shared metric-name, op-name, and tag-key constants | ||
| - default histogram buckets sized for RPC latency and large target counts | ||
| - an in-flight gauge helper that owns the atomic counter callers otherwise reinvent | ||
| - a failure classifier that reuses the errors package |
There was a problem hiding this comment.
@justinwon777 place holder for errors package design RFC
There was a problem hiding this comment.
why metrics should own a classifier?
There was a problem hiding this comment.
just discussed that we will just emit classified error code instead. Will remove
a1249f6 to
cf7326b
Compare
|
|
||
| Options are variadic and compose. `WithTags` merges into the base tag set with later-wins semantics on key collision. `WithDurationBuckets` / `WithValueBuckets` override the emitter's default histogram buckets on a single call. | ||
|
|
||
| ## Op-as-subscope |
There was a problem hiding this comment.
Op-as-subscope means passed op will be a subscope, called like
func (e *defaultEmitter) Inc(op, name string, opts ...Option) {
...
e.Subscope(op).Counter(name).Inc(1)
}
so the metric name is controller.get_target_graph.TreehashCacheLookup
|
|
||
| Every RPC calls one of: | ||
|
|
||
| - `e.Inc(op, Requests, WithTags({result: success}))` on the happy path |
There was a problem hiding this comment.
Inc and RecordFailure aren't intuitive names for counterparts of each other. can we rename?
There was a problem hiding this comment.
Also, not sure why is Inc and failure/success is a thing. Do we need this?
There was a problem hiding this comment.
good point. added symmetrical helper and documented generic purpose of Inc
4f4387b to
54a049f
Compare
sbalabanov
left a comment
There was a problem hiding this comment.
Missing pieces:
- error classification integration
- working with histograms for both status and duration and an example on custom buckets
|
|
||
| Tango is a library. Consumers wire it into their own `fx` graph with their own `tally.Scope`, and often deploy multiple flavors (long-running server, batch job, one-shot CLI) side-by-side. Without a shared convention every deployment invents its own metric names and tag layout, and dashboards devolve into per-name merges. | ||
|
|
||
| This package owns: |
There was a problem hiding this comment.
should this file be README.md under observability/metrics then?
There was a problem hiding this comment.
following https://github.com/uber-go/fx/tree/d5da5b04ac906bfbad8b400baeee9b970c1be6f3/docs/src
this is meant to be usage doc
| - shared metric-name, op-name, and tag-key constants | ||
| - default histogram buckets sized for RPC latency and large target counts | ||
| - an in-flight gauge helper that owns the atomic counter callers otherwise reinvent | ||
| - a failure classifier that reuses the errors package |
There was a problem hiding this comment.
why metrics should own a classifier?
| - default histogram buckets sized for RPC latency and large target counts | ||
| - an in-flight gauge helper that owns the atomic counter callers otherwise reinvent | ||
| - a failure classifier that reuses the errors package | ||
| - context-based emitter propagation so downstream helpers do not need the emitter threaded through every signature |
There was a problem hiding this comment.
they still need to thread context object though.
For the record, I do not necessarily agree that this is better approach than explicit signature-based, but not going to make it blocking.
There was a problem hiding this comment.
Good point. Yes, if a function needs to send metrics, it should explictly extract from context, but that should be the standard idiom (context has to be there, no context is worse that no metrics). I'll add this bit in the doc
This is the same for all other request scoped things like logger, tracings, signals etc. Emitter is what all downstream functions need but not required for business logic.
Signature based will just require the arg in every callsite -- like passing scope into hashing even though it's not needed in the actual logic, plus we'll have to create a subscope and be careful not to mix up with the one from parent
|
|
||
| ## TrackInFlight | ||
|
|
||
| Gauges are update-only, so an in-flight counter needs an owning atomic somewhere. Rather than force every call site to allocate its own `atomic.Int64` and remember to update the gauge, the Emitter.TrackInFlight owns a per-op `*int64`: |
There was a problem hiding this comment.
what is the practical example where gauges need to be used for Tango?
Gauge is a pretty nasty metric type when it comes to distributed systems with multiple running instances, and should be in general avoided.
There was a problem hiding this comment.
Considering how heavy graph computation could be, I think it's beneficial to track inflight requests/leased workspaces per instance. Gauge is the natural fit here, this way users can have visibility into how much scale the service needs (e.g. how many workers exhausted workspace pool). Especially for native_orchestrator, where the computation happen on hosts.
There was a problem hiding this comment.
In practice, when you track per-instance metrics, cardinality starts to become a problem.
It is almost always better to report two counter types of metrics instead: first when the request started, and second when the request finished (as a histogram, with latency and an outcome).
Rely on logging/log aggregation for high-cardinality tracking/debugging.
…local metrics Rework metrics.md around the revised proposal: a concrete Tally-backed Emitter that binds and returns instruments, explicit dependency injection instead of context propagation, domain-local operation/metric names and bucket policies, controller-boundary request classification, per-series in-flight counters, and explicit no-op construction.
…ing-method errors Refine the revised metrics design: remove the gauge/in-flight tracking, drop the central shared-conventions vocabulary, and return instruments directly from the binding methods (only New surfaces a nil-scope wiring error). Add a Request-specific tags example.
|
updated based on discussion offline. |
add Tango Metrics Inventory RFC into the repo. Covers the Emitter contract and its usage in callsites