Compare commits

...

9 Commits

Author SHA1 Message Date
Nityananda Gohain
f43292c10b Merge branch 'develop' into issue_2705 2024-07-21 21:16:25 +05:30
Nityananda Gohain
ea51320e4f Merge branch 'develop' into issue_2705 2024-07-08 10:37:45 +05:30
Nityananda Gohain
436009ec20 Merge branch 'develop' into issue_2705 2024-07-04 14:54:01 +05:30
nityanandagohain
785a872ee0 fix: correct tag type for scope 2024-07-04 14:51:32 +05:30
nityanandagohain
9ab3a03bfe Merge remote-tracking branch 'origin/develop' into issue_2705 2024-07-03 21:41:11 +05:30
nityanandagohain
8a3688b74d feat: rename instrumentation_scope to scope 2024-07-03 21:40:44 +05:30
Nityananda Gohain
5a686f3be1 Merge branch 'develop' into issue_2705 2024-07-01 12:38:38 +05:30
nityanandagohain
da31b2f7df feat: support for attribute suggestion and querying 2024-06-19 16:33:25 +05:30
nityanandagohain
a25189eca7 feat: qb changes to support instrumentation scope 2024-06-19 14:22:11 +05:30
5 changed files with 110 additions and 33 deletions

View File

@@ -63,7 +63,7 @@ func EnrichmentRequired(params *v3.QueryRangeParamsV3) bool {
func isEnriched(field v3.AttributeKey) bool { func isEnriched(field v3.AttributeKey) bool {
// if it is timestamp/id dont check // if it is timestamp/id dont check
if field.Key == "timestamp" || field.Key == "id" || field.Key == constants.SigNozOrderByValue { if field.Key == "timestamp" || field.Key == "id" || field.Key == constants.SigNozOrderByValue || field.Type == v3.AttributeKeyTypeInstrumentationScope {
return true return true
} }

View File

@@ -55,6 +55,9 @@ func getClickhouseLogsColumnType(columnType v3.AttributeKeyType) string {
if columnType == v3.AttributeKeyTypeTag { if columnType == v3.AttributeKeyTypeTag {
return "attributes" return "attributes"
} }
if columnType == v3.AttributeKeyTypeInstrumentationScope {
return "scope"
}
return "resources" return "resources"
} }

View File

@@ -53,6 +53,11 @@ var testGetClickhouseColumnNameData = []struct {
AttributeKey: v3.AttributeKey{Key: "test-attr", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, IsColumn: true}, AttributeKey: v3.AttributeKey{Key: "test-attr", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, IsColumn: true},
ExpectedColumnName: "`attribute_string_test-attr`", ExpectedColumnName: "`attribute_string_test-attr`",
}, },
{
Name: "instrumentation scope attribute",
AttributeKey: v3.AttributeKey{Key: "version", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeInstrumentationScope, IsColumn: false},
ExpectedColumnName: "scope_string_value[indexOf(scope_string_key, 'version')]",
},
} }
func TestGetClickhouseColumnName(t *testing.T) { func TestGetClickhouseColumnName(t *testing.T) {
@@ -130,6 +135,13 @@ var timeSeriesFilterQueryData = []struct {
}}, }},
ExpectedFilter: "attributes_string_value[indexOf(attributes_string_key, 'user_name')] = 'john' AND resources_string_value[indexOf(resources_string_key, 'k8s_namespace')] != 'my_service'", ExpectedFilter: "attributes_string_value[indexOf(attributes_string_key, 'user_name')] = 'john' AND resources_string_value[indexOf(resources_string_key, 'k8s_namespace')] != 'my_service'",
}, },
{
Name: "Test instrumentation scope attribute",
FilterSet: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{
{Key: v3.AttributeKey{Key: "version", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeInstrumentationScope}, Value: "v1", Operator: "="},
}},
ExpectedFilter: "scope_string_value[indexOf(scope_string_key, 'version')] = 'v1'",
},
{ {
Name: "Test materialized column", Name: "Test materialized column",
FilterSet: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{ FilterSet: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{
@@ -734,10 +746,11 @@ var testBuildLogsQueryData = []struct {
Expression: "A", Expression: "A",
Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}}, Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}},
}, },
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," + ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," +
"CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," + "CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," +
"CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," + "CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," +
"CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string " + "CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, " +
"CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) order by timestamp DESC", "from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) order by timestamp DESC",
}, },
{ {
@@ -753,10 +766,11 @@ var testBuildLogsQueryData = []struct {
Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}}, Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}},
OrderBy: []v3.OrderBy{{ColumnName: "method", DataType: v3.AttributeKeyDataTypeString, Order: "ASC", IsColumn: true}}, OrderBy: []v3.OrderBy{{ColumnName: "method", DataType: v3.AttributeKeyDataTypeString, Order: "ASC", IsColumn: true}},
}, },
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," + ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," +
"CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," + "CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," +
"CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," + "CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," +
"CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string " + "CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, " +
"CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) order by `method` ASC", "from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) order by `method` ASC",
}, },
{ {
@@ -773,12 +787,35 @@ var testBuildLogsQueryData = []struct {
{Key: v3.AttributeKey{Key: "severity_number", DataType: v3.AttributeKeyDataTypeInt64, IsColumn: true}, Operator: "!=", Value: 0}, {Key: v3.AttributeKey{Key: "severity_number", DataType: v3.AttributeKeyDataTypeInt64, IsColumn: true}, Operator: "!=", Value: 0},
}}, }},
}, },
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," + ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," +
"CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," + "CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," +
"CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," + "CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," +
"CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string " + "CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, " +
"CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND severity_number != 0 order by timestamp DESC", "from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND severity_number != 0 order by timestamp DESC",
}, },
{
Name: "Test Noop with scope filter",
PanelType: v3.PanelTypeList,
Start: 1680066360726210000,
End: 1680066458000000000,
BuilderQuery: &v3.BuilderQuery{
SelectColumns: []v3.AttributeKey{},
QueryName: "A",
AggregateOperator: v3.AggregateOperatorNoOp,
Expression: "A",
Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{
{Key: v3.AttributeKey{Key: "scope_name", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeUnspecified, IsColumn: true}, Operator: "=", Value: "app"},
{Key: v3.AttributeKey{Key: "scope_version", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeUnspecified, IsColumn: true}, Operator: "=", Value: "version"},
}},
},
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," +
"CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," +
"CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," +
"CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, " +
"CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND scope_name = 'app' AND scope_version = 'version' order by timestamp DESC",
},
{ {
Name: "Test aggregate with having clause", Name: "Test aggregate with having clause",
PanelType: v3.PanelTypeGraph, PanelType: v3.PanelTypeGraph,
@@ -1308,9 +1345,13 @@ var testPrepLogsQueryData = []struct {
}, },
}, },
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where attributes_string_value[indexOf(attributes_string_key, 'method')] = 'GET' AND ", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body," +
Options: Options{IsLivetailQuery: true}, "CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') " +
"as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where attributes_string_value[indexOf(attributes_string_key, 'method')] = 'GET' AND ",
Options: Options{IsLivetailQuery: true},
}, },
{ {
Name: "Live Tail Query with contains", Name: "Live Tail Query with contains",
@@ -1327,9 +1368,12 @@ var testPrepLogsQueryData = []struct {
}, },
}, },
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where attributes_string_value[indexOf(attributes_string_key, 'method')] ILIKE '%GET%' AND ", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
Options: Options{IsLivetailQuery: true}, "as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where attributes_string_value[indexOf(attributes_string_key, 'method')] ILIKE '%GET%' AND ",
Options: Options{IsLivetailQuery: true},
}, },
{ {
Name: "Live Tail Query W/O filter", Name: "Live Tail Query W/O filter",
@@ -1343,9 +1387,12 @@ var testPrepLogsQueryData = []struct {
Expression: "A", Expression: "A",
Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}}, Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}},
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where ", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
Options: Options{IsLivetailQuery: true}, "as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where ",
Options: Options{IsLivetailQuery: true},
}, },
{ {
Name: "Table query w/o limit", Name: "Table query w/o limit",
@@ -1482,8 +1529,11 @@ var testPrepLogsQueryLimitOffsetData = []struct {
Offset: 0, Offset: 0,
PageSize: 5, PageSize: 5,
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) order by `timestamp` desc LIMIT 1", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
"as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) order by `timestamp` desc LIMIT 1",
}, },
{ {
Name: "Test limit greater than pageSize - order by ts", Name: "Test limit greater than pageSize - order by ts",
@@ -1503,8 +1553,11 @@ var testPrepLogsQueryLimitOffsetData = []struct {
Offset: 10, Offset: 10,
PageSize: 10, PageSize: 10,
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) AND id < '2TNh4vp2TpiWyLt3SzuadLJF2s4' order by `timestamp` desc LIMIT 10", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
"as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) AND id < '2TNh4vp2TpiWyLt3SzuadLJF2s4' order by `timestamp` desc LIMIT 10",
}, },
{ {
Name: "Test limit less than pageSize - order by custom", Name: "Test limit less than pageSize - order by custom",
@@ -1522,8 +1575,11 @@ var testPrepLogsQueryLimitOffsetData = []struct {
Offset: 0, Offset: 0,
PageSize: 5, PageSize: 5,
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) order by attributes_string_value[indexOf(attributes_string_key, 'method')] desc LIMIT 1 OFFSET 0", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
"as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) order by attributes_string_value[indexOf(attributes_string_key, 'method')] desc LIMIT 1 OFFSET 0",
}, },
{ {
Name: "Test limit greater than pageSize - order by custom", Name: "Test limit greater than pageSize - order by custom",
@@ -1543,8 +1599,11 @@ var testPrepLogsQueryLimitOffsetData = []struct {
Offset: 50, Offset: 50,
PageSize: 50, PageSize: 50,
}, },
TableName: "logs", TableName: "logs",
ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) AND id < '2TNh4vp2TpiWyLt3SzuadLJF2s4' order by attributes_string_value[indexOf(attributes_string_key, 'method')] desc LIMIT 50 OFFSET 50", ExpectedQuery: "SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body,CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') " +
"as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64,CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64,CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') " +
"as attributes_bool,CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope " +
"from signoz_logs.distributed_logs where (timestamp >= 1680066360726000000 AND timestamp <= 1680066458000000000) AND id < '2TNh4vp2TpiWyLt3SzuadLJF2s4' order by attributes_string_value[indexOf(attributes_string_key, 'method')] desc LIMIT 50 OFFSET 50",
}, },
} }

View File

@@ -296,12 +296,13 @@ var StaticSelectedLogFields = []model.LogField{
const ( const (
LogsSQLSelect = "SELECT " + LogsSQLSelect = "SELECT " +
"timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, body," + "timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body," +
"CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," + "CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string," +
"CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64," + "CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64," +
"CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," + "CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64," +
"CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," + "CAST((attributes_bool_key, attributes_bool_value), 'Map(String, Bool)') as attributes_bool," +
"CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string " "CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string, " +
"CAST((scope_string_key, scope_string_value), 'Map(String, String)') as scope "
TracesExplorerViewSQLSelectWithSubQuery = "WITH subQuery AS (SELECT distinct on (traceID) traceID, durationNano, " + TracesExplorerViewSQLSelectWithSubQuery = "WITH subQuery AS (SELECT distinct on (traceID) traceID, durationNano, " +
"serviceName, name FROM %s.%s WHERE parentSpanID = '' AND %s %s ORDER BY durationNano DESC " "serviceName, name FROM %s.%s WHERE parentSpanID = '' AND %s %s ORDER BY durationNano DESC "
TracesExplorerViewSQLSelectQuery = "SELECT subQuery.serviceName, subQuery.name, count() AS " + TracesExplorerViewSQLSelectQuery = "SELECT subQuery.serviceName, subQuery.name, count() AS " +
@@ -366,6 +367,18 @@ var StaticFieldsLogsV3 = map[string]v3.AttributeKey{
Type: v3.AttributeKeyTypeUnspecified, Type: v3.AttributeKeyTypeUnspecified,
IsColumn: true, IsColumn: true,
}, },
"scope_name": {
Key: "scope_name",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeUnspecified,
IsColumn: true,
},
"scope_version": {
Key: "scope_version",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeUnspecified,
IsColumn: true,
},
} }
const SigNozOrderByValue = "#SIGNOZ_VALUE" const SigNozOrderByValue = "#SIGNOZ_VALUE"

View File

@@ -229,13 +229,14 @@ type AggregateAttributeRequest struct {
type TagType string type TagType string
const ( const (
TagTypeTag TagType = "tag" TagTypeTag TagType = "tag"
TagTypeResource TagType = "resource" TagTypeResource TagType = "resource"
TagTypeInstrumentationScope TagType = "scope"
) )
func (q TagType) Validate() error { func (q TagType) Validate() error {
switch q { switch q {
case TagTypeTag, TagTypeResource: case TagTypeTag, TagTypeResource, TagTypeInstrumentationScope:
return nil return nil
default: default:
return fmt.Errorf("invalid tag type: %s", q) return fmt.Errorf("invalid tag type: %s", q)
@@ -300,9 +301,10 @@ type FilterAttributeKeyResponse struct {
type AttributeKeyType string type AttributeKeyType string
const ( const (
AttributeKeyTypeUnspecified AttributeKeyType = "" AttributeKeyTypeUnspecified AttributeKeyType = ""
AttributeKeyTypeTag AttributeKeyType = "tag" AttributeKeyTypeTag AttributeKeyType = "tag"
AttributeKeyTypeResource AttributeKeyType = "resource" AttributeKeyTypeResource AttributeKeyType = "resource"
AttributeKeyTypeInstrumentationScope AttributeKeyType = "scope"
) )
type AttributeKey struct { type AttributeKey struct {
@@ -327,7 +329,7 @@ func (a AttributeKey) Validate() error {
if a.IsColumn { if a.IsColumn {
switch a.Type { switch a.Type {
case AttributeKeyTypeResource, AttributeKeyTypeTag, AttributeKeyTypeUnspecified: case AttributeKeyTypeResource, AttributeKeyTypeTag, AttributeKeyTypeUnspecified, AttributeKeyTypeInstrumentationScope:
break break
default: default:
return fmt.Errorf("invalid attribute type: %s", a.Type) return fmt.Errorf("invalid attribute type: %s", a.Type)