MCPcopy Create free account
hub / github.com/cloudbase/garm / entityEventToMetrics

Function entityEventToMetrics

cmd/garm-cli/cmd/top.go:1007–1048  ·  view source on GitHub ↗
(entityType string, payload json.RawMessage)

Source from the content-addressed store, hash-verified

1005}
1006
1007func entityEventToMetrics(entityType string, payload json.RawMessage) metrics.MetricsEntity {
1008 switch entityType {
1009 case evtRepository:
1010 var r params.Repository
1011 if err := json.Unmarshal(payload, &r); err == nil && r.ID != "" {
1012 name := r.Name
1013 if r.Owner != "" {
1014 name = r.Owner + "/" + r.Name
1015 }
1016 return metrics.MetricsEntity{
1017 ID: r.ID,
1018 Name: name,
1019 Type: evtRepository,
1020 Endpoint: r.Endpoint.Name,
1021 Healthy: r.PoolManagerStatus.IsRunning,
1022 }
1023 }
1024 case evtOrganization:
1025 var o params.Organization
1026 if err := json.Unmarshal(payload, &o); err == nil && o.ID != "" {
1027 return metrics.MetricsEntity{
1028 ID: o.ID,
1029 Name: o.Name,
1030 Type: evtOrganization,
1031 Endpoint: o.Endpoint.Name,
1032 Healthy: o.PoolManagerStatus.IsRunning,
1033 }
1034 }
1035 case entityTypeEnterprise:
1036 var e params.Enterprise
1037 if err := json.Unmarshal(payload, &e); err == nil && e.ID != "" {
1038 return metrics.MetricsEntity{
1039 ID: e.ID,
1040 Name: e.Name,
1041 Type: entityTypeEnterprise,
1042 Endpoint: e.Endpoint.Name,
1043 Healthy: e.PoolManagerStatus.IsRunning,
1044 }
1045 }
1046 }
1047 return metrics.MetricsEntity{}
1048}
1049
1050func truncateLabels(labels []string, maxLen int) string {
1051 result := ""

Callers 1

top.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected