Skip to content
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

Metrics: add the type of 3scale backend call (auth, authrep, report) #919

Merged
merged 5 commits into from
Oct 4, 2018

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Oct 3, 2018

Part of #745

They were in the same 'describe' clause by mistake.
@davidor davidor requested a review from a team as a code owner October 3, 2018 14:01
if valid_endpoint[endpoint] then
threescale_backend_call:inc(1, { endpoint, label_for_status(status) })
else
ngx.log(ngx.WARN, 'Invalid 3scale backend endpoint endpoint when updating metrics')
Copy link
Contributor

@mikz mikz Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really care about this?

edit: I think we don't need to handle this and can just record every endpoint. No code is better than no code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the possibility of having invalid information in Prometheus?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what would be that invalid information? Someone part of code calling the wrong endpoint on the backend. I don't consider that invalid metric. If that call happened, then it should be measured and reported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.


describe('backend client', function()

local test_backend
local options_header_oauth = 'rejection_reason_header=1'
local options_header_no_oauth = 'rejection_reason_header=1&no_body=1'

before_each(function() test_backend = test_backend_client.new() end)
before_each(function()
test_backend = test_backend_client.new()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be not necessary with the changes from 576fa67

it('reports the call with the status', function()
local service = configuration.parse_service({ id = '42' })
local status = 200
stub(test_backend, 'send', function() return { status = status } end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this instead of the test_backend.expect ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in this case, we don't really care about what the backend client receives, we just want it to return a 200 so we can report it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like test_backend.expect { }.respond_with{status = 200} work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll change it 👍

before_each(function()
stub(test_counter, 'inc')
local Prometheus = require('apicast.prometheus')
getmetatable(Prometheus).__call = function(_, type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this dance in tests is so ugly and error-prone, that I think this could be an excellent time to fix this interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I thought the same because it's the second time we need to write something like this.
I was thinking about whether to modify it in this PR or the next one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's address this one separately because it will change many things not directly related to this PR.

end
end

package.loaded['apicast.metrics.3scale_backend_calls'] = nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above. If we have to do this, looks like something is broken in our interface.

@davidor davidor added this to the 3.4 milestone Oct 4, 2018
@davidor davidor merged commit 288f06c into master Oct 4, 2018
@davidor davidor deleted the metrics-backend-calls-type branch October 4, 2018 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants