MM-63467: Refactor constLabels to a common initializer (#30779)

This is useful to avoid mistakes while adding new metrics.

https://mattermost.atlassian.net/browse/MM-63467

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2025-04-23 21:59:51 +05:30
коммит произвёл GitHub
родитель 6ae0efd285
Коммит 271d928e87

Просмотреть файл

@@ -276,6 +276,12 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
additionalLabels[MetricsCloudDatabaseClusterLabel] = cluster additionalLabels[MetricsCloudDatabaseClusterLabel] = cluster
} }
} }
// Helper function to apply additional labels to histogram options
withLabels := func(opts prometheus.HistogramOpts) prometheus.HistogramOpts {
opts.ConstLabels = additionalLabels
return opts
}
// Posts Subsystem // Posts Subsystem
m.PostCreateCounter = prometheus.NewCounter(prometheus.CounterOpts{ m.PostCreateCounter = prometheus.NewCounter(prometheus.CounterOpts{
@@ -460,13 +466,12 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
}) })
m.Registry.MustRegister(m.ClusterRequestsCounter) m.Registry.MustRegister(m.ClusterRequestsCounter)
m.ClusterRequestsDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ m.ClusterRequestsDuration = prometheus.NewHistogram(withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemCluster, Subsystem: MetricsSubsystemCluster,
Name: "cluster_request_duration_seconds", Name: "cluster_request_duration_seconds",
Help: "The total duration in seconds of the inter-node cluster requests.", Help: "The total duration in seconds of the inter-node cluster requests.",
ConstLabels: additionalLabels, }))
})
m.Registry.MustRegister(m.ClusterRequestsDuration) m.Registry.MustRegister(m.ClusterRequestsDuration)
m.ClusterEventTypeCounters = prometheus.NewCounterVec( m.ClusterEventTypeCounters = prometheus.NewCounterVec(
@@ -730,13 +735,12 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
}) })
m.Registry.MustRegister(m.SearchPostSearchesCounter) m.Registry.MustRegister(m.SearchPostSearchesCounter)
m.SearchPostSearchesDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ m.SearchPostSearchesDuration = prometheus.NewHistogram(withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSearch, Subsystem: MetricsSubsystemSearch,
Name: "posts_searches_duration_seconds", Name: "posts_searches_duration_seconds",
Help: "The total duration in seconds of post searches.", Help: "The total duration in seconds of post searches.",
ConstLabels: additionalLabels, }))
})
m.Registry.MustRegister(m.SearchPostSearchesDuration) m.Registry.MustRegister(m.SearchPostSearchesDuration)
m.SearchFileSearchesCounter = prometheus.NewCounter(prometheus.CounterOpts{ m.SearchFileSearchesCounter = prometheus.NewCounter(prometheus.CounterOpts{
@@ -748,13 +752,12 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
}) })
m.Registry.MustRegister(m.SearchFileSearchesCounter) m.Registry.MustRegister(m.SearchFileSearchesCounter)
m.SearchFileSearchesDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ m.SearchFileSearchesDuration = prometheus.NewHistogram(withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSearch, Subsystem: MetricsSubsystemSearch,
Name: "files_searches_duration_seconds", Name: "files_searches_duration_seconds",
Help: "The total duration in seconds of file searches.", Help: "The total duration in seconds of file searches.",
ConstLabels: additionalLabels, }))
})
m.Registry.MustRegister(m.SearchFileSearchesDuration) m.Registry.MustRegister(m.SearchFileSearchesDuration)
m.ActiveUsers = prometheus.NewGauge(prometheus.GaugeOpts{ m.ActiveUsers = prometheus.NewGauge(prometheus.GaugeOpts{
@@ -767,37 +770,34 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.ActiveUsers) m.Registry.MustRegister(m.ActiveUsers)
m.StoreTimesHistograms = prometheus.NewHistogramVec( m.StoreTimesHistograms = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemDB, Subsystem: MetricsSubsystemDB,
Name: "store_time", Name: "store_time",
Help: "Time to execute the store method", Help: "Time to execute the store method",
ConstLabels: additionalLabels, }),
},
[]string{"method", "success"}, []string{"method", "success"},
) )
m.Registry.MustRegister(m.StoreTimesHistograms) m.Registry.MustRegister(m.StoreTimesHistograms)
m.APITimesHistograms = prometheus.NewHistogramVec( m.APITimesHistograms = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemAPI, Subsystem: MetricsSubsystemAPI,
Name: "time", Name: "time",
Help: "Time to execute the api handler", Help: "Time to execute the api handler",
ConstLabels: additionalLabels, }),
},
[]string{"handler", "method", "status_code", "origin_client", "page_load_context"}, []string{"handler", "method", "status_code", "origin_client", "page_load_context"},
) )
m.Registry.MustRegister(m.APITimesHistograms) m.Registry.MustRegister(m.APITimesHistograms)
m.RedisTimesHistograms = prometheus.NewHistogramVec( m.RedisTimesHistograms = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemDB, Subsystem: MetricsSubsystemDB,
Name: "cache_time", Name: "cache_time",
Help: "Time to execute the cache handler", Help: "Time to execute the cache handler",
ConstLabels: additionalLabels, }),
},
[]string{"cache_name", "operation"}, []string{"cache_name", "operation"},
) )
m.Registry.MustRegister(m.RedisTimesHistograms) m.Registry.MustRegister(m.RedisTimesHistograms)
@@ -841,48 +841,44 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
// Plugin Subsystem // Plugin Subsystem
m.PluginHookTimeHistogram = prometheus.NewHistogramVec( m.PluginHookTimeHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemPlugin, Subsystem: MetricsSubsystemPlugin,
Name: "hook_time", Name: "hook_time",
Help: "Time to execute plugin hook handler in seconds.", Help: "Time to execute plugin hook handler in seconds.",
ConstLabels: additionalLabels, }),
},
[]string{"plugin_id", "hook_name", "success"}, []string{"plugin_id", "hook_name", "success"},
) )
m.Registry.MustRegister(m.PluginHookTimeHistogram) m.Registry.MustRegister(m.PluginHookTimeHistogram)
m.PluginMultiHookTimeHistogram = prometheus.NewHistogramVec( m.PluginMultiHookTimeHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemPlugin, Subsystem: MetricsSubsystemPlugin,
Name: "multi_hook_time", Name: "multi_hook_time",
Help: "Time to execute multiple plugin hook handler in seconds.", Help: "Time to execute multiple plugin hook handler in seconds.",
ConstLabels: additionalLabels, }),
},
[]string{"plugin_id"}, []string{"plugin_id"},
) )
m.Registry.MustRegister(m.PluginMultiHookTimeHistogram) m.Registry.MustRegister(m.PluginMultiHookTimeHistogram)
m.PluginMultiHookServerTimeHistogram = prometheus.NewHistogram( m.PluginMultiHookServerTimeHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemPlugin, Subsystem: MetricsSubsystemPlugin,
Name: "multi_hook_server_time", Name: "multi_hook_server_time",
Help: "Time for the server to execute multiple plugin hook handlers in seconds.", Help: "Time for the server to execute multiple plugin hook handlers in seconds.",
ConstLabels: additionalLabels, }),
},
) )
m.Registry.MustRegister(m.PluginMultiHookServerTimeHistogram) m.Registry.MustRegister(m.PluginMultiHookServerTimeHistogram)
m.PluginAPITimeHistogram = prometheus.NewHistogramVec( m.PluginAPITimeHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemPlugin, Subsystem: MetricsSubsystemPlugin,
Name: "api_time", Name: "api_time",
Help: "Time to execute plugin API handlers in seconds.", Help: "Time to execute plugin API handlers in seconds.",
ConstLabels: additionalLabels, }),
},
[]string{"plugin_id", "api_name", "success"}, []string{"plugin_id", "api_name", "success"},
) )
m.Registry.MustRegister(m.PluginAPITimeHistogram) m.Registry.MustRegister(m.PluginAPITimeHistogram)
@@ -983,25 +979,23 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.RemoteClusterMsgErrorsCounter) m.Registry.MustRegister(m.RemoteClusterMsgErrorsCounter)
m.RemoteClusterPingTimesHistograms = prometheus.NewHistogramVec( m.RemoteClusterPingTimesHistograms = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemRemoteCluster, Subsystem: MetricsSubsystemRemoteCluster,
Name: "ping_time", Name: "ping_time",
Help: "The ping roundtrip times to the remote cluster", Help: "The ping roundtrip times to the remote cluster",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id"}, []string{"remote_id"},
) )
m.Registry.MustRegister(m.RemoteClusterPingTimesHistograms) m.Registry.MustRegister(m.RemoteClusterPingTimesHistograms)
m.RemoteClusterClockSkewHistograms = prometheus.NewHistogramVec( m.RemoteClusterClockSkewHistograms = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemRemoteCluster, Subsystem: MetricsSubsystemRemoteCluster,
Name: "clock_skew", Name: "clock_skew",
Help: "An approximated value for clock skew between clusters", Help: "An approximated value for clock skew between clusters",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id"}, []string{"remote_id"},
) )
m.Registry.MustRegister(m.RemoteClusterClockSkewHistograms) m.Registry.MustRegister(m.RemoteClusterClockSkewHistograms)
@@ -1033,13 +1027,12 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.SharedChannelsSyncCount) m.Registry.MustRegister(m.SharedChannelsSyncCount)
m.SharedChannelsTaskInQueueHistogram = prometheus.NewHistogram( m.SharedChannelsTaskInQueueHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSharedChannels, Subsystem: MetricsSubsystemSharedChannels,
Name: "task_in_queue_duration_seconds", Name: "task_in_queue_duration_seconds",
Help: "Duration tasks spend in queue (seconds)", Help: "Duration tasks spend in queue (seconds)",
ConstLabels: additionalLabels, }),
},
) )
m.Registry.MustRegister(m.SharedChannelsTaskInQueueHistogram) m.Registry.MustRegister(m.SharedChannelsTaskInQueueHistogram)
@@ -1055,49 +1048,45 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.SharedChannelsQueueSize) m.Registry.MustRegister(m.SharedChannelsQueueSize)
m.SharedChannelsSyncCollectionHistogram = prometheus.NewHistogramVec( m.SharedChannelsSyncCollectionHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSharedChannels, Subsystem: MetricsSubsystemSharedChannels,
Name: "sync_collection_duration_seconds", Name: "sync_collection_duration_seconds",
Help: "Duration tasks spend collecting sync data (seconds)", Help: "Duration tasks spend collecting sync data (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id"}, []string{"remote_id"},
) )
m.Registry.MustRegister(m.SharedChannelsSyncCollectionHistogram) m.Registry.MustRegister(m.SharedChannelsSyncCollectionHistogram)
m.SharedChannelsSyncSendHistogram = prometheus.NewHistogramVec( m.SharedChannelsSyncSendHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSharedChannels, Subsystem: MetricsSubsystemSharedChannels,
Name: "sync_send_duration_seconds", Name: "sync_send_duration_seconds",
Help: "Duration tasks spend sending sync data (seconds)", Help: "Duration tasks spend sending sync data (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id"}, []string{"remote_id"},
) )
m.Registry.MustRegister(m.SharedChannelsSyncSendHistogram) m.Registry.MustRegister(m.SharedChannelsSyncSendHistogram)
m.SharedChannelsSyncCollectionStepHistogram = prometheus.NewHistogramVec( m.SharedChannelsSyncCollectionStepHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSharedChannels, Subsystem: MetricsSubsystemSharedChannels,
Name: "sync_collection_step_duration_seconds", Name: "sync_collection_step_duration_seconds",
Help: "Duration tasks spend in each step collecting data (seconds)", Help: "Duration tasks spend in each step collecting data (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id", "step"}, []string{"remote_id", "step"},
) )
m.Registry.MustRegister(m.SharedChannelsSyncCollectionStepHistogram) m.Registry.MustRegister(m.SharedChannelsSyncCollectionStepHistogram)
m.SharedChannelsSyncSendStepHistogram = prometheus.NewHistogramVec( m.SharedChannelsSyncSendStepHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSharedChannels, Subsystem: MetricsSubsystemSharedChannels,
Name: "sync_send_step_duration_seconds", Name: "sync_send_step_duration_seconds",
Help: "Duration tasks spend in each step sending data (seconds)", Help: "Duration tasks spend in each step sending data (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"remote_id", "step"}, []string{"remote_id", "step"},
) )
m.Registry.MustRegister(m.SharedChannelsSyncSendStepHistogram) m.Registry.MustRegister(m.SharedChannelsSyncSendStepHistogram)
@@ -1197,109 +1186,101 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.NotificationUnsupportedCounters) m.Registry.MustRegister(m.NotificationUnsupportedCounters)
m.ClientTimeToFirstByte = NewHistogramVec( m.ClientTimeToFirstByte = NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "time_to_first_byte", Name: "time_to_first_byte",
Help: "Duration from when a browser starts to request a page from a server until when it starts to receive data in response (seconds)", Help: "Duration from when a browser starts to request a page from a server until when it starts to receive data in response (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
m.Platform.Log(), m.Platform.Log(),
) )
m.Registry.MustRegister(m.ClientTimeToFirstByte) m.Registry.MustRegister(m.ClientTimeToFirstByte)
m.ClientTimeToLastByte = NewHistogramVec( m.ClientTimeToLastByte = NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "time_to_last_byte", Name: "time_to_last_byte",
Help: "Duration from when a browser starts to request a page from a server until when it receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first. (seconds)", Help: "Duration from when a browser starts to request a page from a server until when it receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first. (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
m.Platform.Log(), m.Platform.Log(),
) )
m.Registry.MustRegister(m.ClientTimeToLastByte) m.Registry.MustRegister(m.ClientTimeToLastByte)
m.ClientTimeToDOMInteractive = NewHistogramVec( m.ClientTimeToDOMInteractive = NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "dom_interactive", Name: "dom_interactive",
Help: "Duration from when a browser starts to request a page from a server until when it sets the document's readyState to interactive. (seconds)", Help: "Duration from when a browser starts to request a page from a server until when it sets the document's readyState to interactive. (seconds)",
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 7.5, 10, 12.5, 15}, Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 7.5, 10, 12.5, 15},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
m.Platform.Log(), m.Platform.Log(),
) )
m.Registry.MustRegister(m.ClientTimeToDOMInteractive) m.Registry.MustRegister(m.ClientTimeToDOMInteractive)
m.ClientSplashScreenEnd = NewHistogramVec( m.ClientSplashScreenEnd = NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "splash_screen", Name: "splash_screen",
Help: "Duration from when a browser starts to request a page from a server until when the splash screen ends. (seconds)", Help: "Duration from when a browser starts to request a page from a server until when the splash screen ends. (seconds)",
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 7.5, 10, 12.5, 15}, Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 7.5, 10, 12.5, 15},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "page_type", "user_id"}, []string{"platform", "agent", "page_type", "user_id"},
m.Platform.Log(), m.Platform.Log(),
) )
m.Registry.MustRegister(m.ClientSplashScreenEnd) m.Registry.MustRegister(m.ClientSplashScreenEnd)
m.ClientFirstContentfulPaint = prometheus.NewHistogramVec( m.ClientFirstContentfulPaint = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "first_contentful_paint", Name: "first_contentful_paint",
Help: "Duration of how long it takes for any content to be displayed on screen to a user (seconds)", Help: "Duration of how long it takes for any content to be displayed on screen to a user (seconds)",
// Extend the range of buckets for this while we get a better idea of the expected range of this metric is // Extend the range of buckets for this while we get a better idea of the expected range of this metric is
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 20}, Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 20},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
) )
m.Registry.MustRegister(m.ClientFirstContentfulPaint) m.Registry.MustRegister(m.ClientFirstContentfulPaint)
m.ClientLargestContentfulPaint = prometheus.NewHistogramVec( m.ClientLargestContentfulPaint = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "largest_contentful_paint", Name: "largest_contentful_paint",
Help: "Duration of how long it takes for large content to be displayed on screen to a user (seconds)", Help: "Duration of how long it takes for large content to be displayed on screen to a user (seconds)",
// Extend the range of buckets for this while we get a better idea of the expected range of this metric is // Extend the range of buckets for this while we get a better idea of the expected range of this metric is
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 20}, Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 20},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "region", "user_id"}, []string{"platform", "agent", "region", "user_id"},
) )
m.Registry.MustRegister(m.ClientLargestContentfulPaint) m.Registry.MustRegister(m.ClientLargestContentfulPaint)
m.ClientInteractionToNextPaint = prometheus.NewHistogramVec( m.ClientInteractionToNextPaint = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "interaction_to_next_paint", Name: "interaction_to_next_paint",
Help: "Measure of how long it takes for a user to see the effects of clicking with a mouse, tapping with a touchscreen, or pressing a key on the keyboard (seconds)", Help: "Measure of how long it takes for a user to see the effects of clicking with a mouse, tapping with a touchscreen, or pressing a key on the keyboard (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "interaction", "user_id"}, []string{"platform", "agent", "interaction", "user_id"},
) )
m.Registry.MustRegister(m.ClientInteractionToNextPaint) m.Registry.MustRegister(m.ClientInteractionToNextPaint)
m.ClientCumulativeLayoutShift = prometheus.NewHistogramVec( m.ClientCumulativeLayoutShift = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "cumulative_layout_shift", Name: "cumulative_layout_shift",
Help: "Measure of how much a page's content shifts unexpectedly", Help: "Measure of how much a page's content shifts unexpectedly",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
) )
m.Registry.MustRegister(m.ClientCumulativeLayoutShift) m.Registry.MustRegister(m.ClientCumulativeLayoutShift)
@@ -1317,184 +1298,169 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.ClientLongTasks) m.Registry.MustRegister(m.ClientLongTasks)
m.ClientPageLoadDuration = NewHistogramVec( m.ClientPageLoadDuration = NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "page_load", Name: "page_load",
Help: "The amount of time from when the browser starts loading the web app until when the web app's load event has finished (seconds)", Help: "The amount of time from when the browser starts loading the web app until when the web app's load event has finished (seconds)",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 20, 40}, Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 20, 40},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
m.Platform.Log(), m.Platform.Log(),
) )
m.Registry.MustRegister(m.ClientPageLoadDuration) m.Registry.MustRegister(m.ClientPageLoadDuration)
m.ClientChannelSwitchDuration = prometheus.NewHistogramVec( m.ClientChannelSwitchDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "channel_switch", Name: "channel_switch",
Help: "Duration of the time taken from when a user clicks on a channel in the LHS to when posts in that channel become visible (seconds)", Help: "Duration of the time taken from when a user clicks on a channel in the LHS to when posts in that channel become visible (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "fresh", "user_id"}, []string{"platform", "agent", "fresh", "user_id"},
) )
m.Registry.MustRegister(m.ClientChannelSwitchDuration) m.Registry.MustRegister(m.ClientChannelSwitchDuration)
m.ClientTeamSwitchDuration = prometheus.NewHistogramVec( m.ClientTeamSwitchDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "team_switch", Name: "team_switch",
Help: "Duration of the time taken from when a user clicks on a team in the LHS to when posts in that team become visible (seconds)", Help: "Duration of the time taken from when a user clicks on a team in the LHS to when posts in that team become visible (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "fresh", "user_id"}, []string{"platform", "agent", "fresh", "user_id"},
) )
m.Registry.MustRegister(m.ClientTeamSwitchDuration) m.Registry.MustRegister(m.ClientTeamSwitchDuration)
m.ClientRHSLoadDuration = prometheus.NewHistogramVec( m.ClientRHSLoadDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "rhs_load", Name: "rhs_load",
Help: "Duration of the time taken from when a user clicks to open a thread in the RHS until when posts in that thread become visible (seconds)", Help: "Duration of the time taken from when a user clicks to open a thread in the RHS until when posts in that thread become visible (seconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
) )
m.Registry.MustRegister(m.ClientRHSLoadDuration) m.Registry.MustRegister(m.ClientRHSLoadDuration)
m.ClientGlobalThreadsLoadDuration = prometheus.NewHistogramVec( m.ClientGlobalThreadsLoadDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsWeb, Subsystem: MetricsSubsystemClientsWeb,
Name: "global_threads_load", Name: "global_threads_load",
Help: "Duration of the time taken from when a user clicks to open Threads in the LHS until when the global threads view becomes visible (milliseconds)", Help: "Duration of the time taken from when a user clicks to open Threads in the LHS until when the global threads view becomes visible (milliseconds)",
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "user_id"}, []string{"platform", "agent", "user_id"},
) )
m.Registry.MustRegister(m.ClientGlobalThreadsLoadDuration) m.Registry.MustRegister(m.ClientGlobalThreadsLoadDuration)
m.MobileClientLoadDuration = prometheus.NewHistogramVec( m.MobileClientLoadDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_load", Name: "mobile_load",
Help: "Duration of the time taken from when a user opens the app and the app finally loads all relevant information (seconds)", Help: "Duration of the time taken from when a user opens the app and the app finally loads all relevant information (seconds)",
Buckets: []float64{1, 1.5, 2, 3, 4, 4.5, 5, 5.5, 6, 7.5, 10, 20, 25, 30}, Buckets: []float64{1, 1.5, 2, 3, 4, 4.5, 5, 5.5, 6, 7.5, 10, 20, 25, 30},
ConstLabels: additionalLabels, }),
},
[]string{"platform"}, []string{"platform"},
) )
m.MobileClientNetworkRequestsAverageSpeed = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsAverageSpeed = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_average_speed", Name: "mobile_network_requests_average_speed",
Help: "Average speed of network requests in megabytes per second (MBps)", Help: "Average speed of network requests in megabytes per second (MBps)",
Buckets: []float64{1000, 10000, 50000, 100000, 500000, 1000000, 5000000}, Buckets: []float64{1000, 10000, 50000, 100000, 500000, 1000000, 5000000},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsEffectiveLatency = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsEffectiveLatency = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_effective_latency", Name: "mobile_network_requests_effective_latency",
Help: "Effective latency of network requests in seconds", Help: "Effective latency of network requests in seconds",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10}, Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsElapsedTime = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsElapsedTime = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_elapsed_time", Name: "mobile_network_requests_elapsed_time",
Help: "Total elapsed time of network requests in seconds", Help: "Total elapsed time of network requests in seconds",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10}, Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsLatency = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsLatency = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_latency", Name: "mobile_network_requests_latency",
Help: "Latency of network requests in seconds", Help: "Latency of network requests in seconds",
Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10}, Buckets: []float64{0.1, 0.25, 0.5, 1, 2.5, 5, 10},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsTotalCompressedSize = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsTotalCompressedSize = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_total_compressed_size", Name: "mobile_network_requests_total_compressed_size",
Help: "Total compressed size of network requests in bytes", Help: "Total compressed size of network requests in bytes",
Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 20, 50}, Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 20, 50},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsTotalParallelRequests = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsTotalParallelRequests = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_total_parallel_requests", Name: "mobile_network_requests_total_parallel_requests",
Help: "Total number of parallel network requests made", Help: "Total number of parallel network requests made",
Buckets: []float64{1, 2, 5, 10, 20, 50, 100}, Buckets: []float64{1, 2, 5, 10, 20, 50, 100},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsTotalRequests = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsTotalRequests = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_total_requests", Name: "mobile_network_requests_total_requests",
Help: "Total number of network requests made", Help: "Total number of network requests made",
Buckets: []float64{1, 2, 5, 10, 20, 50, 100}, Buckets: []float64{1, 2, 5, 10, 20, 50, 100},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsTotalSequentialRequests = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsTotalSequentialRequests = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_total_sequential_requests", Name: "mobile_network_requests_total_sequential_requests",
Help: "Total number of sequential network requests made", Help: "Total number of sequential network requests made",
Buckets: []float64{1, 2, 5, 10, 20, 50, 100}, Buckets: []float64{1, 2, 5, 10, 20, 50, 100},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
m.MobileClientNetworkRequestsTotalSize = prometheus.NewHistogramVec( m.MobileClientNetworkRequestsTotalSize = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_network_requests_total_size", Name: "mobile_network_requests_total_size",
Help: "Total uncompressed size of network requests in bytes", Help: "Total uncompressed size of network requests in bytes",
Buckets: []float64{1000, 10000, 50000, 100000, 500000, 1000000, 5000000}, Buckets: []float64{1000, 10000, 50000, 100000, 500000, 1000000, 5000000},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "agent", "network_request_group"}, []string{"platform", "agent", "network_request_group"},
) )
@@ -1510,27 +1476,25 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.MobileClientNetworkRequestsTotalSize) m.Registry.MustRegister(m.MobileClientNetworkRequestsTotalSize)
m.MobileClientChannelSwitchDuration = prometheus.NewHistogramVec( m.MobileClientChannelSwitchDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_channel_switch", Name: "mobile_channel_switch",
Help: "Duration of the time taken from when a user clicks on a channel name, and the full channel sreen is loaded (seconds)", Help: "Duration of the time taken from when a user clicks on a channel name, and the full channel sreen is loaded (seconds)",
Buckets: []float64{0.150, 0.200, 0.300, 0.400, 0.450, 0.500, 0.550, 0.600, 0.750, 1, 2, 3}, Buckets: []float64{0.150, 0.200, 0.300, 0.400, 0.450, 0.500, 0.550, 0.600, 0.750, 1, 2, 3},
ConstLabels: additionalLabels, }),
},
[]string{"platform"}, []string{"platform"},
) )
m.Registry.MustRegister(m.MobileClientChannelSwitchDuration) m.Registry.MustRegister(m.MobileClientChannelSwitchDuration)
m.MobileClientTeamSwitchDuration = prometheus.NewHistogramVec( m.MobileClientTeamSwitchDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsMobileApp, Subsystem: MetricsSubsystemClientsMobileApp,
Name: "mobile_team_switch", Name: "mobile_team_switch",
Help: "Duration of the time taken from when a user clicks on a team, and the full categories screen is loaded (seconds)", Help: "Duration of the time taken from when a user clicks on a team, and the full categories screen is loaded (seconds)",
Buckets: []float64{0.150, 0.200, 0.250, 0.300, 0.350, 0.400, 0.500, 0.750, 1, 2, 3}, Buckets: []float64{0.150, 0.200, 0.250, 0.300, 0.350, 0.400, 0.500, 0.750, 1, 2, 3},
ConstLabels: additionalLabels, }),
},
[]string{"platform"}, []string{"platform"},
) )
m.Registry.MustRegister(m.MobileClientTeamSwitchDuration) m.Registry.MustRegister(m.MobileClientTeamSwitchDuration)
@@ -1548,27 +1512,25 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
m.Registry.MustRegister(m.MobileClientSessionMetadataGauge) m.Registry.MustRegister(m.MobileClientSessionMetadataGauge)
m.DesktopClientCPUUsage = prometheus.NewHistogramVec( m.DesktopClientCPUUsage = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsDesktopApp, Subsystem: MetricsSubsystemClientsDesktopApp,
Name: "cpu_usage", Name: "cpu_usage",
Help: "Average CPU usage of a specific process over an interval", Help: "Average CPU usage of a specific process over an interval",
Buckets: []float64{0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 80, 100}, Buckets: []float64{0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 80, 100},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "version", "processName"}, []string{"platform", "version", "processName"},
) )
m.Registry.MustRegister(m.DesktopClientCPUUsage) m.Registry.MustRegister(m.DesktopClientCPUUsage)
m.DesktopClientMemoryUsage = prometheus.NewHistogramVec( m.DesktopClientMemoryUsage = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace, Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemClientsDesktopApp, Subsystem: MetricsSubsystemClientsDesktopApp,
Name: "memory_usage", Name: "memory_usage",
Help: "Memory usage in MB of a specific process", Help: "Memory usage in MB of a specific process",
Buckets: []float64{0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 3000, 5000}, Buckets: []float64{0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 3000, 5000},
ConstLabels: additionalLabels, }),
},
[]string{"platform", "version", "processName"}, []string{"platform", "version", "processName"},
) )
m.Registry.MustRegister(m.DesktopClientMemoryUsage) m.Registry.MustRegister(m.DesktopClientMemoryUsage)