Skip to content

Commit 63c9a78

Browse files
authored
Merge pull request #112 from NHSDigital/APM-4693-splunk-logging
Apm 4693 splunk logging
2 parents f33f562 + 04fe5d6 commit 63c9a78

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ __pycache__/
1818
.env
1919
.env*
2020
.vscode/
21+
.direnv/
2122

2223
smoketest-report.xml

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ install: install-node install-python .git/hooks/pre-commit
1414

1515
lint:
1616
npm run lint
17-
find . -name '*.py' -not -path '**/.venv/*' | xargs poetry run flake8
17+
find . -name '*.py' -not -path '**/.venv/*' -not -path '**/.direnv/*'| xargs poetry run flake8
1818

1919
clean:
2020
rm -rf build

proxies/live/apiproxy/policies/FlowCallout.LogToSplunk.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<FaultRules/>
55
<Properties/>
66
<SharedFlowBundle>LogToSplunk</SharedFlowBundle>
7-
</FlowCallout>
7+
</FlowCallout>

tests/test_splunk_logging.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ def test_splunk_payload_schema(
5656
# If no exception is raised by validate(), the instance is valid.
5757
validate(instance=payload, schema=schema)
5858

59+
def test_splunk_payload_client_sent_timestamp(
60+
self,
61+
nhsd_apim_auth_headers,
62+
nhsd_apim_proxy_url,
63+
trace,
64+
):
65+
session_name = str(uuid4())
66+
header_filters = {"trace_id": session_name}
67+
trace.post_debugsession(session=session_name, header_filters=header_filters)
68+
69+
requests.get(
70+
url=f"{nhsd_apim_proxy_url}/splunk-test",
71+
headers={**nhsd_apim_auth_headers, **header_filters},
72+
)
73+
74+
payload = json.loads(
75+
get_variable_from_trace(trace, session_name, "splunkCalloutRequest.content")
76+
)
77+
78+
trace.delete_debugsession_by_name(session_name)
79+
80+
assert int(payload["client"]["sent_start"]) > 0
81+
assert int(payload["client"]["sent_end"]) > 0
82+
5983
def test_splunk_payload_schema_open_access(
6084
self,
6185
nhsd_apim_proxy_url,

0 commit comments

Comments
 (0)