-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add group_measurements_by_instance_label flag to perfmon configuration #8688
Changes from all commits
fa1969b
0e95428
9ee48b5
a64fe5d
f7c07de
62f7e2a
663431d
6bb4187
6e1be87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -336,3 +336,62 @@ func TestWildcardQuery(t *testing.T) { | |||||
|
||||||
t.Log(values) | ||||||
} | ||||||
|
||||||
func TestGroupByInstance(t *testing.T) { | ||||||
config := Config{ | ||||||
CounterConfig: make([]CounterConfig, 3), | ||||||
GroupMeasurements: true, | ||||||
} | ||||||
config.CounterConfig[0].InstanceLabel = "processor.name" | ||||||
config.CounterConfig[0].MeasurementLabel = "processor.time.pct" | ||||||
config.CounterConfig[0].Query = `\Processor Information(_Total)\% Processor Time` | ||||||
config.CounterConfig[0].Format = "float" | ||||||
|
||||||
config.CounterConfig[1].InstanceLabel = "disk.bytes.name" | ||||||
config.CounterConfig[1].MeasurementLabel = "disk.bytes.read.total" | ||||||
config.CounterConfig[1].Query = `\FileSystem Disk Activity(_Total)\FileSystem Bytes Read` | ||||||
config.CounterConfig[1].Format = "float" | ||||||
|
||||||
config.CounterConfig[2].InstanceLabel = "processor.name" | ||||||
config.CounterConfig[2].MeasurementLabel = "processor.time.idle.average.ns" | ||||||
config.CounterConfig[2].Query = `\Processor Information(_Total)\Average Idle Time` | ||||||
config.CounterConfig[2].Format = "float" | ||||||
|
||||||
handle, err := NewPerfmonReader(config) | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
defer handle.query.Close() | ||||||
|
||||||
values, _ := handle.Read() | ||||||
|
||||||
time.Sleep(time.Millisecond * 1000) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice though if this could be done without depending on |
||||||
|
||||||
values, err = handle.Read() | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These ifs can be replaced with
|
||||||
|
||||||
assert.EqualValues(t, 1, len(values)) // Assert all metrics have been grouped into a single event | ||||||
|
||||||
// Test all keys exist in the event | ||||||
pctKey, err := values[0].MetricSetFields.HasKey("processor.time.pct") | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
assert.True(t, pctKey) | ||||||
|
||||||
pctKey, err := values[0].MetricSetFields.HasKey("disk.bytes.read.total") | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
assert.True(t, pctKey) | ||||||
|
||||||
pctKey, err := values[0].MetricSetFields.HasKey("processor.time.idle.average.ns") | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
assert.True(t, pctKey) | ||||||
|
||||||
t.Log(values) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smi9cm I tested this and it's producing more than one event, but the assertion is expecting only one. There are a few compilation errors in the test code so we are going to revert this the merge in #11001. I'd love it if you could reopen the PR after you have looked into the failing test case. Thanks!
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New PR looks good to me, apologies for breaking the build there! Thanks @jsoriano as well. |
||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can define the list of counter configs inline, something like this: