[#77] Add metrics for HTTP endpoint status #78

Merged
dkirillov merged 1 commits from mbiryukova/frostfs-http-gw:feature/add_metrics_for_http_endpoints into master 2023-08-31 12:35:16 +00:00
Collaborator

Closes #77

Signed-off-by: Marina Biryukova m.biryukova@yadro.com

Closes #77 Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
mbiryukova self-assigned this 2023-08-29 12:52:17 +00:00
mbiryukova force-pushed feature/add_metrics_for_http_endpoints from 62a91356b5 to 942873d72b 2023-08-29 13:05:19 +00:00 Compare
mbiryukova requested review from storage-services-committers 2023-08-29 13:12:55 +00:00
mbiryukova requested review from storage-services-developers 2023-08-29 13:12:55 +00:00
dkirillov reviewed 2023-08-30 07:50:58 +00:00
app.go Outdated
@ -233,0 +245,4 @@
m.mu.RLock()
if !m.enabled {
m.mu.RUnlock()
return
Collaborator

Let's create new method

func (m *gateMetrics) Enabled() bool {
	m.mu.RLock()
	defer m.mu.RUnlock()

	return m.enabled
}

then we can write in functions like this simply

func (m *gateMetrics) MarkUnhealthy(endpoint string) {
	if !m.Enabled() {
		return
	}

	m.provider.MarkUnhealthy(endpoint)
}
Let's create new method ```golang func (m *gateMetrics) Enabled() bool { m.mu.RLock() defer m.mu.RUnlock() return m.enabled } ``` then we can write in functions like this simply ```golang func (m *gateMetrics) MarkUnhealthy(endpoint string) { if !m.Enabled() { return } m.provider.MarkUnhealthy(endpoint) } ```
dkirillov marked this conversation as resolved
app.go Outdated
@ -510,3 +534,4 @@
a.log.Warn("failed to add server", append(fields, zap.Error(err))...)
continue
}
a.metrics.MarkHealthy(serverInfo.Address)
Collaborator

Maybe we can also add label to see if tls is enabled ? @alexvanin

Maybe we can also add label to see if tls is enabled ? @alexvanin

This info is available in config and it can't be changed in runtime, so I think we are good without this label for now.

This info is available in config and it can't be changed in runtime, so I think we are good without this label for now.
dkirillov marked this conversation as resolved
metrics/desc.go Outdated
@ -69,0 +73,4 @@
Subsystem: httpServerSubsystem,
Name: healthMetric,
Help: "HTTP Server endpoint health",
VariableLabels: []string{endpointLabel},
Collaborator

Let's keep label names not in constants (as other metrics):

VariableLabels: []string{"endpoint"},
Let's keep label names not in constants (as other metrics): ```golang VariableLabels: []string{"endpoint"}, ```
dkirillov marked this conversation as resolved
@ -16,0 +13,4 @@
namespace = "frostfs_http_gw"
stateSubsystem = "state"
poolSubsystem = "pool"
httpServerSubsystem = "http_server"
Collaborator

Maybe we can rename this to just server? To have the full metric name frostfs_http_gw_server_health rather than frostfs_http_gw_http_server_health?

Maybe we can rename this to just `server`? To have the full metric name `frostfs_http_gw_server_health` rather than `frostfs_http_gw_http_server_health`?
dkirillov marked this conversation as resolved
@ -195,0 +224,4 @@
}
func (m httpServerMetrics) MarkUnhealthy(endpoint string) {
m.endpointHealth.With(prometheus.Labels{endpointLabel: endpoint}).Set(float64(0))
Collaborator

We can just write

m.endpointHealth.WithLabelValues(endpoint).Set(float64(0))
We can just write ```golang m.endpointHealth.WithLabelValues(endpoint).Set(float64(0)) ```
dkirillov marked this conversation as resolved
mbiryukova force-pushed feature/add_metrics_for_http_endpoints from 942873d72b to 5cdc6d87d7 2023-08-31 08:45:21 +00:00 Compare
mbiryukova force-pushed feature/add_metrics_for_http_endpoints from 5cdc6d87d7 to 2dc990ad4b 2023-08-31 08:48:22 +00:00 Compare
alexvanin approved these changes 2023-08-31 11:47:01 +00:00
alexvanin left a comment
Owner

LGTM

LGTM
mbiryukova force-pushed feature/add_metrics_for_http_endpoints from 2dc990ad4b to dbc6804d27 2023-08-31 11:53:39 +00:00 Compare
dkirillov approved these changes 2023-08-31 12:33:26 +00:00
dkirillov merged commit dbc6804d27 into master 2023-08-31 12:35:16 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-services-developers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-http-gw#78
There is no content yet.