|
8 | 8 | def get_fields(context):
|
9 | 9 | function_arn = context.invoked_function_arn
|
10 | 10 |
|
11 |
| - if fields.get('aws_request_id') != context.aws_request_id: |
12 |
| - # Expected format arn:aws:lambda:us-east-1:accountId:function:functionName:$LATEST |
13 |
| - splitted = function_arn.split(':') |
| 11 | + # Expected format arn:aws:lambda:us-east-1:accountId:function:functionName:$LATEST |
| 12 | + splitted = function_arn.split(':') |
| 13 | + |
| 14 | + fields.update({ |
| 15 | + 'aws_function_version': context.function_version, |
| 16 | + 'aws_function_name': context.function_name, |
| 17 | + 'aws_region': splitted[3], |
| 18 | + 'aws_account_id': splitted[4], |
| 19 | + 'function_wrapper_version': name + '_' + version |
| 20 | + }) |
| 21 | + |
| 22 | + runtime_env = os.environ.get('AWS_EXECUTION_ENV') |
| 23 | + if runtime_env is not None: |
| 24 | + fields['aws_execution_env'] = runtime_env |
| 25 | + if splitted[5] == 'function': |
| 26 | + updatedArn = list(splitted) |
| 27 | + if len(splitted) == 8: |
| 28 | + fields['aws_function_qualifier'] = splitted[7] |
| 29 | + updatedArn[7] = context.function_version |
| 30 | + elif len(splitted) == 7: |
| 31 | + updatedArn.append(context.function_version) |
| 32 | + fields['lambda_arn'] = ':'.join(updatedArn) |
| 33 | + |
| 34 | + elif splitted[5] == 'event-source-mappings': |
| 35 | + fields['event_source_mappings'] = splitted[6] |
| 36 | + fields['lambda_arn'] = function_arn |
| 37 | + |
| 38 | + return fields.copy() |
14 | 39 |
|
| 40 | +def get_tracing_fields(): |
| 41 | + if fields.get('aws_request_id') != context.aws_request_id: |
15 | 42 | fields.update({
|
16 |
| - 'aws_request_id': context.aws_request_id, |
17 |
| - 'aws_function_version': context.function_version, |
18 |
| - 'aws_function_name': context.function_name, |
19 |
| - 'aws_region': splitted[3], |
20 |
| - 'aws_account_id': splitted[4], |
21 |
| - 'function_wrapper_version': name + '_' + version |
| 43 | + 'aws_request_id': context.aws_request_id |
22 | 44 | })
|
23 |
| - runtime_env = os.environ.get('AWS_EXECUTION_ENV') |
24 |
| - if runtime_env is not None: |
25 |
| - fields['aws_execution_env'] = runtime_env |
26 |
| - if splitted[5] == 'function': |
27 |
| - updatedArn = list(splitted) |
28 |
| - if len(splitted) == 8: |
29 |
| - fields['aws_function_qualifier'] = splitted[7] |
30 |
| - updatedArn[7] = context.function_version |
31 |
| - elif len(splitted) == 7: |
32 |
| - updatedArn.append(context.function_version) |
33 |
| - fields['lambda_arn'] = ':'.join(updatedArn) |
34 |
| - |
35 |
| - elif splitted[5] == 'event-source-mappings': |
36 |
| - fields['event_source_mappings'] = splitted[6] |
37 |
| - fields['lambda_arn'] = function_arn |
38 | 45 |
|
39 |
| - return fields.copy() |
| 46 | + return get_fields() |
40 | 47 |
|
41 | 48 |
|
42 | 49 | def get_metrics_url():
|
|
0 commit comments