2022-09-29 11:42:50 +00:00
|
|
|
package metrics
|
|
|
|
|
2022-11-28 10:30:14 +00:00
|
|
|
import "context"
|
|
|
|
|
2022-09-29 11:42:50 +00:00
|
|
|
type Recorder interface {
|
2022-12-09 09:09:11 +00:00
|
|
|
Record(ClientQueryOperation)
|
|
|
|
RecordWithContext(context.Context, ClientQueryOperation)
|
2022-09-29 11:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type clientQueryRecorder struct {
|
|
|
|
manager MetricsConfigManager
|
|
|
|
ns string
|
|
|
|
kind string
|
|
|
|
client ClientType
|
|
|
|
}
|
|
|
|
|
|
|
|
func NamespacedClientQueryRecorder(m MetricsConfigManager, ns, kind string, client ClientType) Recorder {
|
|
|
|
return &clientQueryRecorder{
|
|
|
|
manager: m,
|
|
|
|
ns: ns,
|
|
|
|
kind: kind,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ClusteredClientQueryRecorder(m MetricsConfigManager, kind string, client ClientType) Recorder {
|
|
|
|
return &clientQueryRecorder{
|
|
|
|
manager: m,
|
|
|
|
kind: kind,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *clientQueryRecorder) Record(clientQueryOperation ClientQueryOperation) {
|
2022-11-28 10:30:14 +00:00
|
|
|
r.RecordWithContext(context.TODO(), clientQueryOperation)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *clientQueryRecorder) RecordWithContext(ctx context.Context, clientQueryOperation ClientQueryOperation) {
|
|
|
|
r.manager.RecordClientQueries(ctx, clientQueryOperation, r.client, r.kind, r.ns)
|
2022-09-29 11:42:50 +00:00
|
|
|
}
|