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

Add custom query telemetry and response header to OData endpoint #6583

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Oct 19, 2018

Progress on https://github.com/NuGet/Engineering/issues/1798.

This PR does two things:

  1. Add custom metric ODataCustomQuery to OData queries.
    • This has a property IsCustomQuery = True | False | Unknown
  2. Add a response header X-NuGet-CustomQuery: true | false
    • This can be used by APIM

The telemetry will allow us to verify that official clients are not doing custom queries. Note that "custom query" does not necessarily mean executed without the database. I chose to make this distinction for the GetUpdates OData function. This can be called by official client (2.x for many cases, 3.x+ for nuget.exe update -self) so it should not be throttled like custom OData queries.

Another case: when search hijack throws an exception, some (maybe all?) codepaths fall back to DB. This should probably not be throttled...

@joelverhagen
Copy link
Member Author

Another case: when search hijack throws an exception, some (maybe all?) codepaths fall back to DB. This should probably not be throttled...

I've solved this case with an "Unknown" state. This is registered as "Unknown" in telemetry and no X-NuGet-CustomQuery header in the response body.

Copy link
Contributor

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

👍 Nice test additions

@joelverhagen
Copy link
Member Author

Tried this out on DEV environment.

<rate-limit-by-key
    calls="10"
    renewal-period="60"
    counter-key="@(context.Request.IpAddress)"
    increment-condition="@(context.Response.Headers.GetValueOrDefault("X-NuGet-CustomQuery", "false") == "true")" />

Works great!

@joelverhagen
Copy link
Member Author

I would like to ship this to PROD without the throttle rule and observe the telemetry. Any objections?

@joelverhagen joelverhagen merged commit dc86fe8 into dev Oct 30, 2018
@joelverhagen joelverhagen deleted the jver-nohijackheader branch March 20, 2019 18:51
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.

4 participants