Skip to content

Commit

Permalink
updated dashboard build and added metrics demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ndortega committed Jan 11, 2024
1 parent 9f6e535 commit 385cdbc
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 14 deletions.
4 changes: 2 additions & 2 deletions data/dashboard/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/css/main.1e415bb7.css",
"main.js": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/js/main.ab64643f.js",
"main.js": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/js/main.065fe6b4.js",
"static/media/signInImage.png": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/media/signInImage.eeb0c777f5867442d1a2.png",
"static/media/BgSignUp.png": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/media/BgSignUp.2dea4acf779bbfe49e5c.png",
"static/media/roboto-all-500-normal.woff": "/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/media/roboto-all-500-normal.0ab669b7a0d19b178f57.woff",
Expand Down Expand Up @@ -33,6 +33,6 @@
},
"entrypoints": [
"static/css/main.1e415bb7.css",
"static/js/main.ab64643f.js"
"static/js/main.065fe6b4.js"
]
}
2 changes: 1 addition & 1 deletion data/dashboard/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/manifest.json"/><link rel="shortcut icon" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/favicon.ico"/><link rel="apple-touch-icon" sizes="76x76" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/apple-icon.png"/><title>Oxygen Metrics</title><script defer="defer" src="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/js/main.ab64643f.js"></script><link href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/css/main.1e415bb7.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/manifest.json"/><link rel="shortcut icon" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/favicon.ico"/><link rel="apple-touch-icon" sizes="76x76" href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/apple-icon.png"/><title>Oxygen Metrics</title><script defer="defer" src="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/js/main.065fe6b4.js"></script><link href="/df9a0d86-3283-4920-82dc-4555fc0d1d8b/static/css/main.1e415bb7.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions demo/metricsdemo.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module CronManagementDemo

include("../src/Oxygen.jl")
using .Oxygen
using HTTP
using Dates

get("/data") do
Dict("msg" => "hello")
end

get("/random/sm") do
sleep(rand(0.1:0.30))
"small random"
end

get("/random/md") do
sleep(rand(0.30:0.70))
"small random"
end

get("/random/lg") do
sleep(rand(0.30:1))
"random"
end

serve()

end
32 changes: 26 additions & 6 deletions demo/util/api_tester.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,32 @@ urls = [
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/long",
# "http://localhost:8080/error",
# "http://localhost:8080/fake",
"http://localhost:8080/hello",
"http://localhost:8080/hello",
"http://localhost:8080/hello",
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/data",
"http://localhost:8080/data",

"http://localhost:8080/random/lg",
"http://localhost:8080/random/lg",
"http://localhost:8080/random/lg",

"http://localhost:8080/random/md",
"http://localhost:8080/random/md",
"http://localhost:8080/random/md",
"http://localhost:8080/random/md",

"http://localhost:8080/random/sm",
"http://localhost:8080/random/sm",
"http://localhost:8080/random/sm",
"http://localhost:8080/random/sm",
"http://localhost:8080/random/sm",
"http://localhost:8080/random/sm",

"http://localhost:8080/fake",
"http://localhost:8080/error",
"http://localhost:8080/nothing",
]
random_requester(urls, (1, 8)) # Randomly hit endpoints between 1 and 5 requests per second

Expand Down
6 changes: 3 additions & 3 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function MetricsMiddleware(catch_errors::Bool)
# Handle the request
response = handler(req)
# Log response time
response_time = time() - start_time
response_time = (time() - start_time) * 1000
if response.status == 200
push_history(HTTPTransaction(
string(req.context[:ip]),
Expand All @@ -428,7 +428,7 @@ function MetricsMiddleware(catch_errors::Bool)
# Return the response
return response
catch e
response_time = time() - start_time
response_time = (time() - start_time) * 1000

Check warning on line 431 in src/core.jl

View check run for this annotation

Codecov / codecov/patch

src/core.jl#L431

Added line #L431 was not covered by tests

# Log the error
push_history(HTTPTransaction(

Check warning on line 434 in src/core.jl

View check run for this annotation

Codecov / codecov/patch

src/core.jl#L434

Added line #L434 was not covered by tests
Expand Down Expand Up @@ -681,7 +681,7 @@ end

# add the swagger and swagger/schema routes
function setupswagger()

if isdocsenabled()

@get "$docspath" function()
Expand Down

0 comments on commit 385cdbc

Please sign in to comment.