I am successfully using AWS Xray within a Python v2 Lambda. The patch_all()
is working well to automatically patch a portion of my libraries, i.e boto3, for Xray.
I am unable to set high level annotations that persist across the lower level subsegments. Can annotations in lambda be set like this? If not how else should they be set? I've tried getting current subsegment
and segment
.
import json
import re
import boto3
import logging
import sys
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def lambda_handler(event, context):
subsegment_ref = xray_recorder.current_subsegment()
subsegment_ref.put_annotation('account_id', 'foo')