This repository was archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Add support for qldb driver cs 273 #417
Merged
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
757c1f7
fix(fastapi): support async endpoint handlers
sagivr2020 23e9524
fix(fastapi): lint fix
sagivr2020 49e471e
fix(fastapi): test fixes
sagivr2020 59b3722
fix(fastapi): lint disable for global statement
sagivr2020 b7c3614
fix(fastapi): fix get_event_loop to support multiple python versions
sagivr2020 cb30ec9
fix(fastapi): fix current_task to support multiple python versions
sagivr2020 04c53da
fix(fastapi): fix get event loop for python 3_6
sagivr2020 089bc6a
fix(fastapi): fix lint for python 2_7
sagivr2020 3cf5e64
fix(fastapi): fix CR comments
sagivr2020 4e8727b
fix(fastapi): add to README and lint fix
sagivr2020 f27ceb2
fix(fastapi): fix CR-2 comments
sagivr2020 14595ec
add support for aws qldb driver
sagivr2020 963bae5
Merge branch 'master' into add-support-for-qldb-driver-cs-273
sagivr2020 41da418
fix lint
sagivr2020 89a87cb
fix lint
sagivr2020 016575d
add python 3.6 to be removed from acceptance tests
sagivr2020 4008566
return acceptance tests
sagivr2020 4459b82
fixes for pr review and run acceptance tests
sagivr2020 9775895
ignore python version 3_6 in run acceptance tests
sagivr2020 dd600d9
add ignore python version 3_6 in run acceptance tests
sagivr2020 217c906
ignore python version 3_6 and 2.7 in run acceptance tests
sagivr2020 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
""" | ||
pymongo events module. | ||
""" | ||
|
||
from __future__ import absolute_import | ||
from uuid import uuid4 | ||
import traceback | ||
|
||
from epsagon.utils import add_data_if_needed | ||
from ..event import BaseEvent | ||
from ..trace import trace_factory | ||
|
||
|
||
class QldbEvent(BaseEvent): | ||
""" | ||
Represents base pymongo event. | ||
""" | ||
|
||
ORIGIN = 'qldb' | ||
RESOURCE_TYPE = 'qldb' | ||
|
||
#pylint: disable=W0613 | ||
def __init__(self, wrapped, instance, args, kwargs, start_time, response, | ||
exception): | ||
""" | ||
Initialize. | ||
:param wrapped: wrapt's wrapped | ||
:param instance: wrapt's instance | ||
:param args: wrapt's args | ||
:param kwargs: wrapt's kwargs | ||
:param start_time: Start timestamp (epoch) | ||
:param response: response data | ||
:param exception: Exception (if happened) | ||
""" | ||
super(QldbEvent, self).__init__(start_time) | ||
|
||
self.event_id = 'qldb-{}'.format(str(uuid4())) | ||
self.resource['name'] = \ | ||
getattr(instance.__getattribute__('_transaction')._session,# pylint: disable=W0212 | ||
'_ledger_name') | ||
self.resource['operation'] = wrapped.__func__.__name__ | ||
|
||
self.resource['metadata']['query'] = args[0] | ||
add_data_if_needed(self.resource['metadata'], 'parameters', | ||
[args[i] for i in range(1, len(args))]) | ||
|
||
add_data_if_needed(self.resource['metadata'], 'transaction_id', | ||
getattr(instance, 'transaction_id')) | ||
|
||
if response is not None: | ||
self.update_response(response) | ||
|
||
if exception is not None: | ||
self.set_exception(exception, traceback.format_exc()) | ||
|
||
|
||
def update_response(self, response): | ||
""" | ||
Adds response data to event. | ||
:param response: Response from botocore | ||
:return: None | ||
""" | ||
|
||
self.resource['metadata']['Results'] = [str(x) for x in response] | ||
self.resource['metadata']['response.consumed_information'] = \ | ||
response.get_consumed_ios() | ||
self.resource['metadata']['response.timing_information'] = \ | ||
response.get_timing_information() | ||
|
||
|
||
|
||
class QldbEventFactory(object): | ||
""" | ||
Factory class, generates Qldb event. | ||
""" | ||
|
||
@staticmethod | ||
def create_event(wrapped, instance, args, kwargs, start_time, response, | ||
exception): | ||
""" | ||
Create a Qldb event. | ||
:param wrapped: | ||
:param instance: | ||
:param args: | ||
:param kwargs: | ||
:param start_time: | ||
:param response: | ||
:param exception: | ||
:return: | ||
""" | ||
event = QldbEvent( | ||
wrapped, | ||
instance, | ||
args, | ||
kwargs, | ||
start_time, | ||
response, | ||
exception | ||
) | ||
trace_factory.add_event(event) |
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,31 @@ | ||
""" | ||
pymysql patcher module | ||
""" | ||
from __future__ import absolute_import | ||
import wrapt | ||
from epsagon.modules.general_wrapper import wrapper | ||
from ..events.pyqldb import QldbEventFactory | ||
|
||
|
||
def _wrapper(wrapped, instance, args, kwargs): | ||
""" | ||
General wrapper for PynamoDB instrumentation. | ||
:param wrapped: wrapt's wrapped | ||
:param instance: wrapt's instance | ||
:param args: wrapt's args | ||
:param kwargs: wrapt's kwargs | ||
:return: None | ||
""" | ||
return wrapper(QldbEventFactory, wrapped, instance, args, kwargs) | ||
|
||
|
||
def patch(): | ||
""" | ||
patch module. | ||
:return: None | ||
""" | ||
wrapt.wrap_function_wrapper( | ||
'pyqldb.execution.executor', | ||
'Executor.execute_statement', | ||
_wrapper | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyqldb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed