From 0829a8b66351514530e07b9e9a580887d45e2158 Mon Sep 17 00:00:00 2001 From: hackerrdave Date: Thu, 28 May 2020 11:21:03 -0400 Subject: [PATCH] if SIGNALFX_ENVIRONMENT env variable is present, set it as value for environment root span tag --- README.rst | 8 ++++++++ signalfx_lambda/tracing.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/README.rst b/README.rst index d6bfb4b..2468a54 100644 --- a/README.rst +++ b/README.rst @@ -121,6 +121,11 @@ To learn more, see: SIGNALFX_TRACING_URL=tracing endpoint [ default: https://ingest.signalfx.com/v1/trace ] +4. (Optional) Set environment variable to set `environment` root span tag + +.. code:: bash + SIGNALFX_ENVIRONMENT=production + Step 4: Wrap a function -------------------------- @@ -292,6 +297,9 @@ The tracing wrapper creates a span for the wrapper handler. This span contains t | component | The literal value of | | | ‘python-lambda-wrapper’ | +----------------------------------+----------------------------------+ +| environment | Environment name defined by | +| | SIGNALFX_ENVIRONMENT | ++----------------------------------+----------------------------------+ diff --git a/signalfx_lambda/tracing.py b/signalfx_lambda/tracing.py index 8e2444a..568c7b5 100644 --- a/signalfx_lambda/tracing.py +++ b/signalfx_lambda/tracing.py @@ -17,6 +17,11 @@ def call(*args, **kwargs): span_tags['component'] = 'python-lambda-wrapper' span_tags[ext_tags.SPAN_KIND] = ext_tags.SPAN_KIND_RPC_SERVER + environment = os.getenv('SIGNALFX_ENVIRONMENT') + + if environment: + span_tags['environment'] = environment + span_prefix = os.getenv('SIGNALFX_SPAN_PREFIX', 'lambda_python_') try: