Skip to content

Commit 3905e81

Browse files
fix(core): append correct OTLP paths for HTTP exporters
1 parent f367b95 commit 3905e81

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/core/src/telemetry/sdk.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ describe('Telemetry SDK', () => {
110110
await initializeTelemetry(mockConfig);
111111

112112
expect(OTLPTraceExporterHttp).toHaveBeenCalledWith({
113-
url: 'http://localhost:4318/',
113+
url: 'http://localhost:4318/v1/traces',
114114
});
115115
expect(OTLPLogExporterHttp).toHaveBeenCalledWith({
116-
url: 'http://localhost:4318/',
116+
url: 'http://localhost:4318/v1/logs',
117117
});
118118
expect(OTLPMetricExporterHttp).toHaveBeenCalledWith({
119-
url: 'http://localhost:4318/',
119+
url: 'http://localhost:4318/v1/metrics',
120120
});
121121
expect(NodeSDK.prototype.start).toHaveBeenCalled();
122122
});
@@ -138,7 +138,7 @@ describe('Telemetry SDK', () => {
138138
);
139139
await initializeTelemetry(mockConfig);
140140
expect(OTLPTraceExporterHttp).toHaveBeenCalledWith(
141-
expect.objectContaining({ url: 'https://my-collector.com/' }),
141+
expect.objectContaining({ url: 'https://my-collector.com/v1/traces' }),
142142
);
143143
});
144144

packages/core/src/telemetry/sdk.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,17 @@ export async function initializeTelemetry(
240240
});
241241
} else if (useOtlp) {
242242
if (otlpProtocol === 'http') {
243+
// Trim trailing slashes
244+
const baseUrl = parsedEndpoint.replace(/\/+$/, '');
243245
spanExporter = new OTLPTraceExporterHttp({
244-
url: parsedEndpoint,
246+
url: `${baseUrl}/v1/traces`,
245247
});
246248
logExporter = new OTLPLogExporterHttp({
247-
url: parsedEndpoint,
249+
url: `${baseUrl}/v1/logs`,
248250
});
249251
metricReader = new PeriodicExportingMetricReader({
250252
exporter: new OTLPMetricExporterHttp({
251-
url: parsedEndpoint,
253+
url: `${baseUrl}/v1/metrics`,
252254
}),
253255
exportIntervalMillis: 10000,
254256
});

0 commit comments

Comments
 (0)