Skip to content

Commit 2a96bf0

Browse files
committed
Fix transaction name and add more docs about sampling
1 parent 722358f commit 2a96bf0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

elasticapm/instrumentation/packages/base.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,17 @@ def call_if_sampling(self, module, method, wrapped, instance, args, kwargs):
176176
This is the function which will wrap the instrumented method/function.
177177
178178
By default, will call the instrumented method/function, via `call()`,
179-
only if a transaction is active. This behavior can be overridden by
180-
setting `creates_transactions = True` at the class level.
179+
only if a transaction is active and sampled. This behavior can be
180+
overridden by setting `creates_transactions = True` at the class
181+
level.
182+
183+
If `creates_transactions == False` and there's an active transaction
184+
with `transaction.is_sampled == False`, then the
185+
`mutate_unsampled_call_args()` method is called, and the resulting
186+
args and kwargs are passed into the wrapped function directly, not
187+
via `call()`. This can e.g. be used to add traceparent headers to the
188+
underlying http call for HTTP instrumentations, even if we're not
189+
sampling the transaction.
181190
"""
182191
if self.creates_transactions:
183192
return self.call(module, method, wrapped, instance, args, kwargs)

elasticapm/instrumentation/packages/tornado.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def call(self, module, method, wrapped, instance, args, kwargs):
5454
),
5555
"request",
5656
)
57-
elasticapm.set_transaction_name("{} {}".format(request.method, request.path), override=False)
57+
elasticapm.set_transaction_name("{} {}".format(request.method, type(instance)), override=False)
5858

5959
ret = await wrapped(*args, **kwargs)
6060

0 commit comments

Comments
 (0)