Skip to content

Commit

Permalink
fix: add traceparent from headers (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
cl3m0 authored Sep 12, 2024
1 parent 52f4051 commit b36194c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/pyramid_elasticapm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import elasticapm
import pkg_resources
from elasticapm.utils import get_url_dict
from elasticapm.utils.disttracing import TraceParent
from pyramid._compat import reraise
from pyramid.events import ApplicationCreated, subscriber

Expand Down Expand Up @@ -65,7 +66,9 @@ def __init__(self, handler, registry):
)

def __call__(self, request):
self.client.begin_transaction('request')
self.client.begin_transaction(
'request', TraceParent.from_headers(request.headers)
)
transaction_result = ''
response = None
try:
Expand Down
9 changes: 7 additions & 2 deletions src/pyramid_elasticapm/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def test_get(apmserver):

app = TestApp(make_app(apmserver.url))

resp = app.get('/')
resp = app.get(
url='/',
)
resp.mustcontain(b'{"status": "ok"}')

# Give the apm integration some time to send requests to the apm server
Expand All @@ -48,7 +50,10 @@ def test_post(apmserver):

app = TestApp(make_app(apmserver.url))

resp = app.post('/', dict(foo='bar'))
resp = app.post(
url='/',
params=dict(foo='bar'),
)
resp.mustcontain(b'{"status": "ok"}')

# Give the apm integration some time to send requests to the apm server
Expand Down

0 comments on commit b36194c

Please sign in to comment.