Last active
May 24, 2016 20:18
-
-
Save matagus/ecec9db26db2143e196f659161bc5918 to your computer and use it in GitHub Desktop.
Revisions
-
matagus revised this gist
May 24, 2016 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
matagus revised this gist
May 24, 2016 . No changes.There are no files selected for viewing
-
matagus revised this gist
May 24, 2016 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -29,5 +29,10 @@ def process_response(self, req, resp, resource): rule = build_name_with_http_method_prefix(name, req) try: status_code = int(resp.status.split(" ")[0]) except (IndexError, TypeError): status_code = 200 if not opbeat_is_debug_mode: self.client.end_transaction(rule, status_code) -
matagus revised this gist
May 24, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ opbeat.instrumentation.control.instrument() class OpbeatAPMMiddleware(object): """ Falcon Framework middleware to track resources performance @ Opbeat """ -
matagus created this gist
May 24, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ import falcon from opbeat import Client from opbeat.middleware import Opbeat from apps.my_resource import MyResource from opbeat_middleware import OpbeatAPMMiddleware from settings import OPBEAT_ORGANIZATION_ID, OPBEAT_APP_ID, OPBEAT_SECRET_TOKEN, DEBUG client = Client( organization_id=OPBEAT_ORGANIZATION_ID, app_id=OPBEAT_APP_ID, secret_token=OPBEAT_SECRET_TOKEN, DEBUG=DEBUG, TIMEOUT=5 ) app = falcon.API( middleware=[ OpbeatAPMMiddleware(client), ... ] ) app.add_route('/path/to/some/resource/', MyResource()) app = Opbeat(app, client) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import opbeat.instrumentation.control from opbeat.utils import build_name_with_http_method_prefix from settings import DEBUG opbeat_is_debug_mode = DEBUG opbeat.instrumentation.control.instrument() class OpbeatAPM(object): """ Falcon Framework middleware to track resources performance @ Opbeat """ def __init__(self, client): self.client = client def process_request(self, req, resp): if not opbeat_is_debug_mode: self.client.begin_transaction("web.falcon") def process_response(self, req, resp, resource): name = "{}.{}".format( resource.__class__.__module__, resource.__class__.__name__ ) rule = build_name_with_http_method_prefix(name, req) if not opbeat_is_debug_mode: self.client.end_transaction(rule, req.status)