mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Niladic `ToString()
to idiomatic
String()
`.
This commit is contained in:
parent
44d6ad9eee
commit
a70ee43ad3
|
@ -66,7 +66,7 @@ func exprTypeToString(exprType ExprType) string {
|
||||||
return exprTypeMap[exprType]
|
return exprTypeMap[exprType]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vector Vector) ToString() string {
|
func (vector Vector) String() string {
|
||||||
metricStrings := []string{}
|
metricStrings := []string{}
|
||||||
for _, sample := range vector {
|
for _, sample := range vector {
|
||||||
metricName, ok := sample.Metric["name"]
|
metricName, ok := sample.Metric["name"]
|
||||||
|
@ -91,7 +91,7 @@ func (vector Vector) ToString() string {
|
||||||
return strings.Join(metricStrings, "\n")
|
return strings.Join(metricStrings, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix Matrix) ToString() string {
|
func (matrix Matrix) String() string {
|
||||||
metricStrings := []string{}
|
metricStrings := []string{}
|
||||||
for _, sampleSet := range matrix {
|
for _, sampleSet := range matrix {
|
||||||
metricName, ok := sampleSet.Metric["name"]
|
metricName, ok := sampleSet.Metric["name"]
|
||||||
|
@ -165,7 +165,7 @@ func EvalToString(node Node, timestamp *time.Time, format OutputFormat) string {
|
||||||
vector := node.(VectorNode).Eval(timestamp)
|
vector := node.(VectorNode).Eval(timestamp)
|
||||||
switch format {
|
switch format {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
return vector.ToString()
|
return vector.String()
|
||||||
case JSON:
|
case JSON:
|
||||||
return TypedValueToJSON(vector, "vector")
|
return TypedValueToJSON(vector, "vector")
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ func EvalToString(node Node, timestamp *time.Time, format OutputFormat) string {
|
||||||
matrix := node.(MatrixNode).Eval(timestamp)
|
matrix := node.(MatrixNode).Eval(timestamp)
|
||||||
switch format {
|
switch format {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
return matrix.ToString()
|
return matrix.String()
|
||||||
case JSON:
|
case JSON:
|
||||||
return TypedValueToJSON(matrix, "matrix")
|
return TypedValueToJSON(matrix, "matrix")
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func EvalToString(node Node, timestamp *time.Time, format OutputFormat) string {
|
||||||
panic("Switch didn't cover all node types")
|
panic("Switch didn't cover all node types")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *VectorLiteral) ToString() string {
|
func (node *VectorLiteral) String() string {
|
||||||
metricName, ok := node.labels["name"]
|
metricName, ok := node.labels["name"]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("Tried to print vector without metric name")
|
panic("Tried to print vector without metric name")
|
||||||
|
@ -204,8 +204,8 @@ func (node *VectorLiteral) ToString() string {
|
||||||
return fmt.Sprintf("%v{%v}", metricName, strings.Join(labelStrings, ","))
|
return fmt.Sprintf("%v{%v}", metricName, strings.Join(labelStrings, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *MatrixLiteral) ToString() string {
|
func (node *MatrixLiteral) String() string {
|
||||||
vectorString := (&VectorLiteral{labels: node.labels}).ToString()
|
vectorString := (&VectorLiteral{labels: node.labels}).String()
|
||||||
intervalString := fmt.Sprintf("['%v']", utility.DurationToString(node.interval))
|
intervalString := fmt.Sprintf("['%v']", utility.DurationToString(node.interval))
|
||||||
return vectorString + intervalString
|
return vectorString + intervalString
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ func (node *ScalarArithExpr) NodeTreeToDotGraph() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *VectorLiteral) NodeTreeToDotGraph() string {
|
func (node *VectorLiteral) NodeTreeToDotGraph() string {
|
||||||
return fmt.Sprintf("%#p[label=\"%v\"];\n", node, node.ToString())
|
return fmt.Sprintf("%#p[label=\"%v\"];\n", node, node.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *VectorFunctionCall) NodeTreeToDotGraph() string {
|
func (node *VectorFunctionCall) NodeTreeToDotGraph() string {
|
||||||
|
@ -275,11 +275,11 @@ func (node *VectorArithExpr) NodeTreeToDotGraph() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *MatrixLiteral) NodeTreeToDotGraph() string {
|
func (node *MatrixLiteral) NodeTreeToDotGraph() string {
|
||||||
return fmt.Sprintf("%#p[label=\"%v\"];\n", node, node.ToString())
|
return fmt.Sprintf("%#p[label=\"%v\"];\n", node, node.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *StringLiteral) NodeTreeToDotGraph() string {
|
func (node *StringLiteral) NodeTreeToDotGraph() string {
|
||||||
return fmt.Sprintf("%#p[label=\"'%v'\"];\n", node.str)
|
return fmt.Sprintf("%#p[label=\"'%v'\"];\n", node.str, node.str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *StringFunctionCall) NodeTreeToDotGraph() string {
|
func (node *StringFunctionCall) NodeTreeToDotGraph() string {
|
||||||
|
|
Loading…
Reference in a new issue