Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1182: Refactor Prometheus metrics reporting (ISSUE-1182 part 2) #1200

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

kgiusti
Copy link
Contributor

@kgiusti kgiusti commented Sep 14, 2023

o Implement dynamic registration of each alloc_pool metric
o Refactor http-libwebsockets.c /metrics implementation
o Update unit tests

@kgiusti kgiusti linked an issue Sep 14, 2023 that may be closed by this pull request
@kgiusti kgiusti requested a review from fgiorgetti September 14, 2023 13:24
@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #1200 (6860923) into main (0d9a19a) will increase coverage by 0.08%.
Report is 2 commits behind head on main.
The diff coverage is 74.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1200      +/-   ##
==========================================
+ Coverage   78.22%   78.31%   +0.08%     
==========================================
  Files         244      244              
  Lines       63144    63219      +75     
  Branches     5846     5852       +6     
==========================================
+ Hits        49392    49507     +115     
+ Misses      11098    11075      -23     
+ Partials     2654     2637      -17     
Flag Coverage Δ
pysystemtests 87.57% <100.00%> (+0.01%) ⬆️
pyunittests 54.44% <ø> (ø)
systemtests 72.38% <71.42%> (+0.15%) ⬆️
unittests 26.60% <13.66%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
calculator 30.12% <13.66%> (-0.03%) ⬇️
systemtests 78.92% <74.28%> (+0.08%) ⬆️

…UE-1182 part 2)

 o Implement dynamic registration of each alloc_pool metric
 o Refactor http-libwebsockets.c /metrics implementation
 o Update unit tests
size_t current;
bool headers_sent;
stats_request_state_t *context;
stats_request_state_t *state;
Copy link
Contributor

@ganeshmurthy ganeshmurthy Sep 22, 2023

Choose a reason for hiding this comment

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

Why not simply move the response_complete flag into stats_request_state_t and get rid of stats_t ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most excellent question. It's because I'm paranoid.
It might be possible to get a spurious WRITEABLE event after the request is complete and we've freed the state. Can't tell for sure from the LWS code. Thought best to keep the flag out of the free-able state in case the spurious WRITEABLE occurred after the response was completed (and state freed).


// encode stats into buffer

if (lws_add_http_header_status(wsi, HTTP_STATUS_OK, &start, end)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add a comment here.
Looking at the code, I am assuming that it is trying to first set the response header status to 200, sets the content type and text/plain and adds a connection: header and finally finishes off the http header and if any of these operations fail, the whole request fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add a comment here.

Don't worry about this - the log message Metrics request failed: cannot send headers is good enough

# sanity check that all expected stats are reported
resp = urlopen(f"http://localhost:{port}/metrics", cafile=self.ssl_file('ca-certificate.pem'))
self.assertEqual(200, resp.getcode())
metrics = [x for x in resp.read().decode('utf-8').splitlines() if not x.startswith("#")]
Copy link
Contributor

@ganeshmurthy ganeshmurthy Sep 22, 2023

Choose a reason for hiding this comment

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

WHOA !! I just got Conway-ed !!

Copy link
Contributor

@ganeshmurthy ganeshmurthy left a comment

Choose a reason for hiding this comment

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

Excellent work !

@kgiusti kgiusti merged commit 3d47404 into skupperproject:main Sep 25, 2023
@kgiusti kgiusti deleted the ISSUE-1182-PART02 branch September 25, 2023 15:48
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.

Update/improve prometheus metrics
2 participants