getFieldByLabel returns the related field value for a given label
(label string)
| 117 | |
| 118 | // getFieldByLabel returns the related field value for a given label |
| 119 | func (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 | |
| 137 | func (am *annotatedMetric) shallowCopy() annotatedMetric { |
| 138 | stats := &agentproto.Stats_Metric{ |
no test coverage detected