Skip to content

Commit 9e6ca99

Browse files
GitHKAndrei Neagu
andauthored
🎨 Adding tracing to agent and dynamic-sidecar (🏗️ DEVOPS) (#6691)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent 0781e63 commit 9e6ca99

File tree

12 files changed

+33
-0
lines changed

12 files changed

+33
-0
lines changed

.env-devel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AGENT_VOLUMES_CLEANUP_S3_ENDPOINT=http://172.17.0.1:9001
1717
AGENT_VOLUMES_CLEANUP_S3_PROVIDER=MINIO
1818
AGENT_VOLUMES_CLEANUP_S3_REGION=us-east-1
1919
AGENT_VOLUMES_CLEANUP_S3_SECRET_KEY=12345678
20+
AGENT_TRACING={}
2021

2122
API_SERVER_DEV_FEATURES_ENABLED=0
2223
API_SERVER_LOGLEVEL=INFO

services/agent/src/simcore_service_agent/core/application.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
get_common_oas_options,
66
override_fastapi_openapi_method,
77
)
8+
from servicelib.fastapi.tracing import setup_tracing
89
from servicelib.logging_utils import config_all_loggers
910

1011
from .._meta import (
@@ -59,6 +60,9 @@ def create_app() -> FastAPI:
5960
setup_rest_api(app)
6061
setup_rpc_api_routes(app)
6162

63+
if settings.AGENT_TRACING:
64+
setup_tracing(app, settings.AGENT_TRACING, APP_NAME)
65+
6266
async def _on_startup() -> None:
6367
print(APP_STARTED_BANNER_MSG, flush=True) # noqa: T201
6468

services/agent/src/simcore_service_agent/core/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from settings_library.base import BaseCustomSettings
77
from settings_library.r_clone import S3Provider
88
from settings_library.rabbit import RabbitSettings
9+
from settings_library.tracing import TracingSettings
910
from settings_library.utils_logging import MixinLoggingSettings
1011

1112

@@ -77,6 +78,10 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
7778
auto_default_from_env=True, description="settings for service/rabbitmq"
7879
)
7980

81+
AGENT_TRACING: TracingSettings | None = Field(
82+
auto_default_from_env=True, description="settings for opentelemetry tracing"
83+
)
84+
8085
@validator("LOGLEVEL")
8186
@classmethod
8287
def valid_log_level(cls, value) -> LogLevel:

services/agent/tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def mock_environment(
5858
"RABBIT_SECURE": "false",
5959
"RABBIT_USER": "test",
6060
"AGENT_DOCKER_NODE_ID": docker_node_id,
61+
"AGENT_TRACING": "null",
6162
},
6263
)
6364

services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ def _get_environment_variables(
175175
"S3_SECRET_KEY": r_clone_settings.R_CLONE_S3.S3_SECRET_KEY,
176176
"SC_BOOT_MODE": f"{app_settings.DYNAMIC_SERVICES.DYNAMIC_SIDECAR.DYNAMIC_SIDECAR_SC_BOOT_MODE}",
177177
"SSL_CERT_FILE": app_settings.DIRECTOR_V2_SELF_SIGNED_SSL_FILENAME,
178+
"DYNAMIC_SIDECAR_TRACING": (
179+
app_settings.DIRECTOR_V2_TRACING.json()
180+
if app_settings.DIRECTOR_V2_TRACING
181+
else "null"
182+
),
178183
# For background info on this special env-var above, see
179184
# - https://stackoverflow.com/questions/31448854/how-to-force-requests-use-the-certificates-on-my-ubuntu-system#comment78596389_37447847
180185
"SIMCORE_HOST_NAME": scheduler_data.service_name,

services/director-v2/tests/unit/test_modules_dynamic_sidecar_docker_service_specs_sidecar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"DY_SIDECAR_USER_SERVICES_HAVE_INTERNET_ACCESS",
3838
"DYNAMIC_SIDECAR_COMPOSE_NAMESPACE",
3939
"DYNAMIC_SIDECAR_LOG_LEVEL",
40+
"DYNAMIC_SIDECAR_TRACING",
4041
"NODE_PORTS_400_REQUEST_TIMEOUT_ATTEMPTS",
4142
"POSTGRES_DB",
4243
"POSTGRES_ENDPOINT",

services/director-v2/tests/unit/with_dbs/test_modules_dynamic_sidecar_docker_service_specs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def expected_dynamic_sidecar_spec(
243243
"FORWARD_ENV_DISPLAY": ":0",
244244
"NODE_PORTS_400_REQUEST_TIMEOUT_ATTEMPTS": "3",
245245
"DYNAMIC_SIDECAR_LOG_LEVEL": "DEBUG",
246+
"DYNAMIC_SIDECAR_TRACING": "null",
246247
"DY_DEPLOYMENT_REGISTRY_SETTINGS": (
247248
'{"REGISTRY_AUTH": false, "REGISTRY_PATH": null, '
248249
'"REGISTRY_URL": "foo.bar.com", "REGISTRY_USER": '

services/docker-compose-ops.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ services:
111111
- "4318:4318" # OTLP HTTP receiver
112112
networks:
113113
- simcore_default
114+
- interactive_services_subnet
114115
environment:
115116
TRACING_OPENTELEMETRY_COLLECTOR_BATCH_SIZE: ${TRACING_OPENTELEMETRY_COLLECTOR_BATCH_SIZE}
116117
TRACING_OPENTELEMETRY_COLLECTOR_SAMPLING_PERCENTAGE: ${TRACING_OPENTELEMETRY_COLLECTOR_SAMPLING_PERCENTAGE}

services/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,10 @@ services:
10531053
RABBIT_USER: ${RABBIT_USER}
10541054
RABBIT_SECURE: ${RABBIT_SECURE}
10551055

1056+
AGENT_TRACING: ${AGENT_TRACING}
1057+
TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT: ${TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}
1058+
TRACING_OPENTELEMETRY_COLLECTOR_PORT: ${TRACING_OPENTELEMETRY_COLLECTOR_PORT}
1059+
10561060
dask-sidecar:
10571061
image: ${DOCKER_REGISTRY:-itisfoundation}/dask-sidecar:${DOCKER_IMAGE_TAG:-latest}
10581062
init: true

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/application.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_common_oas_options,
1010
override_fastapi_openapi_method,
1111
)
12+
from servicelib.fastapi.tracing import setup_tracing
1213
from servicelib.logging_utils import config_all_loggers
1314
from simcore_sdk.node_ports_common.exceptions import NodeNotFound
1415

@@ -190,6 +191,9 @@ def create_app():
190191
if application_settings.are_prometheus_metrics_enabled:
191192
setup_prometheus_metrics(app)
192193

194+
if application_settings.DYNAMIC_SIDECAR_TRACING:
195+
setup_tracing(app, application_settings.DYNAMIC_SIDECAR_TRACING, PROJECT_NAME)
196+
193197
# ERROR HANDLERS ------------
194198
app.add_exception_handler(NodeNotFound, node_not_found_error_handler)
195199
app.add_exception_handler(BaseDynamicSidecarError, http_error_handler)

0 commit comments

Comments
 (0)