Skip to content

Commit a0461fc

Browse files
committed
handle if CORECLR_PROFILER_PATH is already set
1 parent 7a1b0fa commit a0461fc

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

scripts/datadog_wrapper

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,38 @@ if [[ "$AWS_EXECUTION_ENV" == *"dotnet"* ]]
4949
then
5050
debug_log "Configuring for the .NET runtime!"
5151

52-
# Handle CORECLR_PROFILER_PATH: try to load the library from these paths, in order:
53-
PROFILER_PATHS=(
54-
# use the shared loader if it's present
55-
"/opt/datadog/linux-x64/Datadog.Trace.ClrProfiler.Native.so"
56-
"/opt/datadog/linux-arm64/Datadog.Trace.ClrProfiler.Native.so"
57-
# if shared loader is not found, use the tracer library directly (not recommended)
58-
"/opt/datadog/linux-x64/Datadog.Tracer.Native.so"
59-
"/opt/datadog/linux-arm64/Datadog.Tracer.Native.so"
60-
# keep this as a fallback for backwards compatibility with older .NET layers
61-
"/opt/datadog/Datadog.Trace.ClrProfiler.Native.so"
62-
)
63-
64-
PROFILER_FOUND=false
65-
66-
## Search from all possible places
67-
for PROFILER_PATH in "${PROFILER_PATHS[@]}"
68-
do
69-
if [ -f "$PROFILER_PATH" ]
70-
then
71-
export CORECLR_PROFILER_PATH="$PROFILER_PATH"
72-
PROFILER_FOUND=true
73-
break
74-
fi
75-
done
76-
77-
if [ $PROFILER_FOUND == false ]
78-
then
79-
echo ".NET library not found. APM instrumentation may not work correctly."
52+
if [ -n "$CORECLR_PROFILER_PATH" ]; then
53+
debug_log "CORECLR_PROFILER_PATH is already set to $CORECLR_PROFILER_PATH"
54+
else
55+
# Handle CORECLR_PROFILER_PATH: try to load the library from these paths, in order:
56+
PROFILER_PATHS=(
57+
# use the shared loader if it's present
58+
"/opt/datadog/linux-x64/Datadog.Trace.ClrProfiler.Native.so"
59+
"/opt/datadog/linux-arm64/Datadog.Trace.ClrProfiler.Native.so"
60+
# if shared loader is not found, use the tracer library directly (not recommended)
61+
"/opt/datadog/linux-x64/Datadog.Tracer.Native.so"
62+
"/opt/datadog/linux-arm64/Datadog.Tracer.Native.so"
63+
# keep this as a fallback for backwards compatibility with older .NET layers
64+
"/opt/datadog/Datadog.Trace.ClrProfiler.Native.so"
65+
)
66+
67+
PROFILER_FOUND=false
68+
69+
## Search from all possible places
70+
for PROFILER_PATH in "${PROFILER_PATHS[@]}"
71+
do
72+
if [ -f "$PROFILER_PATH" ]
73+
then
74+
export CORECLR_PROFILER_PATH="$PROFILER_PATH"
75+
PROFILER_FOUND=true
76+
break
77+
fi
78+
done
79+
80+
if [ $PROFILER_FOUND == false ]
81+
then
82+
echo ".NET library not found. APM instrumentation may not work correctly."
83+
fi
8084
fi
8185

8286
# Required environment variables for .NET library

0 commit comments

Comments
 (0)