diff options
Diffstat (limited to 'packages/core/src/config')
| -rw-r--r-- | packages/core/src/config/config.test.ts | 25 | ||||
| -rw-r--r-- | packages/core/src/config/config.ts | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index f1d8b965..3fb71ae8 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -567,5 +567,30 @@ describe('Server Config (config.ts)', () => { const config = new Config(paramsWithoutTelemetry); expect(config.getTelemetryOtlpEndpoint()).toBe(DEFAULT_OTLP_ENDPOINT); }); + + it('should return provided OTLP protocol', () => { + const params: ConfigParameters = { + ...baseParams, + telemetry: { enabled: true, otlpProtocol: 'http' }, + }; + const config = new Config(params); + expect(config.getTelemetryOtlpProtocol()).toBe('http'); + }); + + it('should return default OTLP protocol if not provided', () => { + const params: ConfigParameters = { + ...baseParams, + telemetry: { enabled: true }, + }; + const config = new Config(params); + expect(config.getTelemetryOtlpProtocol()).toBe('grpc'); + }); + + it('should return default OTLP protocol if telemetry object is not provided', () => { + const paramsWithoutTelemetry: ConfigParameters = { ...baseParams }; + delete paramsWithoutTelemetry.telemetry; + const config = new Config(paramsWithoutTelemetry); + expect(config.getTelemetryOtlpProtocol()).toBe('grpc'); + }); }); }); diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 5c11667b..49f9ab45 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -81,6 +81,7 @@ export interface TelemetrySettings { enabled?: boolean; target?: TelemetryTarget; otlpEndpoint?: string; + otlpProtocol?: 'grpc' | 'http'; logPrompts?: boolean; outfile?: string; } @@ -292,6 +293,7 @@ export class Config { enabled: params.telemetry?.enabled ?? false, target: params.telemetry?.target ?? DEFAULT_TELEMETRY_TARGET, otlpEndpoint: params.telemetry?.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT, + otlpProtocol: params.telemetry?.otlpProtocol, logPrompts: params.telemetry?.logPrompts ?? true, outfile: params.telemetry?.outfile, }; @@ -564,6 +566,10 @@ export class Config { return this.telemetrySettings.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT; } + getTelemetryOtlpProtocol(): 'grpc' | 'http' { + return this.telemetrySettings.otlpProtocol ?? 'grpc'; + } + getTelemetryTarget(): TelemetryTarget { return this.telemetrySettings.target ?? DEFAULT_TELEMETRY_TARGET; } |
