This pull request adds Prometheus endpoint to godoor.
It would be great to get some feedback on metric naming
% curl --silent localhost:3334/metrics | grep godoor
# HELP godoor_api_request_failed_total HTTP API request failures count
# TYPE godoor_api_request_failed_total counter
godoor_api_request_failed_total{api="allowed"} 1
godoor_api_request_failed_total{api="longpoll"} 2
godoor_api_request_failed_total{api="swipe"} 2
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6"} 1
# HELP godoor_cards_in_allow_list_total Number of card hashes that can open the door
# TYPE godoor_cards_in_allow_list_total gauge
godoor_cards_in_allow_list_total 29
# HELP godoor_door_opened_total Number of times door was opened
# TYPE godoor_door_opened_total counter
godoor_door_opened_total{source="api"} 1
godoor_door_opened_total{source="card"} 29
# HELP godoor_last_sync_timestamp_seconds Last time list of cards was pulled from the server
# TYPE godoor_last_sync_timestamp_seconds gauge
godoor_last_sync_timestamp_seconds 1.6913487496892412e+09
# HELP godoor_unknown_card_swipe_total Number of times a unknown (not in allow list) card has been swiped
# TYPE godoor_unknown_card_swipe_total counter
godoor_unknown_card_swipe_total 0
Metrics endpoint also includes bunch of default default go internal metrics and promhttp metrics.
% curl --silent localhost:3334/metrics
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.085e-05
go_gc_duration_seconds{quantile="0.25"} 5.434e-05
go_gc_duration_seconds{quantile="0.5"} 6.156e-05
go_gc_duration_seconds{quantile="0.75"} 6.953e-05
go_gc_duration_seconds{quantile="1"} 0.00014752
go_gc_duration_seconds_sum 0.004899808
go_gc_duration_seconds_count 78
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 69
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.20.7"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 954976
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 1.497291808e+09
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 4233
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 18751
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 8.98468e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 954976
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 6.7919872e+07
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 2.105344e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 3519
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 6.6961408e+07
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 7.0025216e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.6913489999112499e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 22270
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 19200
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 31200
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 198400
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 212160
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.194304e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 3.500175e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 1.277952e+06
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 1.277952e+06
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 8.4035616e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 22
# HELP godoor_api_request_failed_total HTTP API request failures count
# TYPE godoor_api_request_failed_total counter
godoor_api_request_failed_total{api="allowed"} 1
godoor_api_request_failed_total{api="longpoll"} 3
godoor_api_request_failed_total{api="swipe"} 2
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6"} 1
# HELP godoor_cards_in_allow_list_total Number of card hashes that can open the door
# TYPE godoor_cards_in_allow_list_total gauge
godoor_cards_in_allow_list_total 29
# HELP godoor_door_opened_total Number of times door was opened
# TYPE godoor_door_opened_total counter
godoor_door_opened_total{source="api"} 1
godoor_door_opened_total{source="card"} 88
# HELP godoor_last_sync_timestamp_seconds Last time list of cards was pulled from the server
# TYPE godoor_last_sync_timestamp_seconds gauge
godoor_last_sync_timestamp_seconds 1.6913488791300418e+09
# HELP godoor_unknown_card_swipe_total Number of times a unknown (not in allow list) card has been swiped
# TYPE godoor_unknown_card_swipe_total counter
godoor_unknown_card_swipe_total 0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 7.39
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 524288
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 37
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.439168e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.69134862945e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.320498688e+09
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 3
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
This pull request adds Prometheus endpoint to godoor.
It would be great to get some feedback on metric naming
```
% curl --silent localhost:3334/metrics | grep godoor
# HELP godoor_api_request_failed_total HTTP API request failures count
# TYPE godoor_api_request_failed_total counter
godoor_api_request_failed_total{api="allowed"} 1
godoor_api_request_failed_total{api="longpoll"} 2
godoor_api_request_failed_total{api="swipe"} 2
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6"} 1
# HELP godoor_cards_in_allow_list_total Number of card hashes that can open the door
# TYPE godoor_cards_in_allow_list_total gauge
godoor_cards_in_allow_list_total 29
# HELP godoor_door_opened_total Number of times door was opened
# TYPE godoor_door_opened_total counter
godoor_door_opened_total{source="api"} 1
godoor_door_opened_total{source="card"} 29
# HELP godoor_last_sync_timestamp_seconds Last time list of cards was pulled from the server
# TYPE godoor_last_sync_timestamp_seconds gauge
godoor_last_sync_timestamp_seconds 1.6913487496892412e+09
# HELP godoor_unknown_card_swipe_total Number of times a unknown (not in allow list) card has been swiped
# TYPE godoor_unknown_card_swipe_total counter
godoor_unknown_card_swipe_total 0
```
<details><summary>Metrics endpoint also includes bunch of default default go internal metrics and promhttp metrics.
</summary>
```
% curl --silent localhost:3334/metrics
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.085e-05
go_gc_duration_seconds{quantile="0.25"} 5.434e-05
go_gc_duration_seconds{quantile="0.5"} 6.156e-05
go_gc_duration_seconds{quantile="0.75"} 6.953e-05
go_gc_duration_seconds{quantile="1"} 0.00014752
go_gc_duration_seconds_sum 0.004899808
go_gc_duration_seconds_count 78
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 69
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.20.7"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 954976
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 1.497291808e+09
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 4233
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 18751
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 8.98468e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 954976
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 6.7919872e+07
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 2.105344e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 3519
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 6.6961408e+07
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 7.0025216e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.6913489999112499e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 22270
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 19200
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 31200
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 198400
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 212160
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.194304e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 3.500175e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 1.277952e+06
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 1.277952e+06
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 8.4035616e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 22
# HELP godoor_api_request_failed_total HTTP API request failures count
# TYPE godoor_api_request_failed_total counter
godoor_api_request_failed_total{api="allowed"} 1
godoor_api_request_failed_total{api="longpoll"} 3
godoor_api_request_failed_total{api="swipe"} 2
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6"} 1
# HELP godoor_cards_in_allow_list_total Number of card hashes that can open the door
# TYPE godoor_cards_in_allow_list_total gauge
godoor_cards_in_allow_list_total 29
# HELP godoor_door_opened_total Number of times door was opened
# TYPE godoor_door_opened_total counter
godoor_door_opened_total{source="api"} 1
godoor_door_opened_total{source="card"} 88
# HELP godoor_last_sync_timestamp_seconds Last time list of cards was pulled from the server
# TYPE godoor_last_sync_timestamp_seconds gauge
godoor_last_sync_timestamp_seconds 1.6913488791300418e+09
# HELP godoor_unknown_card_swipe_total Number of times a unknown (not in allow list) card has been swiped
# TYPE godoor_unknown_card_swipe_total counter
godoor_unknown_card_swipe_total 0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 7.39
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 524288
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 37
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.439168e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.69134862945e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.320498688e+09
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 3
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
```
</details>
Closes: #1
arti
self-assigned this 2023-08-06 19:13:35 +00:00
godoor_last_sync_timestamp_seconds -> godoor_last_allow_list_sync_timestamp_seconds godoor_unknown_card_swipe_total-> godoor_swipes_total and have label status which would be either accepted, denied and unknown godoor_door_opened_total -> godoor_door_opens_total godoor_api_request_failed_total -> godoor_api_request_failures_total and label could be maybe endpoint godoor_cards_in_allow_list_total -> godoor_allowed_card_hashes_total
Looks good but maybe names can be adjusted a bit
`godoor_last_sync_timestamp_seconds` -> `godoor_last_allow_list_sync_timestamp_seconds`
`godoor_unknown_card_swipe_total`-> `godoor_swipes_total` and have label `status` which would be either `accepted`, `denied` and `unknown`
`godoor_door_opened_total` -> `godoor_door_opens_total`
`godoor_api_request_failed_total` -> `godoor_api_request_failures_total` and label could be maybe `endpoint`
`godoor_cards_in_allow_list_total` -> `godoor_allowed_card_hashes_total`
arti
marked the pull request as work in progress 2023-08-07 06:58:26 +00:00
# HELP godoor_allowed_card_hashes_total Number of card hashes in memory that can open the door
# TYPE godoor_allowed_card_hashes_total gauge
godoor_allowed_card_hashes_total 2
# HELP godoor_api_request_failures_total HTTP API request failures count
# TYPE godoor_api_request_failures_total counter
godoor_api_request_failures_total{api="longpoll",endpoint="http://127.0.0.1:3333/longpoll"} 2
godoor_api_request_failures_total{api="swipe",endpoint="http://127.0.0.1:3333/cardswipe"} 43
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6-dirty"} 1
# HELP godoor_door_opens_total Number of times door was opened
# TYPE godoor_door_opens_total counter
godoor_door_opens_total{source="api"} 1
godoor_door_opens_total{source="card"} 32
# HELP godoor_last_allow_list_sync_timestamp_seconds Last time list of card hashes was pulled from the server
# TYPE godoor_last_allow_list_sync_timestamp_seconds gauge
godoor_last_allow_list_sync_timestamp_seconds 1.6913942670142028e+09
# HELP godoor_swipes_total Number of times a card has been swiped
# TYPE godoor_swipes_total counter
godoor_swipes_total{status="accepted"} 32
godoor_swipes_total{status="denied"} 53
Updated the naming
```
# HELP godoor_allowed_card_hashes_total Number of card hashes in memory that can open the door
# TYPE godoor_allowed_card_hashes_total gauge
godoor_allowed_card_hashes_total 2
# HELP godoor_api_request_failures_total HTTP API request failures count
# TYPE godoor_api_request_failures_total counter
godoor_api_request_failures_total{api="longpoll",endpoint="http://127.0.0.1:3333/longpoll"} 2
godoor_api_request_failures_total{api="swipe",endpoint="http://127.0.0.1:3333/cardswipe"} 43
# HELP godoor_build_info Build Information
# TYPE godoor_build_info gauge
godoor_build_info{revision="dcf7bb1103c636e3f7690b9a8bc3e25c38f9d458",version="v1-5-gdcf7bb1103c6-dirty"} 1
# HELP godoor_door_opens_total Number of times door was opened
# TYPE godoor_door_opens_total counter
godoor_door_opens_total{source="api"} 1
godoor_door_opens_total{source="card"} 32
# HELP godoor_last_allow_list_sync_timestamp_seconds Last time list of card hashes was pulled from the server
# TYPE godoor_last_allow_list_sync_timestamp_seconds gauge
godoor_last_allow_list_sync_timestamp_seconds 1.6913942670142028e+09
# HELP godoor_swipes_total Number of times a card has been swiped
# TYPE godoor_swipes_total counter
godoor_swipes_total{status="accepted"} 32
godoor_swipes_total{status="denied"} 53
```
arti
marked the pull request as ready for review 2023-08-07 07:46:55 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This pull request adds Prometheus endpoint to godoor.
It would be great to get some feedback on metric naming
Metrics endpoint also includes bunch of default default go internal metrics and promhttp metrics.
Closes: #1
Looks good but maybe names can be adjusted a bit
godoor_last_sync_timestamp_seconds->godoor_last_allow_list_sync_timestamp_secondsgodoor_unknown_card_swipe_total->godoor_swipes_totaland have labelstatuswhich would be eitheraccepted,deniedandunknowngodoor_door_opened_total->godoor_door_opens_totalgodoor_api_request_failed_total->godoor_api_request_failures_totaland label could be maybeendpointgodoor_cards_in_allow_list_total->godoor_allowed_card_hashes_totaldcf7bb1103to22487faf06Updated the naming
LGTM