Skip to content

Commit f746ba5

Browse files
authored
[mock_uss] interaction logging for the mock RID DP and SP (#881)
1 parent 6d7c256 commit f746ba5

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

monitoring/mock_uss/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def require_config_value(config_key: str) -> None:
108108
from monitoring.mock_uss.interaction_logging import logger as interactions_logger
109109
from monitoring.mock_uss.interaction_logging import routes_interactions_log
110110

111+
logger.info("Interaction logging enabled")
112+
else:
113+
logger.info("Interaction logging disabled")
114+
111115
if SERVICE_TRACER in webapp.config[config.KEY_SERVICES]:
112116
enabled_services.add(SERVICE_TRACER)
113117
from monitoring.mock_uss import tracer

monitoring/mock_uss/docker-compose.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ services:
106106
- MOCK_USS_PUBLIC_KEY=/var/test-certs/auth2.pem
107107
- MOCK_USS_TOKEN_AUDIENCE=v22a.ridsp.uss1.localutm,localhost,host.docker.internal
108108
- MOCK_USS_BASE_URL=http://v22a.ridsp.uss1.localutm
109-
- MOCK_USS_SERVICES=ridsp
109+
- MOCK_USS_SERVICES=ridsp,interaction_logging
110+
- MOCK_USS_INTERACTIONS_LOG_DIR=output/ridsp_interaction_logs
110111
- MOCK_USS_RID_VERSION=F3411-22a
111112
- MOCK_USS_PORT=80
112113
- MOCK_USS_PROXY_VALUES=x_for=1,x_proto=1,x_host=1,x_prefix=1,x_port=1
@@ -116,6 +117,7 @@ services:
116117
- 8081:80
117118
volumes:
118119
- ../../build/test-certs:/var/test-certs:ro
120+
- ./output/ridsp_interaction_logs:/app/monitoring/mock_uss/output/ridsp_interaction_logs
119121
restart: always
120122
networks:
121123
- interop_ecosystem_network
@@ -136,7 +138,8 @@ services:
136138
- MOCK_USS_PUBLIC_KEY=/var/test-certs/auth2.pem
137139
- MOCK_USS_TOKEN_AUDIENCE=v22a.riddp.uss1.localutm,localhost,host.docker.internal
138140
- MOCK_USS_BASE_URL=http://v22a.riddp.uss1.localutm
139-
- MOCK_USS_SERVICES=riddp
141+
- MOCK_USS_SERVICES=riddp,interaction_logging
142+
- MOCK_USS_INTERACTIONS_LOG_DIR=output/riddp_interaction_logs
140143
- MOCK_USS_RID_VERSION=F3411-22a
141144
- MOCK_USS_PORT=80
142145
- MOCK_USS_PROXY_VALUES=x_for=1,x_proto=1,x_host=1,x_prefix=1,x_port=1
@@ -146,6 +149,7 @@ services:
146149
- 8083:80
147150
volumes:
148151
- ../../build/test-certs:/var/test-certs:ro
152+
- ./output/riddp_interaction_logs:/app/monitoring/mock_uss/output/riddp_interaction_logs
149153
restart: always
150154
networks:
151155
- interop_ecosystem_network
@@ -166,7 +170,8 @@ services:
166170
- MOCK_USS_PUBLIC_KEY=/var/test-certs/auth2.pem
167171
- MOCK_USS_TOKEN_AUDIENCE=v19.ridsp.uss2.localutm,localhost,host.docker.internal
168172
- MOCK_USS_BASE_URL=http://v19.ridsp.uss2.localutm
169-
- MOCK_USS_SERVICES=ridsp
173+
- MOCK_USS_SERVICES=ridsp,interaction_logging
174+
- MOCK_USS_INTERACTIONS_LOG_DIR=output/ridsp_v19_interaction_logs
170175
- MOCK_USS_RID_VERSION=F3411-19
171176
- MOCK_USS_PORT=80
172177
- MOCK_USS_PROXY_VALUES=x_for=1,x_proto=1,x_host=1,x_prefix=1,x_port=1
@@ -176,6 +181,7 @@ services:
176181
- 8071:80
177182
volumes:
178183
- ../../build/test-certs:/var/test-certs:ro
184+
- ./output/ridsp_v19_interaction_logs:/app/monitoring/mock_uss/output/ridsp_v19_interaction_logs
179185
restart: always
180186
networks:
181187
- interop_ecosystem_network
@@ -196,7 +202,8 @@ services:
196202
- MOCK_USS_PUBLIC_KEY=/var/test-certs/auth2.pem
197203
- MOCK_USS_TOKEN_AUDIENCE=v19.riddp.uss3.localutm,localhost,host.docker.internal
198204
- MOCK_USS_BASE_URL=http://v19.riddp.uss3.localutm
199-
- MOCK_USS_SERVICES=riddp
205+
- MOCK_USS_SERVICES=riddp,interaction_logging
206+
- MOCK_USS_INTERACTIONS_LOG_DIR=output/riddp_v19_interaction_logs
200207
- MOCK_USS_RID_VERSION=F3411-19
201208
- MOCK_USS_PORT=80
202209
- MOCK_USS_PROXY_VALUES=x_for=1,x_proto=1,x_host=1,x_prefix=1,x_port=1
@@ -206,6 +213,7 @@ services:
206213
- 8073:80
207214
volumes:
208215
- ../../build/test-certs:/var/test-certs:ro
216+
- ./output/riddp_v19_interaction_logs:/app/monitoring/mock_uss/output/riddp_v19_interaction_logs
209217
restart: always
210218
networks:
211219
- interop_ecosystem_network

monitoring/mock_uss/interaction_logging/logger.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44

55
import flask
6-
import arrow
76

87
from monitoring.mock_uss import webapp, require_config_value
98
from monitoring.mock_uss.interaction_logging.config import KEY_INTERACTIONS_LOG_DIR
@@ -53,6 +52,12 @@ def on_query(self, query: Query) -> None:
5352
if "query_type" in query and query.query_type in {
5453
QueryType.F3548v21USSGetOperationalIntentDetails,
5554
QueryType.F3548v21USSNotifyOperationalIntentDetailsChanged,
55+
QueryType.F3411v19USSGetFlightDetails,
56+
QueryType.F3411v19USSPostIdentificationServiceArea,
57+
QueryType.F3411v19USSSearchFlights,
58+
QueryType.F3411v22aUSSSearchFlights,
59+
QueryType.F3411v22aUSSGetFlightDetails,
60+
QueryType.F3411v22aUSSPostIdentificationServiceArea,
5661
}:
5762
log_interaction(QueryDirection.Outgoing, query)
5863

@@ -72,7 +77,11 @@ def interaction_log_after_request(response):
7277
datetime.datetime.now(datetime.UTC) - flask.current_app.custom_profiler["start"]
7378
).total_seconds()
7479
# TODO: Make this configurable instead of hardcoding exactly these query types
75-
if "/uss/v1/" in flask.request.url:
80+
if (
81+
"/uss/v1/" in flask.request.url
82+
or "/uss/identification_service_areas/" in flask.request.url
83+
or "/uss/flights/" in flask.request.url
84+
):
7685
query = describe_flask_query(flask.request, response, elapsed_s)
7786
log_interaction(QueryDirection.Incoming, query)
7887
return response

0 commit comments

Comments
 (0)