Skip to content

Commit 1160adf

Browse files
committed
add automatic endpoint configuration for lambda environments
1 parent a5d1b0c commit 1160adf

File tree

1 file changed

+5
-0
lines changed
  • exporters/aws-otel-otlp-udp-exporter/src/amazon/opentelemetry/exporters/otlp/udp

1 file changed

+5
-0
lines changed

exporters/aws-otel-otlp-udp-exporter/src/amazon/opentelemetry/exporters/otlp/udp/exporter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
import os
34
import base64
45
import socket
56
from logging import Logger, getLogger
@@ -29,6 +30,10 @@
2930

3031
class UdpExporter:
3132
def __init__(self, endpoint: Optional[str] = None):
33+
if endpoint is None and "AWS_LAMBDA_FUNCTION_NAME" in os.environ:
34+
# If in an AWS Lambda Environment, `AWS_XRAY_DAEMON_ADDRESS` will be defined
35+
endpoint = os.environ.get("AWS_XRAY_DAEMON_ADDRESS", DEFAULT_ENDPOINT)
36+
3237
self._endpoint = endpoint or DEFAULT_ENDPOINT
3338
self._host, self._port = self._parse_endpoint(self._endpoint)
3439
self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

0 commit comments

Comments
 (0)