Loki: Improve backend instrumentation of QueryData calls (#73807)
* improve loki `queryData` instrumentation * fix lint * use correct logger in "queryData" * capitalize log messages * distinguish between requests from alerting
This commit is contained in:
@@ -35,14 +35,14 @@ func adjustMetricFrame(frame *data.Frame, query *lokiQuery, setFrameName bool) e
|
||||
fields := frame.Fields
|
||||
// we check if the fields are of correct type
|
||||
if len(fields) != 2 {
|
||||
return fmt.Errorf("invalid fields in metric frame")
|
||||
return fmt.Errorf("invalid field length in metric frame. expected 2, got %d", len(fields))
|
||||
}
|
||||
|
||||
timeField := fields[0]
|
||||
valueField := fields[1]
|
||||
|
||||
if (timeField.Type() != data.FieldTypeTime) || (valueField.Type() != data.FieldTypeFloat64) {
|
||||
return fmt.Errorf("invalid fields in metric frame")
|
||||
return fmt.Errorf("invalid field types in metric frame. expected time and float64, got %s and %s", timeField.Type(), valueField.Type())
|
||||
}
|
||||
|
||||
labels := getFrameLabels(frame)
|
||||
@@ -94,7 +94,7 @@ func adjustLegacyLogsFrame(frame *data.Frame, query *lokiQuery) error {
|
||||
// we check if the fields are of correct type and length
|
||||
fields := frame.Fields
|
||||
if len(fields) != 4 {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("invalid field length in logs frame. expected 4, got %d", len(fields))
|
||||
}
|
||||
|
||||
labelsField := fields[0]
|
||||
@@ -103,11 +103,11 @@ func adjustLegacyLogsFrame(frame *data.Frame, query *lokiQuery) error {
|
||||
stringTimeField := fields[3]
|
||||
|
||||
if (timeField.Type() != data.FieldTypeTime) || (lineField.Type() != data.FieldTypeString) || (labelsField.Type() != data.FieldTypeJSON) || (stringTimeField.Type() != data.FieldTypeString) {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("invalid field types in logs frame. expected time, string, json and string, got %s, %s, %s and %s", timeField.Type(), lineField.Type(), labelsField.Type(), stringTimeField.Type())
|
||||
}
|
||||
|
||||
if (timeField.Len() != lineField.Len()) || (timeField.Len() != labelsField.Len()) || (timeField.Len() != stringTimeField.Len()) {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("indifferent field lengths in logs frame. expected all to be equal, got %d, %d, %d and %d", timeField.Len(), lineField.Len(), labelsField.Len(), stringTimeField.Len())
|
||||
}
|
||||
|
||||
// this returns an error when the length of fields do not match
|
||||
@@ -150,7 +150,7 @@ func adjustDataplaneLogsFrame(frame *data.Frame, query *lokiQuery) error {
|
||||
// we check if the fields are of correct type and length
|
||||
fields := frame.Fields
|
||||
if len(fields) != 4 {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("invalid field length in logs frame. expected 4, got %d", len(fields))
|
||||
}
|
||||
|
||||
labelsField := fields[0]
|
||||
@@ -159,11 +159,11 @@ func adjustDataplaneLogsFrame(frame *data.Frame, query *lokiQuery) error {
|
||||
stringTimeField := fields[3]
|
||||
|
||||
if (timeField.Type() != data.FieldTypeTime) || (lineField.Type() != data.FieldTypeString) || (labelsField.Type() != data.FieldTypeJSON) || (stringTimeField.Type() != data.FieldTypeString) {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("invalid field types in logs frame. expected time, string, json and string, got %s, %s, %s and %s", timeField.Type(), lineField.Type(), labelsField.Type(), stringTimeField.Type())
|
||||
}
|
||||
|
||||
if (timeField.Len() != lineField.Len()) || (timeField.Len() != labelsField.Len()) || (timeField.Len() != stringTimeField.Len()) {
|
||||
return fmt.Errorf("invalid fields in logs frame")
|
||||
return fmt.Errorf("indifferent field lengths in logs frame. expected all to be equal, got %d, %d, %d and %d", timeField.Len(), lineField.Len(), labelsField.Len(), stringTimeField.Len())
|
||||
}
|
||||
|
||||
// this returns an error when the length of fields do not match
|
||||
|
||||
Reference in New Issue
Block a user