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: