mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
0879ce538f
As noted in #36073, having support for the different protocols for exporting OpenTelemetry data would be useful, especially if this is leading to users seeing issues when they have auto-injected configuration being set. Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { getOtlpProtocol, massageThrowable } from './utils.ts';
|
|
|
|
describe('instrumentation/utils', () => {
|
|
describe('massageThrowable', () => {
|
|
it.each`
|
|
input | expected
|
|
${null} | ${undefined}
|
|
${undefined} | ${undefined}
|
|
${new Error('test')} | ${'test'}
|
|
${'test'} | ${'test'}
|
|
${123} | ${'123'}
|
|
`('should return $expected for $input', ({ input, expected }) => {
|
|
expect(massageThrowable(input)).toEqual(expected);
|
|
});
|
|
});
|
|
|
|
describe('getOtlpProtocol', () => {
|
|
beforeEach(() => {
|
|
vi.stubEnv('OTEL_EXPORTER_OTLP_PROTOCOL', undefined);
|
|
vi.stubEnv('OTEL_EXPORTER_OTLP_TRACES_PROTOCOL', undefined);
|
|
});
|
|
|
|
it('defaults to http/json when unset', () => {
|
|
expect(getOtlpProtocol()).toBe('http/json');
|
|
});
|
|
|
|
it('defaults to http/json for an unrecognised value', () => {
|
|
vi.stubEnv('OTEL_EXPORTER_OTLP_PROTOCOL', 'unknown-protocol');
|
|
expect(getOtlpProtocol()).toBe('http/json');
|
|
});
|
|
|
|
it.each`
|
|
protocol
|
|
${'grpc'}
|
|
${'http/json'}
|
|
${'http/protobuf'}
|
|
`('reads $protocol from OTEL_EXPORTER_OTLP_PROTOCOL', ({ protocol }) => {
|
|
process.env.OTEL_EXPORTER_OTLP_PROTOCOL = protocol;
|
|
expect(getOtlpProtocol()).toBe(protocol);
|
|
});
|
|
|
|
it('prefers OTEL_EXPORTER_OTLP_TRACES_PROTOCOL over OTEL_EXPORTER_OTLP_PROTOCOL', () => {
|
|
vi.stubEnv('OTEL_EXPORTER_OTLP_PROTOCOL', 'http/json');
|
|
vi.stubEnv('OTEL_EXPORTER_OTLP_TRACES_PROTOCOL', 'grpc');
|
|
expect(getOtlpProtocol()).toBe('grpc');
|
|
});
|
|
});
|
|
});
|