From 20c62575727624acb8641ea78d3535973111a701 Mon Sep 17 00:00:00 2001 From: bmrozinski-dt <80966430+bmrozinski-dt@users.noreply.github.com> Date: Thu, 25 Nov 2021 12:38:22 +0100 Subject: [PATCH] APM-317073 - logging AWS log forwarder stack version (#47) APM-317073 - logging AWS log forwarder stack version in forwarder Lambda's log --- src/index.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.py b/src/index.py index c0b625b..3fc9cca 100644 --- a/src/index.py +++ b/src/index.py @@ -28,6 +28,15 @@ def handler(event, lambda_context): dt_token = os.environ.get('DYNATRACE_API_KEY') verify_SSL = os.environ.get('VERIFY_SSL', 'false') == 'true' + try: + with open('version.txt') as versionFile: + version = versionFile.readline() + except Exception as e: + version = "?" + log_multiline_message(f"Couldn't read stack version. Exception: '{e}'.", "version-reading-exception") + + log_multiline_message("LOG FORWARDER version=" + version, "handler") + ensure_credentials_provided(dt_token, dt_url) records = event['records']