Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit cac3895

Browse files
authored
Merge pull request #40 from signalfx/instrumentation-and-force-flush
Add support for auto-instrumentation and flushing spans
2 parents 75728f5 + d40a6fd commit cac3895

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

README.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,36 @@ The tracing wrapper creates a span for the wrapper handler. This span contains t
333333

334334

335335

336+
Auto-instrumentation packages
337+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338+
339+
The SignalFx Python Lambda Wrapper can automatically instrument supported packages. All you need to do is to install instrumentations you need in addition to `signalfx_lambda`. Below is a list of all instrumentation packages supported:
340+
341+
+--------------------------+----------------------------------------------------------------------------------------------------+
342+
| Library/Framework | Instrumentation Package |
343+
+==========================+====================================================================================================+
344+
| celery | `https://github.com/signalfx/python-celery/tarball/0.0.1post0#egg=celery-opentracing` |
345+
+--------------------------+----------------------------------------------------------------------------------------------------+
346+
| django | `https://github.com/signalfx/python-django/tarball/0.1.18post1#egg=django-opentracing` |
347+
+--------------------------+----------------------------------------------------------------------------------------------------+
348+
| elasticsearch | `https://github.com/signalfx/python-elasticsearch/tarball/0.1.4post#egg=elasticsearch-opentracing` |
349+
+--------------------------+----------------------------------------------------------------------------------------------------+
350+
| flask | `https://github.com/signalfx/python-flask/tarball/1.1.0post1#egg=flask_opentracing` |
351+
+--------------------------+----------------------------------------------------------------------------------------------------+
352+
| psycopg | `https://github.com/signalfx/python-dbapi/tarball/v0.0.5post1#egg=dbapi-opentracing` |
353+
+--------------------------+----------------------------------------------------------------------------------------------------+
354+
| pymongo | `https://github.com/signalfx/python-pymongo/tarball/v0.0.3post1#egg=pymongo-opentracing` |
355+
+--------------------------+----------------------------------------------------------------------------------------------------+
356+
| pymysql | `https://github.com/signalfx/python-dbapi/tarball/v0.0.5post1#egg=dbapi-opentracing` |
357+
+--------------------------+----------------------------------------------------------------------------------------------------+
358+
| redis | `https://github.com/signalfx/python-redis/tarball/v1.0.0post1#egg=redis-opentracing` |
359+
+--------------------------+----------------------------------------------------------------------------------------------------+
360+
| requests | `https://github.com/signalfx/python-requests/archive/v0.2.0post1.zip#egg=requests-opentracing` |
361+
+--------------------------+----------------------------------------------------------------------------------------------------+
362+
| tornado | `https://github.com/signalfx/python-tornado/archive/1.0.1post1.zip#egg=tornado_opentracing` |
363+
+--------------------------+----------------------------------------------------------------------------------------------------+
364+
365+
336366
Test locally
337367
^^^^^^^^^^^^^^^^^
338368
If you would like to test changes to a wrapper, run the following commands in your command line:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
signalfx>=1.0.16
2-
sfx-jaeger-client>=3.13.1b0.dev4
2+
signalfx-tracing>=1.5.1
33
six>=1.4.0

signalfx_lambda/tracing.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import opentracing
55
from opentracing.ext import tags as ext_tags
6+
from signalfx_tracing import auto_instrument
67
from jaeger_client import Config
78

89
from . import utils
@@ -33,13 +34,17 @@ def call(event, context):
3334
except BaseException as e:
3435
raise
3536
finally:
36-
tracer.close()
37+
tracer.flush()
3738

3839
return call
3940
return inner
4041

4142

4243
def init_jaeger_tracer(context):
44+
global _tracer
45+
if _tracer:
46+
return _tracer
47+
4348
endpoint = utils.get_tracing_url()
4449
service_name = os.getenv('SIGNALFX_SERVICE_NAME', context.function_name)
4550
access_token = utils.get_access_token()
@@ -63,8 +68,8 @@ def init_jaeger_tracer(context):
6368
config = Config(config=tracer_config, service_name=service_name)
6469

6570
tracer = config.new_tracer()
66-
global _tracer
6771
_tracer = opentracing.tracer = tracer
72+
auto_instrument(_tracer)
6873

6974
return tracer
7075

0 commit comments

Comments
 (0)