aws_xray_sdk/core/plugins/ecs_plugin.py
raw| 1 | import socket |
| 2 | import logging |
| 3 | |
| 4 | log = logging.getLogger(__name__) |
| 5 | |
| 6 | SERVICE_NAME = 'ecs' |
| 7 | ORIGIN = 'AWS::ECS::Container' |
| 8 | |
| 9 | |
| 10 | def initialize(): |
| 11 | global runtime_context |
| 12 | try: |
| 13 | runtime_context = {} |
| 14 | host_name = socket.gethostname() |
| 15 | if host_name: |
| 16 | runtime_context['container'] = host_name |
| 17 | |
| 18 | except Exception: |
| 19 | runtime_context = None |
| 20 | log.warning("failed to get ecs container metadata") |