-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from DataDog/talwai/pylons
pylons: add autopatching
- Loading branch information
Showing
4 changed files
with
37 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
from .middleware import PylonsTraceMiddleware | ||
|
||
from ddtrace import tracer, Pin | ||
|
||
import wrapt | ||
|
||
import pylons.wsgiapp | ||
|
||
def patch(): | ||
"""Patch the instrumented Flask object | ||
""" | ||
if getattr(pylons.wsgiapp, '_datadog_patch', False): | ||
return | ||
|
||
setattr(pylons.wsgiapp, '_datadog_patch', True) | ||
|
||
wrapt.wrap_function_wrapper('pylons.wsgiapp', 'PylonsApp.__init__', traced_init) | ||
|
||
def traced_init(wrapped, instance, args, kwargs): | ||
wrapped(*args, **kwargs) | ||
|
||
service = os.environ.get("DATADOG_SERVICE_NAME") or "pylons" | ||
Pin(service=service, tracer=tracer).onto(instance) | ||
PylonsTraceMiddleware(instance, tracer, service=service) |
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