mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-05 04:11:59 +00:00
ipn/localapi: add API for uploading client metrics
Clients may have platform-specific metrics they would like uploaded (e.g. extracted from MetricKit on iOS). Add a new local API endpoint that allows metrics to be updated by a simple name/value JSON-encoded struct. Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
committed by
Mihai Parparita
parent
d6b8a18b09
commit
e37167b3ef
@@ -136,6 +136,15 @@ func Metrics() []*Metric {
|
||||
return sorted
|
||||
}
|
||||
|
||||
// HasPublished reports whether a metric with the given name has already been
|
||||
// published.
|
||||
func HasPublished(name string) bool {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
_, ok := metrics[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
// NewUnpublished initializes a new Metric without calling Publish on
|
||||
// it.
|
||||
func NewUnpublished(name string, typ Type) *Metric {
|
||||
|
||||
Reference in New Issue
Block a user