Giter Club home page Giter Club logo

Comments (6)

wake42 avatar wake42 commented on May 20, 2024

I think I still get this bug. I use v0.6.0 together with akkaHttpVersion 10.1.11 , akkaVersion 2.5.29 and am using pathLabeled. For 200 requests I get the label specified by pathLabeled ("/GET me"), but when the api responds with an 401 unauthorised for the same path I get "/me" instead so the metrics is not counted together.

from akka-http-metrics.

RustedBones avatar RustedBones commented on May 20, 2024

This behavior depends on the rejection cause. Unmatched path is the rejection leading to 404.

Unauthorised (401) should probably be handled the same way, since a good practice is to always return 401 even if the path requested does not exists. This avoids leaking the (non)existence of resources to rogue users.

I'm reopening this to extend the behavior with other rejections.

Good catch @wake42 !

from akka-http-metrics.

RustedBones avatar RustedBones commented on May 20, 2024

As a note: pathLabeled won't be used in case of rejection. (I'll double check this) that would explain the wrong grouping in your case.

from akka-http-metrics.

wake42 avatar wake42 commented on May 20, 2024

The api could also respond with 403 forbidden and 500 internal error. I guess all response codes should be caught by this?

from akka-http-metrics.

wake42 avatar wake42 commented on May 20, 2024

If the pathLabeled is not used then how do you group endpoints like /user/123, wouldn't that count every individual user as a separate endpoint for error responses?

from akka-http-metrics.

RustedBones avatar RustedBones commented on May 20, 2024

After double checking the code and running some tests for v1.0.0, this is the actual behavior when pathDimension is enabled:

Let's consider the request GET /user/723abce0-9263-4dad-80a6-4eb7002a86da

For server route

pathLabeled("user" / JavaUUID, "user/:user-id") { userId =>
  complete(StatusCodes.NotFound)
}

Path dimension is user/:user-id

For server route

pathLabeled("user" / JavaUUID, "user/:user-id") { userId =>
  reject
}

Path dimension is unhandled

This difference is due to the way akka-http works with rejections.

In the rejection handler, we have no way to know if the path has been fully matched or not. It's then impossible for the metrics framework to process 'labeling' on the request path. To limit the risk of unbounded metrics generation, path dimension is set to unhandled in this case.

There is however an inconsistency in the metrics framework. For server route:

pathLabeled("user" / JavaUUID, "user/:user-id") { userId =>
  failWith(new Exception("ERROR!"))
}

Path dimension is /user/723abce0-9263-4dad-80a6-4eb7002a86da which is unwanted. Must be replaced by unhandled for consistency

from akka-http-metrics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.