示例#1
0
def _patch_func(parent, func_name, func, modifier=lambda x: x):
    if func_name not in parent.__dict__:
        # Ignore functions not directly defined in parent, i.e. exclude inherited ones
        return

    from aws_xray_sdk.core import xray_recorder

    capture_name = func_name
    if func_name.startswith('__') and func_name.endswith('__'):
        capture_name = '{}.{}'.format(parent.__name__, capture_name)
    setattr(parent, func_name, modifier(xray_recorder.capture(name=capture_name)(func)))
示例#2
0
 def wrapper(*args, **kwargs):
     with xray_recorder.capture(name=func.__name__):
         return func(*args, **kwargs)
示例#3
0
 def call(*args, **kwargs):
     return xray_recorder.capture(name)(func)(*args, **kwargs)
def handler(event, context):
    with xray_recorder.capture('insert_record_to_table') as subsegment:
        insert_to_table()
        response = {'statusCode': 200, 'body': json.dumps('Hello Python')}
        raise ValueError("Just an error")
        return response
def insert_to_table():
    with xray_recorder.capture('insert_record_to_table') as subsegment:
        id = generate_id()
        subsegment.put_annotation('received_id', id)
        dynamo.put_item(TableName='heroes', Item={'id': {'S': id}})
def generate_id() -> str:
    with xray_recorder.capture('generate_id') as subsegment:
        id = uuid.uuid4()
        id_as_str = str(id)
        subsegment.put_annotation('generated_id', id_as_str)
        return id_as_str