mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-05 12:31:02 +02:00
feature/featuretags: make clientmetrics optional
Saves 57 KB Updates #12614 Change-Id: If7eebec12b3cb30ae6264171d36a258c04b05a70 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
127a967207
commit
3ae7a351b4
13
feature/buildfeatures/feature_clientmetrics_disabled.go
Normal file
13
feature/buildfeatures/feature_clientmetrics_disabled.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build ts_omit_clientmetrics
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasClientMetrics is whether the binary was built with support for modular feature "Client metrics support".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_clientmetrics" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasClientMetrics = false
|
13
feature/buildfeatures/feature_clientmetrics_enabled.go
Normal file
13
feature/buildfeatures/feature_clientmetrics_enabled.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Code generated by gen.go; DO NOT EDIT.
|
||||
|
||||
//go:build !ts_omit_clientmetrics
|
||||
|
||||
package buildfeatures
|
||||
|
||||
// HasClientMetrics is whether the binary was built with support for modular feature "Client metrics support".
|
||||
// Specifically, it's whether the binary was NOT built with the "ts_omit_clientmetrics" build tag.
|
||||
// It's a const so it can be used for dead code elimination.
|
||||
const HasClientMetrics = true
|
@ -97,6 +97,7 @@ var Features = map[FeatureTag]FeatureMeta{
|
||||
"cloud": {Sym: "Cloud", Desc: "detect cloud environment to learn instances IPs and DNS servers"},
|
||||
"cli": {Sym: "CLI", Desc: "embed the CLI into the tailscaled binary"},
|
||||
"cliconndiag": {Sym: "CLIConnDiag", Desc: "CLI connection error diagnostics"},
|
||||
"clientmetrics": {Sym: "ClientMetrics", Desc: "Client metrics support"},
|
||||
"clientupdate": {Sym: "ClientUpdate", Desc: "Client auto-update support"},
|
||||
"completion": {Sym: "Completion", Desc: "CLI shell completion"},
|
||||
"dbus": {Sym: "DBus", Desc: "Linux DBus support"},
|
||||
|
@ -1218,6 +1218,11 @@ func (h *Handler) serveHandlePushMessage(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
func (h *Handler) serveUploadClientMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
if !buildfeatures.HasClientMetrics {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(struct{}{})
|
||||
return
|
||||
}
|
||||
if r.Method != httpm.POST {
|
||||
http.Error(w, "unsupported method", http.StatusMethodNotAllowed)
|
||||
return
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_clientmetrics
|
||||
|
||||
// Package clientmetric provides client-side metrics whose values
|
||||
// get occasionally logged.
|
||||
package clientmetric
|
||||
|
24
util/clientmetric/omit.go
Normal file
24
util/clientmetric/omit.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_clientmetrics
|
||||
|
||||
package clientmetric
|
||||
|
||||
type Metric struct{}
|
||||
|
||||
func (*Metric) Add(int64) {}
|
||||
func (*Metric) Set(int64) {}
|
||||
func (*Metric) Value() int64 { return 0 }
|
||||
func (*Metric) Register(expvarInt any) {}
|
||||
func (*Metric) UnregisterAll() {}
|
||||
|
||||
func HasPublished(string) bool { panic("unreachable") }
|
||||
func EncodeLogTailMetricsDelta() string { return "" }
|
||||
func WritePrometheusExpositionFormat(any) {}
|
||||
|
||||
var zeroMetric Metric
|
||||
|
||||
func NewCounter(string) *Metric { return &zeroMetric }
|
||||
func NewGauge(string) *Metric { return &zeroMetric }
|
||||
func NewAggregateCounter(string) *Metric { return &zeroMetric }
|
Loading…
x
Reference in New Issue
Block a user