-
Notifications
You must be signed in to change notification settings - Fork 12
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
Buddhi metric reporter service api #6
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
383dcef
test_plan: consistent path generation between saas and simple profiles
eguzki 3dcd1d2
test_plan_spec: update simple url pattern
eguzki f354219
[buddhi] Makefile: small fix
eguzki 685fc8f
[buddhi] README: metric_reporter doc
eguzki 05f03e6
[buddhi] metric_reporter: service to compute metric counter increment…
eguzki 3aa599e
[buddhi] main, server, test_plan: support for metric_reporter service
eguzki 9abe527
[buddhi] spec/[main_spec, metric_reporter_spec, server_spec]: metric_…
eguzki 8c07473
[buddhi] test_plan_spec: metric_reporter unittests
eguzki e8ea9a4
[buddhi] server_spec_helper: create post request helper method
eguzki 53a5ead
[buddhi] server: read regualar post body instead of multipart/form-data
eguzki 105f51b
[buddhi] server_spec: unittest for reading post body on amp reporter …
eguzki 9a10a45
[buddhi] README: update amp reporter curl example doc
eguzki 8a94d57
[buddhi] README: update amp reporter response body format
eguzki ca06367
[buddhi] metric_reporter: reponse body format update
eguzki 4a287fd
[buddhi] server: reponse body format update
eguzki ec47a71
[buddhi] metric_reporter_spec: response body format update
eguzki b33675e
[buddhi] Makefile: improve clean task
eguzki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'csv' | ||
|
||
module AMP | ||
module Toolkit | ||
module Buddhi | ||
class MetricReporter | ||
attr_reader :test_plan | ||
def initialize(test_plan) | ||
@test_plan = test_plan | ||
end | ||
|
||
def report(data) | ||
CSV.parse(data).map(&method(:parse)).each_with_object({}) do |(service_id, path), hsh| | ||
hsh.merge!(test_plan.metric_report(service_id, path)) { |_, old, new| old + new } | ||
end | ||
end | ||
|
||
private | ||
|
||
def parse(row) | ||
host, full_path = row.map(&:strip) | ||
[host.split('.')[0], URI(full_path).path] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'amp/toolkit/buddhi' | ||
RSpec.describe AMP::Toolkit::Buddhi::MetricReporter do | ||
let(:test_plan) { instance_double(AMP::Toolkit::Buddhi::Simple::TestPlan) } | ||
subject { described_class.new test_plan } | ||
describe 'report' do | ||
it 'should return empty hash when empty input' do | ||
expect(test_plan).not_to receive(:metric_report) | ||
expect(subject.report('')).to eq({}) | ||
end | ||
|
||
it 'should return aggregated results' do | ||
data = %("a533908aa896.benchmark.3sca.net","/1?app_id=4cc&app_key=fcc" | ||
"cb0a88b8da15.benchmark.3sca.net","/1?app_id=74ac&app_key=22" | ||
"a533908aa896.benchmark.3sca.net","/11?app_id=6ba&app_key=ff" | ||
) | ||
expect(test_plan).to receive(:metric_report).with('a533908aa896', '/1').and_return('base' => 1, 'metric_1' => 3) | ||
expect(test_plan).to receive(:metric_report).with('cb0a88b8da15', '/1').and_return('base' => 1, 'metric_2' => 2) | ||
expect(test_plan).to receive(:metric_report).with('a533908aa896', '/11').and_return('base' => 2, 'metric_1' => 3, 'metric_3' => 1) | ||
expect(subject.report(data)).to eq('base' => 4, 'metric_1' => 6, 'metric_3' => 1, 'metric_2' => 2) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A metric ID by itself does not identify a metric. It also needs the service ID.
If I remember correctly, Apisonator will let you create 2 different metrics with the same ID under different services.
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.
Correct,
What format would be appropriate?
or CSV
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.
I'd return JSON in this case because it allows us to represent the
service -> metric
relationships