1
1
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
3
import os
4
+ import sys
5
+ from logging import Logger , getLogger
4
6
5
7
from amazon .opentelemetry .distro .patches ._instrumentation_patch import apply_instrumentation_patches
6
8
from opentelemetry .distro import OpenTelemetryDistro
10
12
OTEL_EXPORTER_OTLP_PROTOCOL ,
11
13
)
12
14
15
+ _logger : Logger = getLogger (__name__ )
16
+
13
17
14
18
class AwsOpenTelemetryDistro (OpenTelemetryDistro ):
15
19
def _configure (self , ** kwargs ):
@@ -36,6 +40,21 @@ def _configure(self, **kwargs):
36
40
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION environment variable. Need to work with upstream to
37
41
make it to be configurable.
38
42
"""
43
+
44
+ # Issue: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2495
45
+ # mimicking what is done here: https://tinyurl.com/54mvzmte
46
+ # For handling applications like django running in containers, we are setting the current working directory
47
+ # to the sys.path for the django application to find its executables.
48
+ #
49
+ # Note that we are updating the sys.path and not the PYTHONPATH env var, because once sys.path is
50
+ # loaded upon process start, it doesn't refresh from the PYTHONPATH value.
51
+ #
52
+ # To be removed once the issue has been fixed in https://github.com/open-telemetry/opentelemetry-python-contrib
53
+ cwd_path = os .getcwd ()
54
+ _logger .debug ("Current working directory path: %s" , cwd_path )
55
+ if cwd_path not in sys .path :
56
+ sys .path .insert (0 , cwd_path )
57
+
39
58
os .environ .setdefault (OTEL_EXPORTER_OTLP_PROTOCOL , "http/protobuf" )
40
59
41
60
super (AwsOpenTelemetryDistro , self )._configure ()
0 commit comments