17
17
import * as types from '../../types' ;
18
18
import * as path from 'path' ;
19
19
import * as RequireInTheMiddle from 'require-in-the-middle' ;
20
- import * as semver from 'semver' ;
20
+ import { satisfies } from 'semver' ;
21
21
import { InstrumentationAbstract } from '../../instrumentation' ;
22
22
import { InstrumentationModuleDefinition } from './types' ;
23
23
import { diag } from '@opentelemetry/api' ;
@@ -50,7 +50,7 @@ export abstract class InstrumentationBase<T = any>
50
50
if ( this . _modules . length === 0 ) {
51
51
diag . warn (
52
52
'No modules instrumentation has been defined,' +
53
- ' nothing will be patched'
53
+ ' nothing will be patched'
54
54
) ;
55
55
}
56
56
@@ -80,7 +80,7 @@ export abstract class InstrumentationBase<T = any>
80
80
// main module
81
81
if (
82
82
typeof version === 'string' &&
83
- isSupported ( module . supportedVersions , version )
83
+ isSupported ( module . supportedVersions , version , module . includePrerelease )
84
84
) {
85
85
if ( typeof module . patch === 'function' ) {
86
86
module . moduleExports = exports ;
@@ -93,7 +93,7 @@ export abstract class InstrumentationBase<T = any>
93
93
// internal file
94
94
const files = module . files ?? [ ] ;
95
95
const file = files . find ( file => file . name === name ) ;
96
- if ( file && isSupported ( file . supportedVersions , version ) ) {
96
+ if ( file && isSupported ( file . supportedVersions , version , module . includePrerelease ) ) {
97
97
file . moduleExports = exports ;
98
98
if ( this . _enabled ) {
99
99
return file . patch ( exports , module . moduleVersion ) ;
@@ -167,8 +167,8 @@ export abstract class InstrumentationBase<T = any>
167
167
}
168
168
}
169
169
170
- function isSupported ( supportedVersions : string [ ] , version : string ) : boolean {
170
+ function isSupported ( supportedVersions : string [ ] , version : string , includePrerelease ?: boolean ) : boolean {
171
171
return supportedVersions . some ( supportedVersion => {
172
- return semver . satisfies ( version , supportedVersion ) ;
172
+ return satisfies ( version , supportedVersion , { includePrerelease } ) ;
173
173
} ) ;
174
174
}
0 commit comments