Skip to content

Commit

Permalink
chore: use caret for single major version
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir committed May 11, 2024
1 parent 9d269ae commit 79f4fe8
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ One instrumentation package can potentially instrument multiple modules of diffe
### Range Syntax
Instrumentations should prefer to specify the supported versions of the instrumented package as `>=x.y.z <w` to promote consistency and readability across the code-base. This is the preferred format for specifying version ranges in the supported versions list.
Instrumentations should prefer to specify the supported versions of the instrumented package as `>=x.y.z <w` to promote consistency and readability across the code-base. This is the preferred format for specifying version ranges in the supported versions list. If Instrumentations supports just one major version of the instrumented package, it can specify the version range as `^x.y.z` or `^x`.
Instrumentation should use an upper and lower bounds for the version ranges it uses for patches. This is to ensure that any new major versions of the instrumented package are not automatically patched by the instrumentation, which could lead to unexpected behavior. Instrumentations for nodejs internal modules can specify version range of `['*']`.
Expand Down
6 changes: 4 additions & 2 deletions plugins/node/instrumentation-cucumber/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Cucumber = typeof cucumber;
type Hook = (typeof hooks)[number];
type Step = (typeof steps)[number];

const supportedVersions = ['>=8.0.0 <11'];

export class CucumberInstrumentation extends InstrumentationBase {
private module: Cucumber | undefined;

Expand All @@ -57,7 +59,7 @@ export class CucumberInstrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
'@cucumber/cucumber',
['>=8.0.0 <11'],
supportedVersions,
(moduleExports: Cucumber) => {
this.module = moduleExports;
steps.forEach(step => {
Expand All @@ -83,7 +85,7 @@ export class CucumberInstrumentation extends InstrumentationBase {
[
new InstrumentationNodeModuleFile(
'@cucumber/cucumber/lib/runtime/test_case_runner.js',
['^8.0.0', '^9.0.0', '^10.0.0'],
supportedVersions,
moduleExports => {
if (isWrapped(moduleExports.default.prototype.run)) {
this._unwrap(moduleExports.default.prototype, 'run');
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-dataloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-dataloader

## Supported Versions

[`dataloader`](https://www.npmjs.com/package/dataloader) versions `>=2.0.0 <3`
[`dataloader`](https://www.npmjs.com/package/dataloader) versions `^2.0.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DataloaderInstrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
MODULE_NAME,
['>=2.0.0 <3'],
['^2.0.0'],
dataloader => {
this._patchLoad(dataloader.prototype);
this._patchLoadMany(dataloader.prototype);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-bunyan

## Supported Versions

- [`bunyan`](https://www.npmjs.com/package/bunyan) versions `>=1.0.0 <2`
- [`bunyan`](https://www.npmjs.com/package/bunyan) versions `^1.0.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class BunyanInstrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
'bunyan',
['>=1.0.0 <2'],
['^1.0.0'],
(module: any) => {
const instrumentation = this;
const Logger =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm install --save @opentelemetry/instrumentation-http @opentelemetry/instrument

### Supported Versions

[`express`](https://www.npmjs.com/package/express) version `>=4.0.0 <5`
[`express`](https://www.npmjs.com/package/express) version `^4.0.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ExpressInstrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
'express',
['>=4.0.0 <5'],
['^4.0.0'],
moduleExports => {
const routerProto = moduleExports.Router as unknown as express.Router;
// patch express.Router.route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-generic-pool

### Supported Versions

[`generic-pool`](https://www.npmjs.com/package/generic-pool) version `>=2.0.0 <4`
[`generic-pool`](https://www.npmjs.com/package/generic-pool) version `^3.0.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Instrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
MODULE_NAME,
['>=3.0.0 <4'],
['^3.0.0'],
moduleExports => {
const Pool: any = moduleExports.Pool;
if (isWrapped(Pool.prototype.acquire)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-instrumentation-koa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install --save @opentelemetry/instrumentation-koa

### Supported Versions

- [`koa`](https://www.npmjs.com/package/koa) versions `>=2.0.0 <3`
- [`koa`](https://www.npmjs.com/package/koa) versions `^2.0.0`
- [`@koa/router`] versions `>=8.0.0`

## Usage
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-instrumentation-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-mysql

## Supported Versions

[`mysql`](https://www.npmjs.com/package/mysql) versions `<=2.0.0 <3`
[`mysql`](https://www.npmjs.com/package/mysql) versions `^2.0.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class MySQLInstrumentation extends InstrumentationBase {
return [
new InstrumentationNodeModuleDefinition(
'mysql',
['<=2.0.0 <3'],
['^2.0.0'],
(moduleExports: typeof mysqlTypes) => {
if (isWrapped(moduleExports.createConnection)) {
this._unwrap(moduleExports, 'createConnection');
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-instrumentation-pg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-pg

### Supported Versions

- [`pg`](https://www.npmjs.com/package/pg) versions `>=8.0.0 <9`
- [`pg`](https://www.npmjs.com/package/pg) versions `^8.0.0`
- [`pg-pool`](https://www.npmjs.com/package/pg-pool) versions `>=2.0.0 <4`

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class PgInstrumentation extends InstrumentationBase {
protected init() {
const modulePG = new InstrumentationNodeModuleDefinition(
'pg',
['>=8.0.0 <9'],
['^8.0.0'],
(module: any) => {
const moduleExports: typeof pgTypes =
module[Symbol.toStringTag] === 'Module'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ export const RESTIFY_METHODS = [
'patch',
];
export const MODULE_NAME = 'restify';
export const SUPPORTED_VERSIONS = ['>=4.0.0 <12'];
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { isPromise, isAsyncFunction } from './utils';
import { getRPCMetadata, RPCType } from '@opentelemetry/core';
import type { RestifyInstrumentationConfig } from './types';

const supportedVersions = ['>=4.0.0 <12'];

export class RestifyInstrumentation extends InstrumentationBase {
constructor(config: RestifyInstrumentationConfig = {}) {
super(
Expand All @@ -58,7 +60,7 @@ export class RestifyInstrumentation extends InstrumentationBase {
init() {
const module = new InstrumentationNodeModuleDefinition(
constants.MODULE_NAME,
constants.SUPPORTED_VERSIONS,
supportedVersions,
(moduleExports, moduleVersion) => {
this._moduleVersion = moduleVersion;
return moduleExports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

export const MODULE_NAME = 'router';
export const SUPPORTED_VERSIONS = ['>=1.0.0 <2'];

// Router.prototype.handle
export const ROUTE_ROUTER_FN = `function router(req, res, next) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import * as utils from './utils';
import AttributeNames from './enums/AttributeNames';
import LayerType from './enums/LayerType';

const supportedVersions = ['^1.0.0'];

export default class RouterInstrumentation extends InstrumentationBase {
constructor(config: InstrumentationConfig = {}) {
super(
Expand All @@ -48,7 +50,7 @@ export default class RouterInstrumentation extends InstrumentationBase {
init() {
const module = new InstrumentationNodeModuleDefinition(
constants.MODULE_NAME,
constants.SUPPORTED_VERSIONS,
supportedVersions,
(moduleExports, moduleVersion) => {
this._moduleVersion = moduleVersion;
return moduleExports;
Expand All @@ -58,7 +60,7 @@ export default class RouterInstrumentation extends InstrumentationBase {
module.files.push(
new InstrumentationNodeModuleFile(
'router/lib/layer.js',
constants.SUPPORTED_VERSIONS,
supportedVersions,
moduleExports => {
const Layer: any = moduleExports;
if (isWrapped(Layer.prototype.handle_request)) {
Expand Down

0 comments on commit 79f4fe8

Please sign in to comment.