Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Org Flux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
Org Flux
Commits
7f97b987
Commit
7f97b987
authored
2 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
don't send 404 paths to prometheus since that would allow unbounded label growth
parent
54ee546f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/blog.rs
+12
-6
12 additions, 6 deletions
src/blog.rs
src/main.rs
+1
-3
1 addition, 3 deletions
src/main.rs
with
13 additions
and
9 deletions
src/blog.rs
+
12
−
6
View file @
7f97b987
...
...
@@ -5,8 +5,8 @@ use fnv::FnvHashMap;
use
warp
::
hyper
::
StatusCode
;
use
crate
::{
config
::
Config
,
favicon
::
Favicon
,
image
::
MyImage
,
load
::
load_from_path
,
m
isc
::
Misc
,
path
::
UrlPath
,
post
::
Post
,
resp
::
Response
,
style
::
Style
,
config
::
Config
,
favicon
::
Favicon
,
image
::
MyImage
,
load
::
load_from_path
,
m
etrics
::
HTTP_COUNTER
,
misc
::
Misc
,
path
::
UrlPath
,
post
::
Post
,
resp
::
Response
,
style
::
Style
,
};
pub
struct
Blog
{
...
...
@@ -118,10 +118,16 @@ pub struct RenderedBlog {
impl
RenderedBlog
{
pub
fn
get
(
&
self
,
path
:
&
UrlPath
)
->
(
StatusCode
,
Response
)
{
self
.pages
.get
(
path
)
.map
(|
x
|
(
StatusCode
::
OK
,
x
.clone
()))
.unwrap_or
((
StatusCode
::
NOT_FOUND
,
self
.not_found
.clone
()))
match
self
.pages
.get
(
path
)
{
Some
(
x
)
=>
{
HTTP_COUNTER
.with_label_values
(
&
[
&
path
.to_string
()])
.inc
();
(
StatusCode
::
OK
,
x
.clone
())
}
None
=>
{
HTTP_COUNTER
.with_label_values
(
&
[
"unknown"
])
.inc
();
(
StatusCode
::
NOT_FOUND
,
self
.not_found
.clone
())
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
1
−
3
View file @
7f97b987
use
blog
::{
Blog
,
RenderedBlog
};
use
config
::
Config
;
use
metrics
::{
BUILD_BLOG_FROM_ASSETS
,
HTTP_COUNTER
,
INVALID_EXPIRES_HEADER_VALUE
,
REQUEST_LATENCY
,
RESPONSE_COUNTER
,
BUILD_BLOG_FROM_ASSETS
,
INVALID_EXPIRES_HEADER_VALUE
,
REQUEST_LATENCY
,
RESPONSE_COUNTER
,
};
use
path
::
UrlPath
;
use
std
::
sync
::
Arc
;
...
...
@@ -39,7 +38,6 @@ async fn handle_request(
let
timer
=
REQUEST_LATENCY
.start_timer
();
let
path
=
UrlPath
::
new
(
req
.as_str
());
HTTP_COUNTER
.with_label_values
(
&
[
&
path
.to_string
()])
.inc
();
let
blog
=
blog
.read
()
.await
;
let
(
status
,
content
)
=
blog
.get
(
&
path
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment