diff --git a/Dockerfile b/Dockerfile
index 0bc70d596f20de97e9292bed781c4309a0e3703b..6d4a83b837bbb54090c2780b265c281ee689dbfb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -115,6 +115,7 @@ RUN cd MUST-v${MUST_VERSION} && \
     patch externals/typeart/scripts/typeart-wrapper.in < /patches/typeart-fpic.patch && \
     patch modules/MpiTypeArt/MpiTypeArt.cpp < /patches/typeart-output.patch && \
     patch -p1 < /patches/relative-paths.patch && \
+    patch -p1 < /patches/stack-path-depth.patch && \
     cd build && \
     CC=clang CXX=clang++ MPICH_CC=clang MPICH_CXX=clang++ OMPI_CC=clang OMPI_CXX=clang \
       cmake .. -DCMAKE_INSTALL_PREFIX=/opt/must -DUSE_BACKWARD=ON -DENABLE_TESTS=ON -DENABLE_FORTRAN=ON -DLLVM_FILECHECK_PATH=$(which FileCheck) -DCMAKE_BUILD_TYPE=Release && \
diff --git a/patches/stack-path-depth.patch b/patches/stack-path-depth.patch
new file mode 100644
index 0000000000000000000000000000000000000000..32d10060412eacbe3b8c88a828bc46c0ff3366f3
--- /dev/null
+++ b/patches/stack-path-depth.patch
@@ -0,0 +1,75 @@
+diff --git a/modules/MustBase/InitLocationId.cpp b/modules/MustBase/InitLocationId.cpp
+index 202cf077..184b61f7 100644
+--- a/modules/MustBase/InitLocationId.cpp
++++ b/modules/MustBase/InitLocationId.cpp
+@@ -72,6 +72,12 @@ InitLocationId::InitLocationId(const char* instanceName)
+                    << std::endl;
+         assert(0);
+     }
++
++    myStackPathDepth = -1;
++    const char* depth_str = std::getenv("MUST_STACKTRACE_PATH_DEPTH");
++    if (depth_str != nullptr) {
++        myStackPathDepth = std::atoi(depth_str);
++    }
+ }
+ 
+ //=============================
+@@ -90,6 +96,31 @@ InitLocationId::~InitLocationId()
+     }
+ }
+ 
++std::string InitLocationId::truncatePath(int height, std::string path)
++{
++    if (height <= 0)
++        return std::string(path);
++
++    auto rit = path.rbegin();
++    std::string::size_type pos = path.length();
++    int path_separator_count = 0;
++    // search for path separators backwards and abort if height is reached
++    while (path_separator_count < height) {
++        pos = path.rfind('/', pos - 1);
++        if (pos == std::string::npos) {
++            pos = 0;
++            break;
++        } else {
++            path_separator_count++;
++        }
++    }
++
++    if (pos > 0) // prepend truncation sequence
++        return "[...]" + path.substr(pos, path.length());
++    else
++        return std::string(path);
++}
++
+ //=============================
+ // init
+ //=============================
+@@ -186,7 +217,7 @@ GTI_ANALYSIS_RETURN InitLocationId::init(MustLocationId* pStorage, const char* c
+                 thisFullLocation.stack.emplace_back(trace.object_filename, trace.object_function);
+             } else {
+                 thisFullLocation.stack.emplace_back(
+-                    trace.source.filename,
++                    truncatePath(myStackPathDepth, trace.source.filename),
+                     trace.source.function,
+                     std::to_string(trace.source.line));
+             }
+diff --git a/modules/MustBase/InitLocationId.h b/modules/MustBase/InitLocationId.h
+index 2aee6407..d1fdc01f 100644
+--- a/modules/MustBase/InitLocationId.h
++++ b/modules/MustBase/InitLocationId.h
+@@ -68,6 +68,10 @@ class InitLocationId : public gti::ModuleBase<InitLocationId, I_InitLocationId>
+     I_GenerateLocationId* myGenLId;
+     handleNewLocationP myNewLocFct;
+ 
++  private:
++    int myStackPathDepth;
++    std::string truncatePath(int length, std::string path);
++
+ #ifdef ENABLE_STACKTRACE
+     /**
+      * Helper function to call the handleNewLocation call when we use the callpath module
+-- 
+2.39.1
\ No newline at end of file