in lib/receiver-lambda/receiver-lambda.py [0:0]
def handler(event, context):
log.getLogger().setLevel(log.INFO)
global aws_request_id
aws_request_id = context.aws_request_id
topic = context.client_context.custom['subject']
log.info('Received message from topic: {0} with payload:\n {1}'.format(
topic, json.dumps(event, indent=4)))
deviceId = topic.split('/')[-1]
metrics = event
key_prefix = deviceId
metrics['timestamp'] = int(metrics['timestamp'])
end_time = int(time.time())
start_time = end_time - 3600
store_metrics(key_prefix, metrics, start_time)
topic = 'metrics/stored/{}'.format(deviceId)
message = {'upstream-request-id': aws_request_id}
callDownstreamLambda(topic, message)