Skip to content

Commit 3e6c4e9

Browse files
feature: add observability metrics and update dependencies
1 parent 9b059bf commit 3e6c4e9

7 files changed

+168
-168
lines changed

.idea/currency-quote-wrapper.iml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Python_tests_in__Users_ivsouza_Github_ivdatahub_currency_quote_tests.xml renamed to .idea/runConfigurations/Python_tests_in__Users_ivsouza_github_com_ivanildobarauna_dev_currency_quote_tests.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.lock

+148-162
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "currency-quote"
3-
version = "4.0.2"
3+
version = "5.0.0"
44
description = "Complete solution for extracting currency pair quotes data. With comprehensive testing, parameter validation, flexible configuration management, Hexagonal Architecture, CI/CD pipelines, code quality tools, and detailed documentation."
55
authors = ["IvanildoBarauna <[email protected]>"]
66
readme = "README.md"
@@ -29,9 +29,9 @@ include = ["currency_quote*"]
2929

3030
[tool.poetry.dependencies]
3131
python = "^3.9"
32-
api-to-dataframe = "^1.3.12"
3332
pytest = "^8.3.4"
34-
otel-wrapper = {git = "https://github.com/ivanildobarauna-dev/open-o11y-wrapper.git", rev = "2.0.0"}
33+
api-to-dataframe = "^1.4.0"
34+
otel-wrapper = "^0.0.1"
3535

3636
[tool.poetry.group.dev.dependencies]
3737
coverage = "^7.5.4"

src/currency_quote/domain/services/get_currency_quote.py

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ValidateCurrencyUseCase,
77
)
88
from currency_quote.domain.entities.currency import CurrencyQuote, CurrencyObject
9+
from currency_quote.utils.open_observability import increment_metric
910

1011

1112
class GetCurrencyQuoteService:
@@ -15,16 +16,19 @@ def __init__(
1516
self.currency = currency
1617
self.currency_repository = currency_repository
1718

19+
@increment_metric
1820
def last(self) -> List[CurrencyQuote]:
1921
valid_currency = self.validate_currency_code()
2022
last_quote = self.currency_repository(valid_currency).get_last_quote()
2123
return last_quote
2224

25+
@increment_metric
2326
def history(self, reference_date: int) -> List[CurrencyQuote]:
2427
return self.currency_repository(
2528
self.validate_currency_code()
2629
).get_history_quote(reference_date=reference_date)
2730

31+
@increment_metric
2832
def validate_currency_code(self) -> CurrencyObject:
2933
currency_valid_obj = ValidateCurrencyUseCase.execute(self.currency)
3034
return currency_valid_obj
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from otel_wrapper import OpenObservability
2+
3+
metrics_wrapper = OpenObservability(application_name="currency-quote").get_wrapper().metrics()
4+
5+
6+
def increment_metric(func):
7+
def inner(*args, **kwargs):
8+
metrics_wrapper.metric_increment(func.__qualname__, value=1, tags=kwargs)
9+
return func(*args, **kwargs)
10+
return inner

0 commit comments

Comments
 (0)