MCPcopy Index your code
hub / github.com/coder/coder / getFieldByLabel

Method getFieldByLabel

coderd/prometheusmetrics/aggregator.go:119–135  ·  view source on GitHub ↗

getFieldByLabel returns the related field value for a given label

(label string)

Source from the content-addressed store, hash-verified

117
118// getFieldByLabel returns the related field value for a given label
119func (am *annotatedMetric) getFieldByLabel(label string) (string, error) {
120 var labelVal string
121 switch label {
122 case agentmetrics.LabelWorkspaceName:
123 labelVal = am.workspaceName
124 case agentmetrics.LabelTemplateName:
125 labelVal = am.templateName
126 case agentmetrics.LabelAgentName:
127 labelVal = am.agentName
128 case agentmetrics.LabelUsername:
129 labelVal = am.username
130 default:
131 return "", xerrors.Errorf("unexpected label: %q", label)
132 }
133
134 return labelVal, nil
135}
136
137func (am *annotatedMetric) shallowCopy() annotatedMetric {
138 stats := &agentproto.Stats_Metric{

Callers 2

aggregateMethod · 0.80
asPrometheusMethod · 0.80

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected