-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): implement prometheus metrics
see #231
- Loading branch information
Showing
9 changed files
with
192 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from prometheus_client import Gauge | ||
from prometheus_fastapi_instrumentator.metrics import Info | ||
|
||
from abrechnung.application.groups import GroupService | ||
from abrechnung.application.transactions import TransactionService | ||
|
||
|
||
def abrechnung_number_of_groups_total(group_service: GroupService): | ||
metric = Gauge( | ||
"abrechnung_number_of_groups_total", | ||
"Number of groups created on this Abrechnung instance..", | ||
) | ||
|
||
async def instrumentation(info: Info) -> None: | ||
total = await group_service.total_number_of_groups() | ||
metric.set(total) | ||
|
||
return instrumentation | ||
|
||
|
||
def abrechnung_number_of_transactions_total(transaction_service: TransactionService): | ||
metric = Gauge( | ||
"abrechnung_number_of_transactions_total", | ||
"Number of transactions created on this Abrechnung instance..", | ||
) | ||
|
||
async def instrumentation(info: Info) -> None: | ||
total = await transaction_service.total_number_of_transactions() | ||
metric.set(total) | ||
|
||
return instrumentation | ||
|
||
|
||
def abrechnung_total_amount_of_money(transaction_service: TransactionService): | ||
metric = Gauge( | ||
"abrechnung_total_amount_of_money", | ||
"Total amount of money per currency cleared via thisthis Abrechnung instance..", | ||
labelnames=("currency_symbol",), | ||
) | ||
|
||
async def instrumentation(info: Info) -> None: | ||
total = await transaction_service.total_amount_of_money_per_currency() | ||
for currency, value in total.items(): | ||
metric.labels(currency).set(value) | ||
|
||
return instrumentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.