summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/__init__.py')
-rw-r--r--components/pm-subscription-handler/pmsh_service/mod/__init__.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/__init__.py b/components/pm-subscription-handler/pmsh_service/mod/__init__.py
index 1024417e..548670c3 100644
--- a/components/pm-subscription-handler/pmsh_service/mod/__init__.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/__init__.py
@@ -1,5 +1,5 @@
# ============LICENSE_START===================================================
-# Copyright (C) 2019-2021 Nordix Foundation.
+# Copyright (C) 2019-2022 Nordix Foundation.
# ============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
-import logging as logging
+import logging
import os
import pathlib
import ssl
@@ -26,6 +26,9 @@ from flask_sqlalchemy import SQLAlchemy
from onaplogging import monkey
from onaplogging.mdcContext import MDC
from ruamel.yaml import YAML
+import uuid
+from functools import wraps
+from os import getenv
db = SQLAlchemy()
basedir = os.path.abspath(os.path.dirname(__file__))
@@ -33,6 +36,22 @@ _connexion_app = None
logger = logging.getLogger('onap_logger')
+def mdc_handler(func):
+ @wraps(func)
+ def wrapper(*args, **kwargs):
+ request_id = str(uuid.uuid1())
+ invocation_id = str(uuid.uuid1())
+ MDC.put('ServiceName', getenv('HOSTNAME'))
+ MDC.put('RequestID', request_id)
+ MDC.put('InvocationID', invocation_id)
+
+ kwargs['request_id'] = request_id
+ kwargs['invocation_id'] = invocation_id
+ return func(*args, **kwargs)
+
+ return wrapper
+
+
def _get_app():
global _connexion_app
if not _connexion_app: