@@ -196,23 +196,41 @@ var (
196196
197197func fetchShippedVersions () map [string ]string {
198198 initOnce .Do (func () {
199- versions := make (map [string ]string )
200199 _ , thisFile , _ , _ := runtime .Caller (0 )
201- // The version of dd-trace-go that shipped with the current version of orchestrion.
202- // We use this to determine if we need to upgrade dd-trace-go when pinning.
203200 orchestrionRoot := filepath .Join (thisFile , ".." , ".." , ".." )
204- ver , err := resolveDependencyVersion (orchestrionRoot , integrations .DatadogTracerV2 )
205- if err != nil {
206- panic (fmt .Errorf ("resolving %s version in %q: %w" , integrations .DatadogTracerV2 , orchestrionRoot , err ))
207- }
208- versions [integrations .DatadogTracerV2 ] = ver
209- instrumentationRoot := filepath .Join (orchestrionRoot , "instrument" )
210- ver , err = resolveDependencyVersion (instrumentationRoot , integrations .DatadogTracerV2All )
211- if err != nil {
212- panic (fmt .Errorf ("resolving %s version in %q: %w" , integrations .DatadogTracerV2All , instrumentationRoot , err ))
213- }
214- versions [integrations .DatadogTracerV2All ] = ver
201+ versions := loadShippedVersions (orchestrionRoot )
215202 orchestrionShippedVersions .Store (& versions )
216203 })
217204 return * orchestrionShippedVersions .Load ()
218205}
206+
207+ func loadShippedVersions (orchestrionRoot string ) map [string ]string {
208+ versions := make (map [string ]string )
209+
210+ // The version of dd-trace-go that shipped with the current version of orchestrion.
211+ // We use this to determine if we need to upgrade dd-trace-go when pinning.
212+ ver , err := resolveDependencyVersion (orchestrionRoot , integrations .DatadogTracerV2 )
213+ if err != nil {
214+ panic (fmt .Errorf ("resolving %s version in %q: %w" , integrations .DatadogTracerV2 , orchestrionRoot , err ))
215+ }
216+ versions [integrations .DatadogTracerV2 ] = ver
217+
218+ // Default to using the same version as DatadogTracerV2 for DatadogTracerV2All.
219+ // This serves as a fallback when the instrument directory (which is a separate submodule)
220+ // is not accessible, such as when orchestrion is used as a module dependency from the
221+ // Go module cache where nested submodules may not be present.
222+ versions [integrations .DatadogTracerV2All ] = versions [integrations .DatadogTracerV2 ]
223+
224+ // If the instrument directory exists, override with the actual version from its go.mod
225+ instrumentationRoot := filepath .Join (orchestrionRoot , "instrument" )
226+ if _ , err := os .Stat (instrumentationRoot ); err != nil {
227+ return versions
228+ }
229+ ver , err = resolveDependencyVersion (instrumentationRoot , integrations .DatadogTracerV2All )
230+ if err != nil {
231+ panic (fmt .Errorf ("resolving %s version in %q: %w" , integrations .DatadogTracerV2All , instrumentationRoot , err ))
232+ }
233+ versions [integrations .DatadogTracerV2All ] = ver
234+
235+ return versions
236+ }
0 commit comments