From b9581fe5242db6c880e306f7e0c16ae276a6451b Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Apr 2024 13:59:21 +0200 Subject: [PATCH 1/4] feat(http): Allow to opt-out of instrumenting incoming/outgoing requests --- .../README.md | 2 + .../src/http.ts | 114 ++++++++++++------ .../src/types.ts | 4 + .../test/functionals/http-enable.test.ts | 35 ++++++ .../test/functionals/https-enable.test.ts | 36 ++++++ 5 files changed, 153 insertions(+), 38 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-http/README.md b/experimental/packages/opentelemetry-instrumentation-http/README.md index 73b43d5b71..50f0f54111 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/README.md +++ b/experimental/packages/opentelemetry-instrumentation-http/README.md @@ -61,6 +61,8 @@ Http instrumentation has few options available to choose from. You can set the f | [`startOutgoingSpanHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L99) | `StartOutgoingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in outgoingRequest | | `ignoreIncomingRequestHook` | `IgnoreIncomingRequestFunction` | Http instrumentation will not trace all incoming requests that matched with custom function | | `ignoreOutgoingRequestHook` | `IgnoreOutgoingRequestFunction` | Http instrumentation will not trace all outgoing requests that matched with custom function | +| `instrumentOutgoingRequests` | `boolean` | Set to false to avoid instrumenting outgoing requests at all. | +| `instrumentIncomingRequests` | `boolean` | Set to false to avoid instrumenting incoming requests at all. | | [`serverName`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L101) | `string` | The primary server name of the matched virtual host. | | [`requireParentforOutgoingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L103) | Boolean | Require that is a parent span to create new span for outgoing requests. | | [`requireParentforIncomingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L105) | Boolean | Require that is a parent span to create new span for incoming requests. | diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts index a42927fff5..7cec07d50f 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts @@ -109,30 +109,50 @@ export class HttpInstrumentation extends InstrumentationBase { - this._wrap( - moduleExports, - 'request', - this._getPatchOutgoingRequestFunction('http') - ); - this._wrap( - moduleExports, - 'get', - this._getPatchOutgoingGetFunction(moduleExports.request) - ); - this._wrap( - moduleExports.Server.prototype, - 'emit', - this._getPatchIncomingRequestFunction('http') - ); + moduleExports => { + this._diag.debug(`Applying patch for http@${version}`); + if (this._getConfig().instrumentOutgoingRequests !== false) { + if (isWrapped(moduleExports.request)) { + this._unwrap(moduleExports, 'request'); + } + + this._wrap( + moduleExports, + 'request', + this._getPatchOutgoingRequestFunction('http') + ); + + if (isWrapped(moduleExports.get)) { + this._unwrap(moduleExports, 'get'); + } + this._wrap( + moduleExports, + 'get', + this._getPatchOutgoingGetFunction(moduleExports.request) + ); + if (isWrapped(moduleExports.Server.prototype.emit)) { + this._unwrap(moduleExports.Server.prototype, 'emit'); + } + } + if (this._getConfig().instrumentIncomingRequests !== false) { + this._wrap( + moduleExports.Server.prototype, + 'emit', + this._getPatchIncomingRequestFunction('http') + ); + } return moduleExports; }, (moduleExports: Http) => { if (moduleExports === undefined) return; - this._unwrap(moduleExports, 'request'); - this._unwrap(moduleExports, 'get'); - this._unwrap(moduleExports.Server.prototype, 'emit'); + if (this._getConfig().instrumentOutgoingRequests !== false) { + this._unwrap(moduleExports, 'request'); + this._unwrap(moduleExports, 'get'); + } + if (this._getConfig().instrumentIncomingRequests !== false) { + this._unwrap(moduleExports.Server.prototype, 'emit'); + } } ); } @@ -141,30 +161,48 @@ export class HttpInstrumentation extends InstrumentationBase { - this._wrap( - moduleExports, - 'request', - this._getPatchHttpsOutgoingRequestFunction('https') - ); - this._wrap( - moduleExports, - 'get', - this._getPatchHttpsOutgoingGetFunction(moduleExports.request) - ); - this._wrap( - moduleExports.Server.prototype, - 'emit', - this._getPatchIncomingRequestFunction('https') - ); + moduleExports => { + this._diag.debug(`Applying patch for https@${version}`); + if (this._getConfig().instrumentOutgoingRequests !== false) { + if (isWrapped(moduleExports.request)) { + this._unwrap(moduleExports, 'request'); + } + this._wrap( + moduleExports, + 'request', + this._getPatchHttpsOutgoingRequestFunction('https') + ); + if (isWrapped(moduleExports.get)) { + this._unwrap(moduleExports, 'get'); + } + this._wrap( + moduleExports, + 'get', + this._getPatchHttpsOutgoingGetFunction(moduleExports.request) + ); + } + if (this._getConfig().instrumentIncomingRequests !== false) { + if (isWrapped(moduleExports.Server.prototype.emit)) { + this._unwrap(moduleExports.Server.prototype, 'emit'); + } + this._wrap( + moduleExports.Server.prototype, + 'emit', + this._getPatchIncomingRequestFunction('https') + ); + } return moduleExports; }, (moduleExports: Https) => { if (moduleExports === undefined) return; - this._unwrap(moduleExports, 'request'); - this._unwrap(moduleExports, 'get'); - this._unwrap(moduleExports.Server.prototype, 'emit'); + if (this._getConfig().instrumentOutgoingRequests !== false) { + this._unwrap(moduleExports, 'request'); + this._unwrap(moduleExports, 'get'); + } + if (this._getConfig().instrumentIncomingRequests !== false) { + this._unwrap(moduleExports.Server.prototype, 'emit'); + } } ); } diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts index 5cc09341d4..f5e3a42b2e 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts @@ -98,6 +98,10 @@ export interface HttpInstrumentationConfig extends InstrumentationConfig { ignoreOutgoingUrls?: IgnoreMatcher[]; /** Not trace all outgoing requests that matched with custom function */ ignoreOutgoingRequestHook?: IgnoreOutgoingRequestFunction; + /** If set to false, incoming requests will not be instrumented at all. */ + instrumentIncomingRequests?: boolean; + /** If set to false, outgoing requests will not be instrumented at all. */ + instrumentOutgoingRequests?: boolean; /** Function for adding custom attributes after response is handled */ applyCustomAttributesOnSpan?: HttpCustomAttributeFunction; /** Function for adding custom attributes before request is handled */ diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 414b1aeb81..9d615f53c3 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -227,6 +227,41 @@ describe('HttpInstrumentation', () => { }); }); + it('allows to disable outgoing request instrumentation', () => { + server.close(); + instrumentation.disable(); + + instrumentation.setConfig({ + instrumentOutgoingRequests: false, + }); + instrumentation.enable(); + server = http.createServer((_request, response) => { + response.end('Test Server Response'); + }); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), true); + assert.strictEqual(isWrapped(http.get), false); + assert.strictEqual(isWrapped(http.request), false); + }); + + it('allows to disable incoming request instrumentation', () => { + instrumentation.setConfig({ + instrumentIncomingRequests: false, + }); + instrumentation.enable(); + server = http.createServer((_request, response) => { + response.end('Test Server Response'); + }); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), false); + assert.strictEqual(isWrapped(http.get), true); + assert.strictEqual(isWrapped(http.request), true); + }); + describe('with good instrumentation options', () => { beforeEach(() => { memoryExporter.reset(); diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts index ae6358cfbc..d92cfedc48 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts @@ -184,6 +184,42 @@ describe('HttpsInstrumentation', () => { ); }); }); + + it('allows to disable outgoing request instrumentation', () => { + server.close(); + instrumentation.disable(); + + instrumentation.setConfig({ + instrumentOutgoingRequests: false, + }); + instrumentation.enable(); + server = https.createServer((_request, response) => { + response.end('Test Server Response'); + }); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), true); + assert.strictEqual(isWrapped(http.get), false); + assert.strictEqual(isWrapped(http.request), false); + }); + + it('allows to disable incoming request instrumentation', () => { + instrumentation.setConfig({ + instrumentIncomingRequests: false, + }); + instrumentation.enable(); + server = https.createServer((_request, response) => { + response.end('Test Server Response'); + }); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), false); + assert.strictEqual(isWrapped(http.get), true); + assert.strictEqual(isWrapped(http.request), true); + }); + describe('with good instrumentation options', () => { beforeEach(() => { memoryExporter.reset(); From 3d6f8eceb92389e52211080101370418969f5020 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Apr 2024 14:44:58 +0200 Subject: [PATCH 2/4] fix tests --- .../test/functionals/http-enable.test.ts | 64 +++++++------ .../test/functionals/https-enable.test.ts | 90 +++++++++++-------- 2 files changed, 94 insertions(+), 60 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 9d615f53c3..ad14544978 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -227,39 +227,53 @@ describe('HttpInstrumentation', () => { }); }); - it('allows to disable outgoing request instrumentation', () => { - server.close(); - instrumentation.disable(); - - instrumentation.setConfig({ - instrumentOutgoingRequests: false, + describe('partially disable instrumentation', () => { + beforeEach(() => { + memoryExporter.reset(); }); - instrumentation.enable(); - server = http.createServer((_request, response) => { - response.end('Test Server Response'); + + afterEach(() => { + server.close(); + instrumentation.disable(); }); - server.listen(serverPort); + it('allows to disable outgoing request instrumentation', () => { + server.close(); + instrumentation.disable(); - assert.strictEqual(isWrapped(http.Server.prototype.emit), true); - assert.strictEqual(isWrapped(http.get), false); - assert.strictEqual(isWrapped(http.request), false); - }); + instrumentation.setConfig({ + instrumentOutgoingRequests: false, + }); + instrumentation.enable(); + server = http.createServer((_request, response) => { + response.end('Test Server Response'); + }); - it('allows to disable incoming request instrumentation', () => { - instrumentation.setConfig({ - instrumentIncomingRequests: false, - }); - instrumentation.enable(); - server = http.createServer((_request, response) => { - response.end('Test Server Response'); + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), true); + assert.strictEqual(isWrapped(http.get), false); + assert.strictEqual(isWrapped(http.request), false); }); - server.listen(serverPort); + it('allows to disable incoming request instrumentation', () => { + server.close(); + instrumentation.disable(); + + instrumentation.setConfig({ + instrumentIncomingRequests: false, + }); + instrumentation.enable(); + server = http.createServer((_request, response) => { + response.end('Test Server Response'); + }); - assert.strictEqual(isWrapped(http.Server.prototype.emit), false); - assert.strictEqual(isWrapped(http.get), true); - assert.strictEqual(isWrapped(http.request), true); + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), false); + assert.strictEqual(isWrapped(http.get), true); + assert.strictEqual(isWrapped(http.request), true); + }); }); describe('with good instrumentation options', () => { diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts index d92cfedc48..6605194cde 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts @@ -185,41 +185,6 @@ describe('HttpsInstrumentation', () => { }); }); - it('allows to disable outgoing request instrumentation', () => { - server.close(); - instrumentation.disable(); - - instrumentation.setConfig({ - instrumentOutgoingRequests: false, - }); - instrumentation.enable(); - server = https.createServer((_request, response) => { - response.end('Test Server Response'); - }); - - server.listen(serverPort); - - assert.strictEqual(isWrapped(http.Server.prototype.emit), true); - assert.strictEqual(isWrapped(http.get), false); - assert.strictEqual(isWrapped(http.request), false); - }); - - it('allows to disable incoming request instrumentation', () => { - instrumentation.setConfig({ - instrumentIncomingRequests: false, - }); - instrumentation.enable(); - server = https.createServer((_request, response) => { - response.end('Test Server Response'); - }); - - server.listen(serverPort); - - assert.strictEqual(isWrapped(http.Server.prototype.emit), false); - assert.strictEqual(isWrapped(http.get), true); - assert.strictEqual(isWrapped(http.request), true); - }); - describe('with good instrumentation options', () => { beforeEach(() => { memoryExporter.reset(); @@ -740,5 +705,60 @@ describe('HttpsInstrumentation', () => { req.end(); }); }); + + describe('partially disable instrumentation', () => { + beforeEach(() => { + memoryExporter.reset(); + }); + + afterEach(() => { + server.close(); + instrumentation.disable(); + }); + + it('allows to disable outgoing request instrumentation', () => { + instrumentation.setConfig({ + instrumentOutgoingRequests: false, + }); + instrumentation.enable(); + server = https.createServer( + { + key: fs.readFileSync('test/fixtures/server-key.pem'), + cert: fs.readFileSync('test/fixtures/server-cert.pem'), + }, + (request, response) => { + response.end('Test Server Response'); + } + ); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), true); + assert.strictEqual(isWrapped(http.get), false); + assert.strictEqual(isWrapped(http.request), false); + }); + + it('allows to disable incoming request instrumentation', () => { + instrumentation.setConfig({ + instrumentIncomingRequests: false, + }); + instrumentation.enable(); + server = https.createServer( + { + key: fs.readFileSync('test/fixtures/server-key.pem'), + cert: fs.readFileSync('test/fixtures/server-cert.pem'), + }, + (request, response) => { + response.end('Test Server Response'); + } + ); + + server.listen(serverPort); + + assert.strictEqual(isWrapped(http.Server.prototype.emit), false); + assert.strictEqual(isWrapped(http.get), true); + assert.strictEqual(isWrapped(http.request), true); + }); + }); }); }); From 321f07cdc58446961c10866137306740c9642af6 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Jul 2024 11:35:01 +0200 Subject: [PATCH 3/4] PR feedback --- .../README.md | 4 +- .../src/http.ts | 43 +++++-------------- .../src/types.ts | 8 ++-- .../test/functionals/http-enable.test.ts | 4 +- .../test/functionals/https-enable.test.ts | 4 +- package-lock.json | 20 ++++----- 6 files changed, 31 insertions(+), 52 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-http/README.md b/experimental/packages/opentelemetry-instrumentation-http/README.md index 50f0f54111..530205ac77 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/README.md +++ b/experimental/packages/opentelemetry-instrumentation-http/README.md @@ -61,8 +61,8 @@ Http instrumentation has few options available to choose from. You can set the f | [`startOutgoingSpanHook`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L99) | `StartOutgoingSpanCustomAttributeFunction` | Function for adding custom attributes before a span is started in outgoingRequest | | `ignoreIncomingRequestHook` | `IgnoreIncomingRequestFunction` | Http instrumentation will not trace all incoming requests that matched with custom function | | `ignoreOutgoingRequestHook` | `IgnoreOutgoingRequestFunction` | Http instrumentation will not trace all outgoing requests that matched with custom function | -| `instrumentOutgoingRequests` | `boolean` | Set to false to avoid instrumenting outgoing requests at all. | -| `instrumentIncomingRequests` | `boolean` | Set to false to avoid instrumenting incoming requests at all. | +| `disableOutgoingRequestInstrumentation` | `boolean` | Set to true to avoid instrumenting outgoing requests at all. This can be helpful when another instrumentation handles outgoing requests. | +| `disableIncomingRequestInstrumentation` | `boolean` | Set to true to avoid instrumenting incoming requests at all. This can be helpful when another instrumentation handles incoming requests. | | [`serverName`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L101) | `string` | The primary server name of the matched virtual host. | | [`requireParentforOutgoingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L103) | Boolean | Require that is a parent span to create new span for outgoing requests. | | [`requireParentforIncomingSpans`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/types.ts#L105) | Boolean | Require that is a parent span to create new span for incoming requests. | diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts index 7cec07d50f..226c4ac86b 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts @@ -109,32 +109,20 @@ export class HttpInstrumentation extends InstrumentationBase { - this._diag.debug(`Applying patch for http@${version}`); - if (this._getConfig().instrumentOutgoingRequests !== false) { - if (isWrapped(moduleExports.request)) { - this._unwrap(moduleExports, 'request'); - } - + (moduleExports: Http): Http => { + if (!this.getConfig().disableOutgoingRequestInstrumentation) { this._wrap( moduleExports, 'request', this._getPatchOutgoingRequestFunction('http') ); - - if (isWrapped(moduleExports.get)) { - this._unwrap(moduleExports, 'get'); - } this._wrap( moduleExports, 'get', this._getPatchOutgoingGetFunction(moduleExports.request) ); - if (isWrapped(moduleExports.Server.prototype.emit)) { - this._unwrap(moduleExports.Server.prototype, 'emit'); - } } - if (this._getConfig().instrumentIncomingRequests !== false) { + if (!this.getConfig().disableIncomingRequestInstrumentation) { this._wrap( moduleExports.Server.prototype, 'emit', @@ -146,11 +134,11 @@ export class HttpInstrumentation extends InstrumentationBase { if (moduleExports === undefined) return; - if (this._getConfig().instrumentOutgoingRequests !== false) { + if (!this.getConfig().disableOutgoingRequestInstrumentation) { this._unwrap(moduleExports, 'request'); this._unwrap(moduleExports, 'get'); } - if (this._getConfig().instrumentIncomingRequests !== false) { + if (!this.getConfig().disableIncomingRequestInstrumentation) { this._unwrap(moduleExports.Server.prototype, 'emit'); } } @@ -161,30 +149,21 @@ export class HttpInstrumentation extends InstrumentationBase { - this._diag.debug(`Applying patch for https@${version}`); - if (this._getConfig().instrumentOutgoingRequests !== false) { - if (isWrapped(moduleExports.request)) { - this._unwrap(moduleExports, 'request'); - } + (moduleExports: Https): Https => { + if (!this.getConfig().disableOutgoingRequestInstrumentation) { this._wrap( moduleExports, 'request', this._getPatchHttpsOutgoingRequestFunction('https') ); - if (isWrapped(moduleExports.get)) { - this._unwrap(moduleExports, 'get'); - } + this._wrap( moduleExports, 'get', this._getPatchHttpsOutgoingGetFunction(moduleExports.request) ); } - if (this._getConfig().instrumentIncomingRequests !== false) { - if (isWrapped(moduleExports.Server.prototype.emit)) { - this._unwrap(moduleExports.Server.prototype, 'emit'); - } + if (!this.getConfig().disableIncomingRequestInstrumentation) { this._wrap( moduleExports.Server.prototype, 'emit', @@ -196,11 +175,11 @@ export class HttpInstrumentation extends InstrumentationBase { if (moduleExports === undefined) return; - if (this._getConfig().instrumentOutgoingRequests !== false) { + if (!this.getConfig().disableOutgoingRequestInstrumentation) { this._unwrap(moduleExports, 'request'); this._unwrap(moduleExports, 'get'); } - if (this._getConfig().instrumentIncomingRequests !== false) { + if (!this.getConfig().disableIncomingRequestInstrumentation) { this._unwrap(moduleExports.Server.prototype, 'emit'); } } diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts index f5e3a42b2e..a0e783a1bd 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts @@ -98,10 +98,10 @@ export interface HttpInstrumentationConfig extends InstrumentationConfig { ignoreOutgoingUrls?: IgnoreMatcher[]; /** Not trace all outgoing requests that matched with custom function */ ignoreOutgoingRequestHook?: IgnoreOutgoingRequestFunction; - /** If set to false, incoming requests will not be instrumented at all. */ - instrumentIncomingRequests?: boolean; - /** If set to false, outgoing requests will not be instrumented at all. */ - instrumentOutgoingRequests?: boolean; + /** If set to true, incoming requests will not be instrumented at all. */ + disableIncomingRequestInstrumentation?: boolean; + /** If set to true, outgoing requests will not be instrumented at all. */ + disableOutgoingRequestInstrumentation?: boolean; /** Function for adding custom attributes after response is handled */ applyCustomAttributesOnSpan?: HttpCustomAttributeFunction; /** Function for adding custom attributes before request is handled */ diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index ad14544978..77d90b4fa3 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -242,7 +242,7 @@ describe('HttpInstrumentation', () => { instrumentation.disable(); instrumentation.setConfig({ - instrumentOutgoingRequests: false, + disableOutgoingRequestInstrumentation: true, }); instrumentation.enable(); server = http.createServer((_request, response) => { @@ -261,7 +261,7 @@ describe('HttpInstrumentation', () => { instrumentation.disable(); instrumentation.setConfig({ - instrumentIncomingRequests: false, + disableIncomingRequestInstrumentation: true, }); instrumentation.enable(); server = http.createServer((_request, response) => { diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts index 6605194cde..0f48a30ae7 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts @@ -718,7 +718,7 @@ describe('HttpsInstrumentation', () => { it('allows to disable outgoing request instrumentation', () => { instrumentation.setConfig({ - instrumentOutgoingRequests: false, + disableOutgoingRequestInstrumentation: true, }); instrumentation.enable(); server = https.createServer( @@ -740,7 +740,7 @@ describe('HttpsInstrumentation', () => { it('allows to disable incoming request instrumentation', () => { instrumentation.setConfig({ - instrumentIncomingRequests: false, + disableIncomingRequestInstrumentation: true, }); instrumentation.enable(); server = https.createServer( diff --git a/package-lock.json b/package-lock.json index c622aa15f7..559643e206 100644 --- a/package-lock.json +++ b/package-lock.json @@ -782,7 +782,7 @@ "version": "0.52.1", "license": "Apache-2.0", "dependencies": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "1.25.1", "@opentelemetry/otlp-grpc-exporter-base": "0.52.1", "@opentelemetry/otlp-transformer": "0.52.1", @@ -1211,7 +1211,7 @@ "version": "0.52.1", "license": "Apache-2.0", "dependencies": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "1.25.1", "@opentelemetry/otlp-grpc-exporter-base": "0.52.1", "@opentelemetry/otlp-transformer": "0.52.1", @@ -1806,7 +1806,7 @@ "version": "0.52.1", "license": "Apache-2.0", "dependencies": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "1.25.1", "@opentelemetry/exporter-metrics-otlp-http": "0.52.1", "@opentelemetry/otlp-exporter-base": "0.52.1", @@ -2434,7 +2434,7 @@ }, "devDependencies": { "@bufbuild/buf": "1.21.0-1", - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@grpc/proto-loader": "^0.7.10", "@opentelemetry/api": "1.9.0", "@opentelemetry/context-async-hooks": "1.25.1", @@ -3154,7 +3154,7 @@ "version": "0.52.1", "license": "Apache-2.0", "dependencies": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "1.25.1", "@opentelemetry/otlp-exporter-base": "0.52.1", "@opentelemetry/otlp-transformer": "0.52.1" @@ -37462,7 +37462,7 @@ "@opentelemetry/exporter-logs-otlp-grpc": { "version": "file:experimental/packages/exporter-logs-otlp-grpc", "requires": { - "@grpc/grpc-js": "1.10.10", + "@grpc/grpc-js": "^1.7.1", "@grpc/proto-loader": "^0.7.10", "@opentelemetry/api": "1.9.0", "@opentelemetry/api-logs": "0.52.1", @@ -37766,7 +37766,7 @@ "@opentelemetry/exporter-metrics-otlp-grpc": { "version": "file:experimental/packages/opentelemetry-exporter-metrics-otlp-grpc", "requires": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@grpc/proto-loader": "^0.7.10", "@opentelemetry/api": "1.9.0", "@opentelemetry/core": "1.25.1", @@ -38051,7 +38051,7 @@ "@opentelemetry/exporter-trace-otlp-grpc": { "version": "file:experimental/packages/exporter-trace-otlp-grpc", "requires": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@grpc/proto-loader": "^0.7.10", "@opentelemetry/api": "1.9.0", "@opentelemetry/core": "1.25.1", @@ -38727,7 +38727,7 @@ "version": "file:experimental/packages/opentelemetry-instrumentation-grpc", "requires": { "@bufbuild/buf": "1.21.0-1", - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@grpc/proto-loader": "^0.7.10", "@opentelemetry/api": "1.9.0", "@opentelemetry/context-async-hooks": "1.25.1", @@ -39255,7 +39255,7 @@ "@opentelemetry/otlp-grpc-exporter-base": { "version": "file:experimental/packages/otlp-grpc-exporter-base", "requires": { - "@grpc/grpc-js": "^1.10.10", + "@grpc/grpc-js": "^1.7.1", "@opentelemetry/api": "1.9.0", "@opentelemetry/core": "1.25.1", "@opentelemetry/otlp-exporter-base": "0.52.1", From bb787bff2dbfed4b40f28c88bd5a43ee4702ce72 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 25 Jul 2024 12:03:28 -0700 Subject: [PATCH 4/4] add a changelog entry --- experimental/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index ab188c2752..bb7c0a64c0 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -11,6 +11,8 @@ All notable changes to experimental packages in this project will be documented ### :rocket: (Enhancement) +* feat(instrumentation-http): Allow to opt-out of instrumenting incoming/outgoing requests [#4643](https://github.com/open-telemetry/opentelemetry-js/pull/4643) @mydea + ### :bug: (Bug Fix) * fix(instrumentation-http): Ensure instrumentation of `http.get` and `https.get` work when used in ESM code [#4857](https://github.com/open-telemetry/opentelemetry-js/issues/4857) @trentm