-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(SQS): prometheus metrics for cache hits and misses * lint (cherry picked from commit f6777d6) Co-authored-by: Roman <[email protected]>
- Loading branch information
1 parent
3064d9e
commit 7ced101
Showing
3 changed files
with
98 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package domain | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
"github.com/labstack/echo" | ||
) | ||
|
||
// RequestPathKeyType is a custom type for request path key. | ||
type RequestPathKeyType string | ||
|
||
const ( | ||
// RequestPathCtxKey is the key used to store the request path in the request context | ||
RequestPathCtxKey RequestPathKeyType = "request_path" | ||
) | ||
|
||
// ParseURLPath parses the URL path from the echo context | ||
func ParseURLPath(c echo.Context) (string, error) { | ||
parsedURL, err := url.Parse(c.Request().RequestURI) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return parsedURL.Path, nil | ||
} | ||
|
||
// GetURLPathFromContext returns the request path from the context | ||
func GetURLPathFromContext(ctx context.Context) (string, error) { | ||
// Get request path for metrics | ||
requestPath, ok := ctx.Value(RequestPathCtxKey).(string) | ||
if !ok || (ok && len(requestPath) == 0) { | ||
requestPath = "unknown" | ||
} | ||
return requestPath, nil | ||
} |
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