Skip to content

Commit 3636b82

Browse files
committed
Handle IPv6 hosts
1 parent d27149e commit 3636b82

File tree

1 file changed

+6
-2
lines changed
  • packages/node/src/integrations/tracing/firebase/otel/patches

1 file changed

+6
-2
lines changed

packages/node/src/integrations/tracing/firebase/otel/patches/firestore.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as net from 'node:net';
12
import type { Span, Tracer } from '@opentelemetry/api';
23
import { context, diag, SpanKind, trace } from '@opentelemetry/api';
34
import {
@@ -272,10 +273,13 @@ function addAttributes<AppModelType, DbModelType extends DocumentData>(
272273
};
273274

274275
if (typeof settings.host === 'string') {
275-
const arr = settings.host.split(':');
276+
const arr = net.isIPv6(settings.host)
277+
? settings.host.split(']:') // Handling IPv6 addresses
278+
: settings.host.split(':'); // Handling IPv4 addresses
279+
276280
if (arr.length === 2) {
277281
attributes[ATTR_SERVER_ADDRESS] = arr[0];
278-
attributes[ATTR_SERVER_PORT] = arr[1];
282+
attributes[ATTR_SERVER_PORT] = Number(arr[1]);
279283
}
280284
}
281285

0 commit comments

Comments
 (0)