Skip to content

refactor: add metrics endpoint (DEV-1555) - #2331

Merged
subotic merged 9 commits into
mainfrom
wip/DEV-1555-add-prometheus-endpoint
Dec 14, 2022
Merged

subotic merged 9 commits into
mainfrom
wip/DEV-1555-add-prometheus-endpoint

Conversation

@subotic

@subotic subotic commented Dec 10, 2022 •

Copy link
Copy Markdown
Collaborator

Pull Request Checklist

Task Description/Number

Issue Number: DEV-1555

Basic Requirements

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix: represents bug fixes
  • Refactor: represents production code refactoring
  • Feature: represents a new feature
  • Documentation: documentation changes (no production code change)
  • Chore: maintenance tasks (no production code change)
  • Style: styles updates (no production code change)
  • Test: all about tests: adding, refactoring tests (no production code change)
  • Other... Please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Does this PR change client-test-data?

  • Yes (don't forget to update the JS-LIB team about the change)
  • No

@subotic subotic self-assigned this Dec 10, 2022
@swarmia

swarmia Bot commented Dec 10, 2022

Copy link
Copy Markdown

✅  Linked to Story DEV-1555 · Add prometheus metrics endpoint

@codecov

codecov Bot commented Dec 10, 2022 •

Copy link
Copy Markdown

Codecov Report

Base: 86.68% // Head: 85.85% // Decreases project coverage by -0.82% ⚠️

Coverage data is based on head (75458e5) compared to base (26e9596).
Patch coverage: 18.91% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2331      +/-   ##
==========================================
- Coverage   86.68%   85.85%   -0.83%     
==========================================
  Files         250      238      -12     
  Lines       28252    27924     -328     
==========================================
- Hits        24490    23975     -515     
- Misses       3762     3949     +187     
Impacted Files Coverage Δ
webapi/src/main/scala/org/knora/webapi/Main.scala 0.00% <0.00%> (ø)
...main/scala/org/knora/webapi/config/AppConfig.scala 75.51% <ø> (-6.13%) ⬇️
.../org/knora/webapi/core/HttpServerWithZIOHttp.scala 0.00% <0.00%> (ø)
.../knora/webapi/core/InstrumentationHttpServer.scala 0.00% <0.00%> (ø)
...nora/webapi/instrumentation/health/HealthApp.scala 0.00% <0.00%> (ø)
.../knora/webapi/instrumentation/index/IndexApp.scala 0.00% <0.00%> (ø)
...api/instrumentation/prometheus/PrometheusApp.scala 0.00% <0.00%> (ø)
...main/scala/org/knora/webapi/routing/IndexApp.scala 0.00% <0.00%> (ø)
...c/main/scala/org/knora/webapi/core/AppServer.scala 90.62% <77.77%> (+1.07%) ⬆️
...p-shared/src/main/scala/dsp/config/AppConfig.scala 0.00% <0.00%> (-100.00%) ⬇️
... and 29 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@irinaschubert irinaschubert left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


override def run = for {
f1 <- PrometheusServer.make.forkDaemon
f2 <- (AppServer.live *> ZIO.never).forkDaemon

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to leave AppServer.live.launch instead of AppServer.live *> ZIO.never?

@subotic subotic Dec 12, 2022 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.launch is a method on ZLayer. It does exactly the same.

@BalduinLandolt BalduinLandolt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good code-wise, I would like to have seen some documentation on it


object PrometheusServer {

private val nThreads = 5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not coming from the config?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what it does exactly. I still need to figure that out first. Maybe we don't need it.

@mpro7 mpro7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Feel free to apply my suggestion. Shouldn't PrometheusServer has some unit tests written?

Comment on lines +35 to +38
f1 <- PrometheusServer.make.forkDaemon
f2 <- (AppServer.live *> ZIO.never).forkDaemon
_ <- f1.join
_ <- f2.join

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f1 <- PrometheusServer.make.forkDaemon
f2 <- (AppServer.live *> ZIO.never).forkDaemon
_ <- f1.join
_ <- f2.join
_ <- PrometheusServer.make.forkDaemon.join
_ <- (AppServer.live *> ZIO.never).forkDaemon.join

How about join in the same lines?

@seakayone

Copy link
Copy Markdown
Contributor

As discussed. I would prefer to have all zio http server definitions in the core package side by side.

I do think it will make sense to split the application and instrumentation http endpoint to be on separate port, hence the new Server should be named InstrumentationHttpServer or something like that .

Please also move the health route to the instrumentation server.

@subotic subotic changed the title refactor: add prometheus endpoint refactor: add prometheus endpoint (DEV-1555) Dec 14, 2022
@subotic

subotic commented Dec 14, 2022

Copy link
Copy Markdown
Collaborator Author

Looks good code-wise, I would like to have seen some documentation on it

Docs added.

@subotic

subotic commented Dec 14, 2022

Copy link
Copy Markdown
Collaborator Author

As discussed. I would prefer to have all zio http server definitions in the core package side by side.

I do think it will make sense to split the application and instrumentation http endpoint to be on separate port, hence the new Server should be named InstrumentationHttpServer or something like that .

Please also move the health route to the instrumentation server.

done.

@subotic subotic changed the title refactor: add prometheus endpoint (DEV-1555) refactor: add metrics endpoint (DEV-1555) Dec 14, 2022
@subotic
subotic merged commit b06f5b4 into main Dec 14, 2022
@subotic
subotic deleted the wip/DEV-1555-add-prometheus-endpoint branch December 14, 2022 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants