Skip to content

Commit 07f67fa

Browse files
marcosborgesmichaelyaakoby
authored andcommitted
feat: Added possibility to customize meta data
1 parent 5ada442 commit 07f67fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pyctuator/impl/spring_boot_admin_registration.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(
2525
start_time: datetime,
2626
service_url: str,
2727
registration_interval_sec: int,
28+
application_metadata: dict
2829
) -> None:
2930
self.registration_url = registration_url
3031
self.registration_auth = registration_auth
@@ -34,6 +35,7 @@ def __init__(
3435
self.service_url = service_url if service_url.endswith("/") else service_url + "/"
3536
self.registration_interval_sec = registration_interval_sec
3637
self.instance_id = None
38+
self.application_metadata = application_metadata
3739

3840
self.should_continue_registration_schedule: bool = False
3941
self.disable_certificate_validation_for_https_registration: bool = \
@@ -58,7 +60,10 @@ def _register_with_admin_server(self) -> None:
5860
"managementUrl": self.pyctuator_base_url,
5961
"healthUrl": f"{self.pyctuator_base_url}/health",
6062
"serviceUrl": self.service_url,
61-
"metadata": {"startup": self.start_time.isoformat()}
63+
"metadata": {
64+
"startup": self.start_time.isoformat(),
65+
**self.application_metadata
66+
}
6267
}
6368

6469
logging.debug("Trying to post registration data to %s: %s",

pyctuator/pyctuator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(
3838
logfile_max_size: int = 10000,
3939
logfile_formatter: str = default_logfile_format,
4040
auto_deregister: bool = True,
41+
metadata: dict = None
4142
) -> None:
4243
"""The entry point for integrating pyctuator with a web-frameworks such as FastAPI and Flask.
4344
@@ -120,6 +121,7 @@ def __init__(
120121
start_time,
121122
app_url,
122123
registration_interval_sec,
124+
metadata
123125
)
124126

125127
# Deregister from SBA on exit

0 commit comments

Comments
 (0)