Skip to content

Commit a182256

Browse files
committed
Fix handling of FetchTracedCursor
1 parent 280c7a8 commit a182256

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

ddtrace/contrib/dbapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _trace_method(self, method, name, resource, extra_tags, *args, **kwargs):
5151
s.set_tags(extra_tags)
5252

5353
# set analytics sample rate if enabled but only for non-FetchTracedCursor
54-
if type(self) is not FetchTracedCursor:
54+
if not isinstance(self, FetchTracedCursor):
5555
s.set_tag(
5656
ANALYTICS_SAMPLE_RATE_KEY,
5757
config.dbapi2.get_analytics_sample_rate()

tests/contrib/dbapi/test_unit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ def method():
415415
assert span.get_metric('db.rowcount') == 123, 'Row count is set as a metric'
416416
assert span.get_tag('sql.rows') == '123', 'Row count is set as a tag (for legacy django cursor replacement)'
417417

418-
def test_fetch_analytics_off(self):
418+
def test_fetch_no_analytics(self):
419+
""" Confirm fetch* methods do not have analytics sample rate metric """
419420
with self.override_config(
420421
'dbapi2',
421422
dict(analytics_enabled=True)

0 commit comments

Comments
 (0)