chore: make userAgent optional in OtlpNodeHttpConfiguration
This commit is contained in:
parent
78667e4a85
commit
d36ea599ca
|
|
@ -56,7 +56,7 @@ export function convertLegacyHttpOptions(
|
||||||
signalIdentifier: string,
|
signalIdentifier: string,
|
||||||
signalResourcePath: string,
|
signalResourcePath: string,
|
||||||
requiredHeaders: Record<string, string>
|
requiredHeaders: Record<string, string>
|
||||||
): OtlpNodeHttpConfiguration {
|
): Required<OtlpNodeHttpConfiguration> {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if ((config as any).metadata) {
|
if ((config as any).metadata) {
|
||||||
diag.warn('Metadata cannot be set when using http');
|
diag.warn('Metadata cannot be set when using http');
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export interface OtlpNodeHttpConfiguration extends OtlpHttpConfiguration {
|
||||||
* Ref: https://github.com/open-telemetry/opentelemetry-specification/pull/4654
|
* Ref: https://github.com/open-telemetry/opentelemetry-specification/pull/4654
|
||||||
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
* Ref: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#user-agent
|
||||||
*/
|
*/
|
||||||
userAgent: string;
|
userAgent?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function httpAgentFactoryFromOptions(
|
export function httpAgentFactoryFromOptions(
|
||||||
|
|
@ -67,8 +67,8 @@ export function httpAgentFactoryFromOptions(
|
||||||
export function mergeOtlpNodeHttpConfigurationWithDefaults(
|
export function mergeOtlpNodeHttpConfigurationWithDefaults(
|
||||||
userProvidedConfiguration: Partial<OtlpNodeHttpConfiguration>,
|
userProvidedConfiguration: Partial<OtlpNodeHttpConfiguration>,
|
||||||
fallbackConfiguration: Partial<OtlpNodeHttpConfiguration>,
|
fallbackConfiguration: Partial<OtlpNodeHttpConfiguration>,
|
||||||
defaultConfiguration: OtlpNodeHttpConfiguration
|
defaultConfiguration: Required<OtlpNodeHttpConfiguration>
|
||||||
): OtlpNodeHttpConfiguration {
|
): Required<OtlpNodeHttpConfiguration> {
|
||||||
let userAgent = defaultConfiguration.userAgent;
|
let userAgent = defaultConfiguration.userAgent;
|
||||||
if (userProvidedConfiguration.userAgent) {
|
if (userProvidedConfiguration.userAgent) {
|
||||||
userAgent = `${userProvidedConfiguration.userAgent} ${userAgent}`;
|
userAgent = `${userProvidedConfiguration.userAgent} ${userAgent}`;
|
||||||
|
|
@ -90,7 +90,7 @@ export function mergeOtlpNodeHttpConfigurationWithDefaults(
|
||||||
export function getNodeHttpConfigurationDefaults(
|
export function getNodeHttpConfigurationDefaults(
|
||||||
requiredHeaders: Record<string, string>,
|
requiredHeaders: Record<string, string>,
|
||||||
signalResourcePath: string
|
signalResourcePath: string
|
||||||
): OtlpNodeHttpConfiguration {
|
): Required<OtlpNodeHttpConfiguration> {
|
||||||
return {
|
return {
|
||||||
...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),
|
...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),
|
||||||
agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),
|
agentFactory: httpAgentFactoryFromOptions({ keepAlive: true }),
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { createRetryingTransport } from './retrying-transport';
|
||||||
import { OtlpNodeHttpConfiguration } from './configuration/otlp-node-http-configuration';
|
import { OtlpNodeHttpConfiguration } from './configuration/otlp-node-http-configuration';
|
||||||
|
|
||||||
export function createOtlpHttpExportDelegate<Internal, Response>(
|
export function createOtlpHttpExportDelegate<Internal, Response>(
|
||||||
options: OtlpNodeHttpConfiguration,
|
options: Required<OtlpNodeHttpConfiguration>,
|
||||||
serializer: ISerializer<Internal, Response>
|
serializer: ISerializer<Internal, Response>
|
||||||
): IOtlpExportDelegate<Internal> {
|
): IOtlpExportDelegate<Internal> {
|
||||||
return createOtlpExportDelegate(
|
return createOtlpExportDelegate(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { mergeOtlpNodeHttpConfigurationWithDefaults } from '../../../src/configu
|
||||||
import { OtlpNodeHttpConfiguration } from '../../../src/configuration/otlp-node-http-configuration';
|
import { OtlpNodeHttpConfiguration } from '../../../src/configuration/otlp-node-http-configuration';
|
||||||
|
|
||||||
describe('mergeOtlpNodeHttpConfigurationWithDefaults', function () {
|
describe('mergeOtlpNodeHttpConfigurationWithDefaults', function () {
|
||||||
const testDefaults: OtlpNodeHttpConfiguration = {
|
const testDefaults: Required<OtlpNodeHttpConfiguration> = {
|
||||||
url: 'http://default.example.test',
|
url: 'http://default.example.test',
|
||||||
timeoutMillis: 1,
|
timeoutMillis: 1,
|
||||||
compression: 'none',
|
compression: 'none',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue