-
Notifications
You must be signed in to change notification settings - Fork 8.2k
add prometheus library #72804
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
add prometheus library #72804
Conversation
cf94baa to
b806b91
Compare
bjarki-andreasen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some notes:
- The
pm_namespace is used for "power management", maybe update it tonet_pm, orpmts_? or simplyprometheus_ - I think prometheous may be better placed in
subsys/mgmtalongside integrations like mcumgr, rather thannet, where we have MQTT, IPV4 etc
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally use typedefs only for function pointers in Zephyr and avoid using typedefs for structs. So with this in mind you could just have struct pm_collector_node { ... } here. Similar comment to all the other typedefs you have in the header files.
Also, all the structs and their fields need to be documented if they are considered to be "public" i.e., used by the application. For "private" structs, you should use /** @cond INTERNAL_HIDDEN */ ... /** @endcond */ to prevent the struct from showing in the generated documentation. See examples in other header files. It would be good to document all structs regardless of their public/private status so that the usage of them can be understood by casual reader / reviewer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the pm_ prefix, I think we could use prometheus_ as suggested by @bjarki-trackunit. It is a bit longish but we avoid confusion with power mgmt APIs.
samples/net/prometheus/Kconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better Prometheus ...
|
About the location, I initially thought the |
b806b91 to
25ffd4a
Compare
I waiting to opinion for re-place library components. For now i did solve @jukkar reviewed points. |
4eb172e to
1d174ce
Compare
jukkar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not finish the review yet, but some preliminary comments added.
As a general note I am not a big fan of the dynamic memory we are using all over the place. We have been trying to minimize the usage of malloc in the network stack, but this is not possible always but we should try to minimize malloc use (because if malloc is not used, then there is no possibility to memory leaks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are part of the API that applications will use, then these needs to be documented so that the generated documentation contains useful information. Same comment to all structs in the header files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add detailed comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of our own list pointers, would it make sense to use the slist API here, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to use slist apis at first. I will update with slist instead of my linked list implementation but I should be try. We should will measure overhead between implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use strncmp() to make sure we do not read past the end of buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite large and will use lot of stack, do we need this long tmp buffer?
|
Also we will need some tests for these, could be placed for example to |
We did decide about library place? Can i integrate to under net/lib for now ? |
I think there is no consensus yet, it should be trivial change if the location is changed, just some |
fe4fe4b to
fa57e53
Compare
Hi @jukkar. I did completely remove k_malloc and various allocation so library evolve to compile time definitions. As far as i see try to implement iterable sections. If the implementation good, i will start to write test. |
fa57e53 to
123da84
Compare
b1b5248 to
306d73f
Compare
5918a49 to
f9fc954
Compare
|
There is one compliance error that we could fix |
I just apply clang-format. Check complience pipeline give error following type. struct http_resource_detail_dynamic dyn_resource_detail = {
.common =
{
.type = HTTP_RESOURCE_TYPE_DYNAMIC,
.bitmask_of_supported_http_methods = BIT(HTTP_GET),
.content_type = "text/plain",
},
.cb = dyn_handler,
.user_data = NULL,
};but if i move to bracket previous line like following i give warning (https://github.com/zephyrproject-rtos/zephyr/actions/runs/11113829987). Which one is true?: struct http_resource_detail_dynamic dyn_resource_detail = {
.common = {
.type = HTTP_RESOURCE_TYPE_DYNAMIC,
.bitmask_of_supported_http_methods = BIT(HTTP_GET),
.content_type = "text/plain",
},
.cb = dyn_handler,
.user_data = NULL,
}; |
|
Clang format annotations are non-blocking, ideally this is fixed in the |
|
As Pieter said, just ignore the clang- format suggestions for now. |
|
@josuah gentle ping :) |
josuah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience, I was traveling but I am back now.
Some very minor changes proposed, but it looks very close now.
Thank you for all the iterations!
The library provides Prometheus metrics types, collector and exposion formatter. The library isn't thread-safe for now. The next first pull request will support that. Can be use exposion formatted output with Zephyr Http server. Signed-off-by: Mustafa Abdullah Kus <[email protected]>
The sample uses the Zephyr HTTP server library and demonstrates the Prometheus metric server node. Prometheus client library runs as a pull method. The sample contains the HTTP request counter and increases when refresh path of '/metrics' from the browser. Signed-off-by: Mustafa Abdullah Kus <[email protected]>
Tests for prometheus library support. It contains integration and unit test each metric types. Signed-off-by: Mustafa Abdullah Kus <[email protected]>
f9fc954 to
0f1ccd3
Compare
josuah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, everything got fixed and addressed!
One minor suggestion, but does not hurt in any way.
Thank you for all the changes!
|
@nashif You had -1 to this, could you take a look again and approve. Also we need help to force push this because the PR contains binary certificate files and the compliance script does not accept them. |
|
congratulations! 🍾 |
Hey Zephyr Community! 🚀
I'm excited to announce the launch of our latest addition to the Zephyr ecosystem: the Zephyr Prometheus Library! 🎉
What is Zephyr Prometheus Library?
Zephyr Prometheus is a lightweight library designed to seamlessly integrate Prometheus metrics into your Zephyr projects. Whether you're developing for IoT, edge computing, or any other embedded application with Zephyr, monitoring and collecting metrics is now easier than ever.
Features:
📊 Effortless Integration: With just a few lines of code, you can start exposing custom metrics from your Zephyr applications.
🔍 Flexible Metrics Collection: Monitor crucial aspects of your application's performance, such as memory usage, task execution times, and custom-defined metrics.
🔒 Secure Communication: Ensure the integrity and confidentiality of your metrics data with secure communication protocols supported by Zephyr.
we'r talk about that pr following discussion: #72127
Metric Server
Grafana
Signed-off-by: Mustafa Abdullah Kus [email protected]