mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-18 12:39:54 +00:00
Add Netbird version tracking to client metrics
Integrate Netbird version into VictoriaMetrics backend and metrics labels. Update `ClientMetrics` constructor and metric name formatting to include version information.
This commit is contained in:
@@ -66,6 +66,7 @@ import (
|
||||
signal "github.com/netbirdio/netbird/shared/signal/client"
|
||||
sProto "github.com/netbirdio/netbird/shared/signal/proto"
|
||||
"github.com/netbirdio/netbird/util"
|
||||
"github.com/netbirdio/netbird/version"
|
||||
)
|
||||
|
||||
// PeerConnectionTimeoutMax is a timeout of an initial connection attempt to a remote peer.
|
||||
@@ -278,7 +279,7 @@ func NewEngine(
|
||||
connSemaphore: semaphoregroup.NewSemaphoreGroup(connInitLimit),
|
||||
probeStunTurn: relay.NewStunTurnProbe(relay.DefaultCacheTTL),
|
||||
jobExecutor: jobexec.NewExecutor(),
|
||||
clientMetrics: metrics.NewClientMetrics(deploymentType, true),
|
||||
clientMetrics: metrics.NewClientMetrics(deploymentType, version.NetbirdVersion(), true),
|
||||
}
|
||||
|
||||
log.Infof("I am: %s", config.WgPrivateKey.PublicKey().String())
|
||||
|
||||
@@ -36,12 +36,12 @@ type ConnectionStageTimestamps struct {
|
||||
// NewClientMetrics creates a new ClientMetrics instance
|
||||
// If enabled is true, uses an OpenTelemetry implementation
|
||||
// If enabled is false, uses a no-op implementation
|
||||
func NewClientMetrics(deploymentType DeploymentType, enabled bool) *ClientMetrics {
|
||||
func NewClientMetrics(deploymentType DeploymentType, version string, enabled bool) *ClientMetrics {
|
||||
var impl metricsImplementation
|
||||
if !enabled {
|
||||
impl = &noopMetrics{}
|
||||
} else {
|
||||
impl = newVictoriaMetrics(deploymentType)
|
||||
impl = newVictoriaMetrics(deploymentType, version)
|
||||
}
|
||||
return &ClientMetrics{impl: impl}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,16 @@ import (
|
||||
type victoriaMetrics struct {
|
||||
// Static attributes applied to all metrics
|
||||
deploymentType DeploymentType
|
||||
version string
|
||||
|
||||
// Metrics set for managing all metrics
|
||||
set *metrics.Set
|
||||
}
|
||||
|
||||
func newVictoriaMetrics(deploymentType DeploymentType) metricsImplementation {
|
||||
func newVictoriaMetrics(deploymentType DeploymentType, version string) metricsImplementation {
|
||||
return &victoriaMetrics{
|
||||
deploymentType: deploymentType,
|
||||
version: version,
|
||||
set: metrics.NewSet(),
|
||||
}
|
||||
}
|
||||
@@ -92,11 +94,12 @@ func (m *victoriaMetrics) RecordConnectionStages(
|
||||
|
||||
// getMetricName constructs a metric name with labels
|
||||
func (m *victoriaMetrics) getMetricName(baseName, connectionType, attemptType string) string {
|
||||
return fmt.Sprintf(`%s{deployment_type=%q,connection_type=%q,attempt_type=%q}`,
|
||||
return fmt.Sprintf(`%s{deployment_type=%q,connection_type=%q,attempt_type=%q,version=%q}`,
|
||||
baseName,
|
||||
m.deploymentType.String(),
|
||||
connectionType,
|
||||
attemptType,
|
||||
m.version,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user