Closed SpicyLemon closed 1 month ago
After the last discussion it probably doesn't make sense to track object counts in these kinds of metrics. Any data warehouse will already have a complete picture of the type and number of assets already and will not rely on these counters. If there was value here it would likely be in processing time counters that track how long it takes to validate records--but even there we can get this data based on overall request processing time which is handled separately.
Summary of Bug
None of the metadata telemetry stuff is actually being emitted.
Version
v1.19.1
(all the way back tov1.3.0
when it was "added").Steps to Reproduce
Note: I haven't actually tried those steps, but I'm certain telemetry isn't being recorded.
I found this by noticing that we are attempting to record telemetry using code like this:
That
GetIncObjFunc
function returns afunc()
that actually does the telemetry stuff.When execution reaches that line, it queues up the call to
types.GetIncObjFunc(types.TLType_Scope, action)
to run at the end of the current function. So at the end, it callsGetIncObjFunc
, which just creates afunc()
. But nothing tellsgo
to actually execute that func, so it's simply discarded (similar to howdefer iter.Close()
just discards any error returned byiter.Close()
).If that line were this (note the extra
()
at the end):Then, when execution reaches that line, it would execute
types.GetIncObjFunc(types.TLType_Scope, action)
, then it would queue up the resultingfunc()
to run at the end of the current function. At the end, it'd then run the thing that updates telemetry before finishing it's return.To verify that nothing is happening:
var TelemetryCounter int
in theevents.go
file.GetIncObjFunc
to incrementTelemetryCounter
at the end of thefunc()
it returns (after the call(s) totelemetry.IncrCounterWithLabels
).TelemetryCounter
value before and after executions that should be doing telemetry stuff.defer types.GetIncObjFunc(types.TLType_Scope, action)
.TelemetryCounter
value was never changing.defer types.GetIncObjFunc(types.TLType_Scope, action)()
and found thatTelemetryCounter
DID increment in that test.The Problem
The
GetIncObjFunc
function returns afunc()
that updates telemetry data. However, the resultingfunc()
is never being executed; it's being created then thrown away.There's a couple ways to fix this.
()
to the end of all the invocations, e.g.defer types.GetIncObjFunc(types.TLType_Scope, action)()
.GetIncObjFunc
to just do the telemetry updates instead of returning a function that does it; probably want to rename it too since it's now doing something instead of getting a function.Further, I don't think we get anything by deferring these calls. In almost all cases, it's being done at the very end of the func anyway.
Further Consideration
It's probably worthwhile to have a discussion about whether this telemetry data is still wanted. I.e. should we fix this or delete that stuff?
Here's what it was supposed to track:
"metadata"
,"stored-object"
.1
if being created, or-1
if being deleted. If being updated, this telemetry entry isn't recorded; i.e. the value here is never0
."metadata"
,"object-action"
.1
(always).Labels:
"category"
"entry"
,"specification"
, or"object-store-locator"
."object-type"
"scope"
,"session"
,"record"
,"scope-specification"
,"contract-specification"
,"record-specification"
, or"object-store-locator"
."action"
"created"
,"updated"
, or"deleted"
.For Admin Use