Skip to content

Commit

Permalink
rename FilterTag to QueryLogFilterTag for consistency and clarity
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
  • Loading branch information
demmer committed May 31, 2019
1 parent a0f2d1f commit 1bfa92d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions go/streamlog/streamlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var (
// QueryLogFormat controls the format of the query log (either text or json)
QueryLogFormat = flag.String("querylog-format", "text", "format for query logs (\"text\" or \"json\")")

// FilterTag contains an optional string that must be present in the query for it to be logged
FilterTag = flag.String("querylog-filter-tag", "", "string that must be present in the query for it to be logged")
// QueryLogFilterTag contains an optional string that must be present in the query for it to be logged
QueryLogFilterTag = flag.String("querylog-filter-tag", "", "string that must be present in the query for it to be logged")

sendCount = stats.NewCountersWithSingleLabel("StreamlogSend", "stream log send count", "logger_names")
deliveredCount = stats.NewCountersWithMultiLabels(
Expand Down Expand Up @@ -209,8 +209,8 @@ func GetFormatter(logger *StreamLogger) LogFormatter {
// ShouldEmitLog returns whether the log with the given SQL query
// should be emitted or filtered
func ShouldEmitLog(sql string) bool {
if *FilterTag == "" {
if *QueryLogFilterTag == "" {
return true
}
return strings.Contains(sql, *FilterTag)
return strings.Contains(sql, *QueryLogFilterTag)
}
6 changes: 3 additions & 3 deletions go/vt/vtgate/logstats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestLogStatsFormat(t *testing.T) {
}

func TestLogStatsFilter(t *testing.T) {
defer func() { *streamlog.FilterTag = "" }()
defer func() { *streamlog.QueryLogFilterTag = "" }()

logStats := NewLogStats(context.Background(), "test", "sql1 /* LOG_THIS_QUERY */", map[string]*querypb.BindVariable{"intVal": sqltypes.Int64BindVariable(1)})
logStats.StartTime = time.Date(2017, time.January, 1, 1, 2, 3, 0, time.UTC)
Expand All @@ -140,14 +140,14 @@ func TestLogStatsFilter(t *testing.T) {
t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want)
}

*streamlog.FilterTag = "LOG_THIS_QUERY"
*streamlog.QueryLogFilterTag = "LOG_THIS_QUERY"
got = testFormat(logStats, url.Values(params))
want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\tmap[intVal:type:INT64 value:\"1\" ]\t0\t0\t\"\"\t\n"
if got != want {
t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want)
}

*streamlog.FilterTag = "NOT_THIS_QUERY"
*streamlog.QueryLogFilterTag = "NOT_THIS_QUERY"
got = testFormat(logStats, url.Values(params))
want = ""
if got != want {
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/querylogz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func TestQuerylogzHandlerFormatting(t *testing.T) {
checkQuerylogzHasStats(t, slowQueryPattern, logStats, body)

// ensure querylogz is not affected by the filter tag
*streamlog.FilterTag = "XXX_SKIP_ME"
defer func() { *streamlog.FilterTag = "" }()
*streamlog.QueryLogFilterTag = "XXX_SKIP_ME"
defer func() { *streamlog.QueryLogFilterTag = "" }()
ch = make(chan interface{}, 1)
ch <- logStats
querylogzHandler(ch, response, req)
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/querylogz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func TestQuerylogzHandler(t *testing.T) {
checkQuerylogzHasStats(t, slowQueryPattern, logStats, body)

// ensure querylogz is not affected by the filter tag
*streamlog.FilterTag = "XXX_SKIP_ME"
defer func() { *streamlog.FilterTag = "" }()
*streamlog.QueryLogFilterTag = "XXX_SKIP_ME"
defer func() { *streamlog.QueryLogFilterTag = "" }()
ch = make(chan interface{}, 1)
ch <- logStats
querylogzHandler(ch, response, req)
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/tabletenv/logstats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestLogStatsFormat(t *testing.T) {
}

func TestLogStatsFilter(t *testing.T) {
defer func() { *streamlog.FilterTag = "" }()
defer func() { *streamlog.QueryLogFilterTag = "" }()

logStats := NewLogStats(context.Background(), "test")
logStats.StartTime = time.Date(2017, time.January, 1, 1, 2, 3, 0, time.UTC)
Expand All @@ -168,14 +168,14 @@ func TestLogStatsFilter(t *testing.T) {
t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want)
}

*streamlog.FilterTag = "LOG_THIS_QUERY"
*streamlog.QueryLogFilterTag = "LOG_THIS_QUERY"
got = testFormat(logStats, url.Values(params))
want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql /* LOG_THIS_QUERY */\"\tmap[intVal:type:INT64 value:\"1\" ]\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t1\t\"\"\t\n"
if got != want {
t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want)
}

*streamlog.FilterTag = "NOT_THIS_QUERY"
*streamlog.QueryLogFilterTag = "NOT_THIS_QUERY"
got = testFormat(logStats, url.Values(params))
want = ""
if got != want {
Expand Down

0 comments on commit 1bfa92d

Please sign in to comment.