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

Improve path handling in pushgateway client #220

Merged
merged 5 commits into from
Jun 9, 2021

Commits on Jun 6, 2021

  1. Raise ArgumentError in push.rb if job is nil

    Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
    Sinjo committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    fe1f105 View commit details
    Browse the repository at this point in the history
  2. Convert pushgateway client to keyword arguments

    Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
    Sinjo committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    cc65970 View commit details
    Browse the repository at this point in the history
  3. Raise ArgumentError in push.rb if job is empty

    Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
    Sinjo committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    7fc1064 View commit details
    Browse the repository at this point in the history
  4. Handle empty instance label in push.rb

    Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
    Sinjo committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    dfa5f90 View commit details
    Browse the repository at this point in the history

Commits on Jun 9, 2021

  1. Fix URI escaping of spaces in push.rb

    When `URI.escape` was deprecated, we switched to using `CGI.escape` to
    construct the request path in push.rb.
    
    The problem with that is that it mishandles spaces, encoding them as `+`
    rather than `%20`. This leads to literal `+` characters in metric
    labels, which is a bug.
    
    This commit uses `ERB::Util.url_encode` instead, which gives us the
    behaviour we want.
    
    It's not the part of the standard library I expected to use for this,
    but it's the only one that seems to have the behaviour we want and that
    hasn't disappeared in Ruby 3.0. `WEBrick::HTTPUtils.escape` seems
    similar on the surface, but doesn't encode `&`. Presumably it's intended
    as a best-effort way to encode an entire URL, and has to assume that any
    `&` character is a separator between query params.
    
    Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
    Sinjo committed Jun 9, 2021
    Configuration menu
    Copy the full SHA
    ec5c5aa View commit details
    Browse the repository at this point in the history