mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(core): append correct OTLP paths for HTTP exporters (#16836)
This commit is contained in:
committed by
GitHub
parent
1a7d4184cd
commit
7d31d5f4ec
@@ -113,13 +113,13 @@ describe('Telemetry SDK', () => {
|
||||
await initializeTelemetry(mockConfig);
|
||||
|
||||
expect(OTLPTraceExporterHttp).toHaveBeenCalledWith({
|
||||
url: 'http://localhost:4318/',
|
||||
url: 'http://localhost:4318/v1/traces',
|
||||
});
|
||||
expect(OTLPLogExporterHttp).toHaveBeenCalledWith({
|
||||
url: 'http://localhost:4318/',
|
||||
url: 'http://localhost:4318/v1/logs',
|
||||
});
|
||||
expect(OTLPMetricExporterHttp).toHaveBeenCalledWith({
|
||||
url: 'http://localhost:4318/',
|
||||
url: 'http://localhost:4318/v1/metrics',
|
||||
});
|
||||
expect(NodeSDK.prototype.start).toHaveBeenCalled();
|
||||
});
|
||||
@@ -141,7 +141,7 @@ describe('Telemetry SDK', () => {
|
||||
);
|
||||
await initializeTelemetry(mockConfig);
|
||||
expect(OTLPTraceExporterHttp).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ url: 'https://my-collector.com/' }),
|
||||
expect.objectContaining({ url: 'https://my-collector.com/v1/traces' }),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -275,15 +275,21 @@ export async function initializeTelemetry(
|
||||
});
|
||||
} else if (useOtlp) {
|
||||
if (otlpProtocol === 'http') {
|
||||
const buildUrl = (path: string) => {
|
||||
const url = new URL(parsedEndpoint);
|
||||
// Join the existing pathname with the new path, handling trailing slashes.
|
||||
url.pathname = [url.pathname.replace(/\/$/, ''), path].join('/');
|
||||
return url.href;
|
||||
};
|
||||
spanExporter = new OTLPTraceExporterHttp({
|
||||
url: parsedEndpoint,
|
||||
url: buildUrl('v1/traces'),
|
||||
});
|
||||
logExporter = new OTLPLogExporterHttp({
|
||||
url: parsedEndpoint,
|
||||
url: buildUrl('v1/logs'),
|
||||
});
|
||||
metricReader = new PeriodicExportingMetricReader({
|
||||
exporter: new OTLPMetricExporterHttp({
|
||||
url: parsedEndpoint,
|
||||
url: buildUrl('v1/metrics'),
|
||||
}),
|
||||
exportIntervalMillis: 10000,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user