Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit a6b6738

Browse files
authored
Merge pull request #86 from percona/PMM-2214
PMM-2214 Fixed default value for ExampleQuery conf
2 parents 54db9fe + 3ed7287 commit a6b6738

File tree

206 files changed

+10120
-2379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+10120
-2379
lines changed

agent/agent_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,12 @@ func (s *AgentTestSuite) TestStatusAfterConnFail(t *C) {
281281
}
282282

283283
func (s *AgentTestSuite) TestStartStopService(t *C) {
284+
exampleQueries := true
284285
// To start a service, first we make a config for the service:
285286
qanConfig := &pc.QAN{
286287
Interval: 60, // seconds
287288
MaxSlowLogSize: 1073741824, // 1 GiB
288-
ExampleQueries: true,
289+
ExampleQueries: &exampleQueries,
289290
WorkerRunTime: 120, // seconds
290291
}
291292

@@ -379,10 +380,11 @@ func (s *AgentTestSuite) TestStartStopService(t *C) {
379380
func (s *AgentTestSuite) TestStartServiceSlow(t *C) {
380381
// This test is like TestStartService but simulates a slow starting service.
381382

383+
exampleQueries := true
382384
qanConfig := &pc.QAN{
383385
Interval: 60, // seconds
384386
MaxSlowLogSize: 1073741824, // 1 GiB
385-
ExampleQueries: true,
387+
ExampleQueries: &exampleQueries,
386388
WorkerRunTime: 120, // seconds
387389
}
388390
qanConfigData, _ := json.Marshal(qanConfig)

bin/percona-qan-agent-installer/installer/installer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ type Installer struct {
4444
hostname string
4545
flags Flags
4646
// --
47-
os *proto.Instance
48-
agent *proto.Instance
49-
debug bool
47+
os *proto.Instance
48+
agent *proto.Instance
49+
debug bool
5050
}
5151

5252
func newUUID() string {

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
volumes:
1313
- ./test/schema/:/docker-entrypoint-initdb.d/:rw
1414
mongo:
15-
image: ${MONGODB_IMAGE:-percona/percona-server-mongodb:3.4}
15+
image: ${MONGODB_IMAGE:-mongo:3.6}
1616
ports:
1717
- ${MONGODB_HOST:-127.0.0.1}:${MONGODB_PORT:-27017}:27017
1818
# MongoDB doesn't enable profiling by default

glide.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qan/analyzer/mongo/manager_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ func TestRealStartTool(t *testing.T) {
7676
require.NoError(t, err)
7777

7878
// Create the qan config.
79+
exampleQueries := true
7980
config := &pc.QAN{
8081
UUID: protoInstance.UUID,
8182
Interval: 1, // 1 second
82-
ExampleQueries: true,
83+
ExampleQueries: &exampleQueries,
8384
}
8485

8586
// Send a StartTool cmd with the qan config to start an analyzer.

qan/analyzer/mongo/mongo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ func (m *MongoAnalyzer) Stop() error {
133133
}
134134

135135
func (m *MongoAnalyzer) GetDefaults(uuid string) map[string]interface{} {
136+
defaultExampleQueries := aggregator.DefaultExampleQueries
136137
// verify config
137138
if m.config.Interval == 0 {
138139
m.config.Interval = aggregator.DefaultInterval
139-
m.config.ExampleQueries = aggregator.DefaultExampleQueries
140+
m.config.ExampleQueries = &defaultExampleQueries
140141
}
141142

142143
return map[string]interface{}{

qan/analyzer/mongo/profiler/aggregator/aggregator.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ const (
2424

2525
// New returns configured *Aggregator
2626
func New(timeStart time.Time, config pc.QAN) *Aggregator {
27+
defaultExampleQueries := DefaultExampleQueries
2728
// verify config
2829
if config.Interval == 0 {
2930
config.Interval = DefaultInterval
30-
config.ExampleQueries = DefaultExampleQueries
31+
config.ExampleQueries = &defaultExampleQueries
3132
}
3233

3334
aggregator := &Aggregator{
@@ -251,9 +252,10 @@ func (self *Aggregator) createResult() *report.Result {
251252
global := event.NewClass("", "", false)
252253
queryStats := queries.CalcQueriesStats(int64(self.config.Interval))
253254
classes := []*event.Class{}
255+
exampleQueries := boolValue(self.config.ExampleQueries)
254256
for _, queryInfo := range queryStats {
255-
class := event.NewClass(queryInfo.ID, queryInfo.Fingerprint, self.config.ExampleQueries)
256-
if self.config.ExampleQueries {
257+
class := event.NewClass(queryInfo.ID, queryInfo.Fingerprint, exampleQueries)
258+
if exampleQueries {
257259
db := ""
258260
s := strings.SplitN(queryInfo.Namespace, ".", 2)
259261
if len(s) == 2 {
@@ -313,3 +315,12 @@ func newEventTimeStatsInMilliseconds(s mongostats.Statistics) *event.TimeStats {
313315
Max: event.Float64(s.Max / 1000),
314316
}
315317
}
318+
319+
// boolValue returns the value of the bool pointer passed in or
320+
// false if the pointer is nil.
321+
func boolValue(v *bool) bool {
322+
if v != nil {
323+
return *v
324+
}
325+
return false
326+
}

qan/analyzer/mongo/profiler/aggregator/aggregator_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ func TestAggregator_Add(t *testing.T) {
3131

3232
{
3333
doc := proto.SystemProfile{
34-
Ts: timeStart,
35-
Millis: 1000,
34+
Ts: timeStart,
35+
Millis: 1000,
3636
DocsExamined: 13,
37-
Nreturned: 42,
37+
Nreturned: 42,
3838
}
3939
err := aggregator.Add(doc)
4040
require.NoError(t, err)
@@ -68,7 +68,7 @@ func TestAggregator_Add(t *testing.T) {
6868
},
6969
},
7070
NumberMetrics: map[string]*event.NumberStats{
71-
"Bytes_sent": {
71+
"Bytes_sent": {
7272
Sum: 0,
7373
Min: event.Uint64(0),
7474
Avg: event.Uint64(0),
@@ -84,7 +84,7 @@ func TestAggregator_Add(t *testing.T) {
8484
Avg: event.Uint64(13),
8585
Max: event.Uint64(13),
8686
},
87-
"Rows_sent": {
87+
"Rows_sent": {
8888
Sum: 42,
8989
Med: event.Uint64(42),
9090
P95: event.Uint64(42),
@@ -113,7 +113,7 @@ func TestAggregator_Add(t *testing.T) {
113113
},
114114
},
115115
NumberMetrics: map[string]*event.NumberStats{
116-
"Bytes_sent": {
116+
"Bytes_sent": {
117117
Sum: 0,
118118
Min: event.Uint64(0),
119119
Avg: event.Uint64(0),
@@ -129,7 +129,7 @@ func TestAggregator_Add(t *testing.T) {
129129
P95: event.Uint64(13),
130130
Max: event.Uint64(13),
131131
},
132-
"Rows_sent": {
132+
"Rows_sent": {
133133
Sum: 42,
134134
Min: event.Uint64(42),
135135
Avg: event.Uint64(42),

qan/analyzer/mongo/profiler/profiler_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ func TestCollectingAndSendingData(t *testing.T) {
3232
dataChan := make(chan interface{})
3333
spool := mock.NewSpooler(dataChan)
3434
// Create the QAN config.
35+
exampleQueries := true
3536
qanConfig := config.QAN{
3637
UUID: "12345678",
3738
Interval: 5, // seconds
38-
ExampleQueries: true,
39+
ExampleQueries: &exampleQueries,
3940
}
4041
plugin := New(dialInfo, dialer, logger, spool, qanConfig)
4142

qan/analyzer/mysql/analyzer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (s *AnalyzerTestSuite) SetUpTest(t *C) {
123123
}
124124
s.worker = qan_worker.NewQanWorker()
125125
// Config needs to be recreated on every test since it can be modified by the test analyzers
126+
exampleQueries := true
126127
s.config = pc.QAN{
127128
UUID: s.mysqlUUID,
128129
CollectFrom: "slowlog",
@@ -135,6 +136,7 @@ func (s *AnalyzerTestSuite) SetUpTest(t *C) {
135136
Stop: []string{
136137
"-- stop",
137138
},
139+
ExampleQueries: &exampleQueries,
138140
}
139141
}
140142

0 commit comments

Comments
 (0)