Skip to content

Commit

Permalink
Optimize the gcp_logging_log_entry table result or result timing by a…
Browse files Browse the repository at this point in the history
…pplying a timestamp filter Closes #507
  • Loading branch information
ParthaI committed Oct 25, 2023
1 parent 00b60ef commit ce78466
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions gcp/table_gcp_logging_log_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func tableGcpLoggingLogEntry(_ context.Context) *plugin.Table {
{Name: "log_name", Require: plugin.Optional},
{Name: "span_id", Require: plugin.Optional},
{Name: "text_payload", Require: plugin.Optional},
{Name: "receive_timestamp", Require: plugin.Optional},
{Name: "timestamp", Require: plugin.Optional},
{Name: "receive_timestamp", Require: plugin.Optional, Operators: []string{"=", ">", "<", ">=", "<="}},
{Name: "timestamp", Require: plugin.Optional, Operators: []string{"=", ">", "<", ">=", "<="}},
{Name: "trace", Require: plugin.Optional},
{Name: "log_entry_operation_id", Require: plugin.Optional},
{Name: "filter", Require: plugin.Optional, CacheMatch: "exact"},
Expand Down Expand Up @@ -331,9 +331,31 @@ func buildLoggingLogEntryFilterParam(equalQuals plugin.KeyColumnQualMap) string
}
case "timestamp":
if filter == "" {
filter = filterQualItem.PropertyPath + " = \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
switch qual.Operator {
case "=":
filter = filterQualItem.PropertyPath + " = \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case ">":
filter = filterQualItem.PropertyPath + " > \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case "<":
filter = filterQualItem.PropertyPath + " < \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case ">=":
filter = filterQualItem.PropertyPath + " >= \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case "<=":
filter = filterQualItem.PropertyPath + " <= \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
}
} else {
filter = filter + " AND " + filterQualItem.PropertyPath + " = \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
switch qual.Operator {
case "=":
filter = filter + " AND " + filterQualItem.PropertyPath + " = \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case ">":
filter = filter + " AND " + filterQualItem.PropertyPath + " > \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case "<":
filter = filter + " AND " + filterQualItem.PropertyPath + " < \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case ">=":
filter = filter + " AND " + filterQualItem.PropertyPath + " >= \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
case "<=":
filter = filter + " AND " + filterQualItem.PropertyPath + " <= \"" + value.GetTimestampValue().AsTime().Format(time.RFC3339) + "\""
}
}
}
}
Expand Down

0 comments on commit ce78466

Please sign in to comment.