MM-61887: Log the userID if a metric exceeds the last histogram bucket (#29448)
We create a custom histogram metric that logs the userID when the observed value is greater or equal to the last bucket value. This allows us to start tracking the slowest users of a system while at the same time not polluting the Prometheus metrics by storing a userID for every observation. https://mattermost.atlassian.net/browse/MM-61887 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
421001c981
Коммит
a6d37fa14c
@@ -201,16 +201,16 @@ type MetricsInterfaceImpl struct {
|
||||
NotificationNotSentCounters *prometheus.CounterVec
|
||||
NotificationUnsupportedCounters *prometheus.CounterVec
|
||||
|
||||
ClientTimeToFirstByte *prometheus.HistogramVec
|
||||
ClientTimeToLastByte *prometheus.HistogramVec
|
||||
ClientTimeToDOMInteractive *prometheus.HistogramVec
|
||||
ClientSplashScreenEnd *prometheus.HistogramVec
|
||||
ClientTimeToFirstByte *HistogramVec
|
||||
ClientTimeToLastByte *HistogramVec
|
||||
ClientTimeToDOMInteractive *HistogramVec
|
||||
ClientSplashScreenEnd *HistogramVec
|
||||
ClientFirstContentfulPaint *prometheus.HistogramVec
|
||||
ClientLargestContentfulPaint *prometheus.HistogramVec
|
||||
ClientInteractionToNextPaint *prometheus.HistogramVec
|
||||
ClientCumulativeLayoutShift *prometheus.HistogramVec
|
||||
ClientLongTasks *prometheus.CounterVec
|
||||
ClientPageLoadDuration *prometheus.HistogramVec
|
||||
ClientPageLoadDuration *HistogramVec
|
||||
ClientChannelSwitchDuration *prometheus.HistogramVec
|
||||
ClientTeamSwitchDuration *prometheus.HistogramVec
|
||||
ClientRHSLoadDuration *prometheus.HistogramVec
|
||||
@@ -1179,7 +1179,7 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
)
|
||||
m.Registry.MustRegister(m.NotificationUnsupportedCounters)
|
||||
|
||||
m.ClientTimeToFirstByte = prometheus.NewHistogramVec(
|
||||
m.ClientTimeToFirstByte = NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemClientsWeb,
|
||||
@@ -1187,10 +1187,11 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
Help: "Duration from when a browser starts to request a page from a server until when it starts to receive data in response (seconds)",
|
||||
},
|
||||
[]string{"platform", "agent"},
|
||||
m.Platform.Log(),
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientTimeToFirstByte)
|
||||
|
||||
m.ClientTimeToLastByte = prometheus.NewHistogramVec(
|
||||
m.ClientTimeToLastByte = NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemClientsWeb,
|
||||
@@ -1198,28 +1199,33 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
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)",
|
||||
},
|
||||
[]string{"platform", "agent"},
|
||||
m.Platform.Log(),
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientTimeToLastByte)
|
||||
|
||||
m.ClientTimeToDOMInteractive = prometheus.NewHistogramVec(
|
||||
m.ClientTimeToDOMInteractive = NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemClientsWeb,
|
||||
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)",
|
||||
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 7.5, 10, 12.5, 15},
|
||||
},
|
||||
[]string{"platform", "agent"},
|
||||
m.Platform.Log(),
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientTimeToDOMInteractive)
|
||||
|
||||
m.ClientSplashScreenEnd = prometheus.NewHistogramVec(
|
||||
m.ClientSplashScreenEnd = NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemClientsWeb,
|
||||
Name: "splash_screen",
|
||||
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},
|
||||
},
|
||||
[]string{"platform", "agent", "page_type"},
|
||||
m.Platform.Log(),
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientSplashScreenEnd)
|
||||
|
||||
@@ -1284,7 +1290,7 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientLongTasks)
|
||||
|
||||
m.ClientPageLoadDuration = prometheus.NewHistogramVec(
|
||||
m.ClientPageLoadDuration = NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemClientsWeb,
|
||||
@@ -1293,6 +1299,7 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 20, 40},
|
||||
},
|
||||
[]string{"platform", "agent"},
|
||||
m.Platform.Log(),
|
||||
)
|
||||
m.Registry.MustRegister(m.ClientPageLoadDuration)
|
||||
|
||||
@@ -1870,20 +1877,20 @@ func (mi *MetricsInterfaceImpl) DecrementHTTPWebSockets(originClient string) {
|
||||
mi.HTTPWebsocketsGauge.With(prometheus.Labels{"origin_client": originClient}).Dec()
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToFirstByte(platform, agent string, elapsed float64) {
|
||||
mi.ClientTimeToFirstByte.With(prometheus.Labels{"platform": platform, "agent": agent}).Observe(elapsed)
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToFirstByte(platform, agent, userID string, elapsed float64) {
|
||||
mi.ClientTimeToFirstByte.With(prometheus.Labels{"platform": platform, "agent": agent}, userID).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToLastByte(platform, agent string, elapsed float64) {
|
||||
mi.ClientTimeToLastByte.With(prometheus.Labels{"platform": platform, "agent": agent}).Observe(elapsed)
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToLastByte(platform, agent, userID string, elapsed float64) {
|
||||
mi.ClientTimeToLastByte.With(prometheus.Labels{"platform": platform, "agent": agent}, userID).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToDomInteractive(platform, agent string, elapsed float64) {
|
||||
mi.ClientTimeToDOMInteractive.With(prometheus.Labels{"platform": platform, "agent": agent}).Observe(elapsed)
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientTimeToDomInteractive(platform, agent, userID string, elapsed float64) {
|
||||
mi.ClientTimeToDOMInteractive.With(prometheus.Labels{"platform": platform, "agent": agent}, userID).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientSplashScreenEnd(platform, agent, pageType string, elapsed float64) {
|
||||
mi.ClientSplashScreenEnd.With(prometheus.Labels{"platform": platform, "agent": agent, "page_type": pageType}).Observe(elapsed)
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientSplashScreenEnd(platform, agent, pageType, userID string, elapsed float64) {
|
||||
mi.ClientSplashScreenEnd.With(prometheus.Labels{"platform": platform, "agent": agent, "page_type": pageType}, userID).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientFirstContentfulPaint(platform, agent string, elapsed float64) {
|
||||
@@ -1906,8 +1913,11 @@ func (mi *MetricsInterfaceImpl) IncrementClientLongTasks(platform, agent string,
|
||||
mi.ClientLongTasks.With(prometheus.Labels{"platform": platform, "agent": agent}).Add(inc)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientPageLoadDuration(platform, agent string, elapsed float64) {
|
||||
mi.ClientPageLoadDuration.With(prometheus.Labels{"platform": platform, "agent": agent}).Observe(elapsed)
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientPageLoadDuration(platform, agent, userID string, elapsed float64) {
|
||||
mi.ClientPageLoadDuration.With(prometheus.Labels{
|
||||
"platform": platform,
|
||||
"agent": agent,
|
||||
}, userID).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveClientChannelSwitchDuration(platform, agent, fresh string, elapsed float64) {
|
||||
@@ -1946,7 +1956,7 @@ func (mi *MetricsInterfaceImpl) ObserveMobileClientTeamSwitchDuration(platform s
|
||||
mi.MobileClientTeamSwitchDuration.With(prometheus.Labels{"platform": platform}).Observe(elapsed)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveMobileClientSessionMetadata(version string, platform string, value float64, notificationDisabled string) {
|
||||
func (mi *MetricsInterfaceImpl) ObserveMobileClientSessionMetadata(version, platform string, value float64, notificationDisabled string) {
|
||||
mi.MobileClientSessionMetadataGauge.With(prometheus.Labels{"version": version, "platform": platform, "notifications_disabled": notificationDisabled}).Set(value)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user