-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to Trace "check" function with DD APM (#2079)
* Initial pass at trace decorator
- Loading branch information
Showing
7 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
# (C) Datadog, Inc. 2018 | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
try: | ||
import datadog_agent | ||
if datadog_agent.get_config('integration_tracing'): | ||
from ddtrace import patch | ||
patch(requests=True) | ||
except ImportError: | ||
# Tracing Integrations is only available with Agent 6 | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# (C) Datadog, Inc. 2018 | ||
# All rights reserved | ||
# Licensed under Simplified BSD License (see LICENSE) | ||
|
||
from ..config import is_affirmative | ||
from ddtrace import tracer | ||
|
||
import wrapt | ||
|
||
try: | ||
import datadog_agent | ||
except ImportError: | ||
# Integration Tracing is only available with Agent 6 | ||
datadog_agent = None | ||
|
||
|
||
_tracing_config = set() | ||
|
||
def add_trace_check(check_object): | ||
_tracing_config.add(check_object) | ||
|
||
@wrapt.decorator | ||
def traced(wrapped, instance, args, kwargs): | ||
if datadog_agent is None: | ||
return wrapped(*args, **kwargs) | ||
|
||
trace_check = instance in _tracing_config | ||
integration_tracing = is_affirmative(datadog_agent.get_config('integration_tracing')) | ||
|
||
if integration_tracing and trace_check: | ||
with tracer.trace('integration.check', service='integrations-tracing', resource=instance.name): | ||
return wrapped(*args, **kwargs) | ||
|
||
return wrapped(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
ddtrace==0.13.0 | ||
prometheus-client==0.3.0 | ||
requests==2.19.1 | ||
protobuf==3.5.1 | ||
requests==2.19.1 | ||
simplejson==3.6.5 | ||
six==1.11.0 | ||
uptime==3.0.1 | ||
uuid==1.30 | ||
six==1.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters