File tree Expand file tree Collapse file tree 4 files changed +39
-8
lines changed
packages/otlp-exporter-base/src/configuration Expand file tree Collapse file tree 4 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
9
9
### :boom : Breaking Changes
10
10
11
11
* feat(api-logs)!: Marked private methods as "conventionally private". [ #5789 ] ( https://github.com/open-telemetry/opentelemetry-js/pull/5789 )
12
+ * feat(exporter-otlp-\* ): support custom HTTP agents [ #5719 ] ( https://github.com/open-telemetry/opentelemetry-js/pull/5719 ) @raphael-theriault-swi
13
+ * ` OtlpHttpConfiguration.agentOptions ` has been removed and functionality has been rolled into ` OtlpHttpConfiguration.agentFactory `
14
+ * (old) ` { agentOptions: myOptions } `
15
+ * (new) ` { agentFactory: httpAgentFactoryFromOptions(myOptions) } `
12
16
13
17
### :rocket : Features
14
18
15
- * feat(exporter-otlp-\* ): support custom HTTP agents [ #5719 ] ( https://github.com/open-telemetry/opentelemetry-js/pull/5719 ) @raphael-theriault-swi
16
-
17
19
### :bug : Bug Fixes
18
20
19
21
* fix(otlp-exporter-base): prioritize ` esnext ` export condition as it is more specific [ #5458 ] ( https://github.com/open-telemetry/opentelemetry-js/pull/5458 )
Original file line number Diff line number Diff line change @@ -27,6 +27,28 @@ import type { HttpAgentFactory } from './otlp-http-configuration';
27
27
export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
28
28
keepAlive ?: boolean ;
29
29
compression ?: CompressionAlgorithm ;
30
+ /**
31
+ * Custom HTTP agent options or a factory function for creating agents.
32
+ *
33
+ * @remarks
34
+ * Prefer using `http.AgentOptions` or `https.AgentOptions` over a factory function wherever possible.
35
+ * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`
36
+ * statically at the top of the file**.
37
+ * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`
38
+ * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
39
+ *
40
+ * @example <caption> Using agent options directly: </caption>
41
+ * httpAgentOptions: {
42
+ * keepAlive: true,
43
+ * maxSockets: 10
44
+ * }
45
+ *
46
+ * @example <caption> Using a factory with dynamic import: </caption>
47
+ * httpAgentOptions: async (protocol) => {
48
+ * const module = protocol === 'http:' ? await import('http') : await import('https');
49
+ * return new module.Agent({ keepAlive: true });
50
+ * }
51
+ */
30
52
httpAgentOptions ?: http . AgentOptions | https . AgentOptions | HttpAgentFactory ;
31
53
}
32
54
Original file line number Diff line number Diff line change @@ -25,15 +25,23 @@ import { validateAndNormalizeHeaders } from '../util';
25
25
import type * as http from 'http' ;
26
26
import type * as https from 'https' ;
27
27
28
- export type HttpAgentFactory =
29
- | ( ( protocol : string ) => http . Agent )
30
- | ( ( protocol : string ) => https . Agent )
31
- | ( ( protocol : string ) => Promise < http . Agent > )
32
- | ( ( protocol : string ) => Promise < https . Agent > ) ;
28
+ export type HttpAgentFactory = (
29
+ protocol : string
30
+ ) => http . Agent | https . Agent | Promise < http . Agent > | Promise < https . Agent > ;
33
31
34
32
export interface OtlpHttpConfiguration extends OtlpSharedConfiguration {
35
33
url : string ;
36
34
headers : ( ) => Record < string , string > ;
35
+ /**
36
+ * Factory function for creating agents.
37
+ *
38
+ * @remarks
39
+ * Prefer using {@link httpAgentFactoryFromOptions} over manually writing a factory function wherever possible.
40
+ * If using a factory function (`HttpAgentFactory`), **do not import `http.Agent` or `https.Agent`
41
+ * statically at the top of the file**.
42
+ * Instead, use dynamic `import()` or `require()` to load the module. This ensures that the `http` or `https`
43
+ * module is not loaded before `@opentelemetry/instrumentation-http` can instrument it.
44
+ */
37
45
agentFactory : HttpAgentFactory ;
38
46
}
39
47
Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ const tsConfigMergeKeys = [
40
40
'compilerOptions' ,
41
41
'include' ,
42
42
'files' ,
43
- "ts-node" ,
44
43
] ;
45
44
// Make `extends` the first field.
46
45
const tsConfigPriorityKeys = [ 'extends' ] ;
You can’t perform that action at this time.
0 commit comments