From 7f79cef20edf6deb1511898302ad9c64b9fb1f16 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Tue, 28 Jul 2026 12:14:11 +0200 Subject: [PATCH] ref(node): Remove vendored Firebase instrumentation This instrumentation is dead code: the Firebase integration is provided by the channel-based implementation in `@sentry/server-utils` (default since #22501), and the vendored OpenTelemetry instrumentation here is no longer wired up. Ref: #22346 Co-Authored-By: Claude Opus 4.8 --- .../integrations/tracing/firebase/firebase.ts | 6 - .../integrations/tracing/firebase/index.ts | 1 - .../firebase/otel/firebaseInstrumentation.ts | 31 -- .../tracing/firebase/otel/index.ts | 3 - .../firebase/otel/patches/firestore.ts | 272 ------------------ .../firebase/otel/patches/functions.ts | 191 ------------ .../tracing/firebase/otel/types.ts | 144 ---------- .../integrations/tracing/firebase.test.ts | 74 ----- 8 files changed, 722 deletions(-) delete mode 100644 packages/node/src/integrations/tracing/firebase/firebase.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/index.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/otel/index.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/otel/patches/firestore.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/otel/patches/functions.ts delete mode 100644 packages/node/src/integrations/tracing/firebase/otel/types.ts delete mode 100644 packages/node/test/integrations/tracing/firebase.test.ts diff --git a/packages/node/src/integrations/tracing/firebase/firebase.ts b/packages/node/src/integrations/tracing/firebase/firebase.ts deleted file mode 100644 index c56199f897e7..000000000000 --- a/packages/node/src/integrations/tracing/firebase/firebase.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { generateInstrumentOnce } from '../../../otel/instrument'; -import { FirebaseInstrumentation } from './otel'; - -const INTEGRATION_NAME = 'Firebase' as const; - -export const instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME, () => new FirebaseInstrumentation()); diff --git a/packages/node/src/integrations/tracing/firebase/index.ts b/packages/node/src/integrations/tracing/firebase/index.ts deleted file mode 100644 index 5588511bf303..000000000000 --- a/packages/node/src/integrations/tracing/firebase/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './firebase'; diff --git a/packages/node/src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts b/packages/node/src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts deleted file mode 100644 index ed57b02b1035..000000000000 --- a/packages/node/src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { InstrumentationConfig, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation'; -import { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { SDK_VERSION } from '@sentry/core'; -import { patchFirestore } from './patches/firestore'; -import { patchFunctions } from './patches/functions'; - -const firestoreSupportedVersions = ['>=3.0.0 <5']; // firebase 9+ -const functionsSupportedVersions = ['>=6.0.0 <7']; // firebase-functions v2 - -/** - * Instrumentation for Firebase services, specifically Firestore. - */ -export class FirebaseInstrumentation extends InstrumentationBase { - public constructor(config: InstrumentationConfig = {}) { - super('@sentry/instrumentation-firebase', SDK_VERSION, config); - } - - /** - * - * @protected - */ - // eslint-disable-next-line @typescript-eslint/naming-convention - protected init(): InstrumentationNodeModuleDefinition | InstrumentationNodeModuleDefinition[] | void { - const modules: InstrumentationNodeModuleDefinition[] = []; - - modules.push(patchFirestore(firestoreSupportedVersions, this._wrap, this._unwrap)); - modules.push(patchFunctions(functionsSupportedVersions, this._wrap, this._unwrap)); - - return modules; - } -} diff --git a/packages/node/src/integrations/tracing/firebase/otel/index.ts b/packages/node/src/integrations/tracing/firebase/otel/index.ts deleted file mode 100644 index 88520ba3efee..000000000000 --- a/packages/node/src/integrations/tracing/firebase/otel/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// The structure inside OTEL is to be kept as close as possible to an opentelemetry plugin. -export * from './firebaseInstrumentation'; -export * from './types'; diff --git a/packages/node/src/integrations/tracing/firebase/otel/patches/firestore.ts b/packages/node/src/integrations/tracing/firebase/otel/patches/firestore.ts deleted file mode 100644 index 0f09d0209fe3..000000000000 --- a/packages/node/src/integrations/tracing/firebase/otel/patches/firestore.ts +++ /dev/null @@ -1,272 +0,0 @@ -import * as net from 'node:net'; -import { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation'; -import { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile'; -import { - DB_COLLECTION_NAME, - DB_NAMESPACE, - DB_OPERATION_NAME, - DB_SYSTEM_NAME, - SENTRY_KIND, - SERVER_ADDRESS, - SERVER_PORT, -} from '@sentry/conventions/attributes'; -import type { SpanAttributes } from '@sentry/core'; -import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core'; -import type { FirebaseInstrumentation } from '../firebaseInstrumentation'; -import type { - AddDocType, - CollectionReference, - DeleteDocType, - DocumentData, - DocumentReference, - FirebaseApp, - FirebaseOptions, - FirestoreSettings, - GetDocsType, - PartialWithFieldValue, - QuerySnapshot, - SetDocType, - SetOptions, - WithFieldValue, -} from '../types'; - -// Inline minimal types used from `shimmer` to avoid importing shimmer's types directly. -// We only need the shape for `wrap` and `unwrap` used in this file. -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type ShimmerWrap = (target: any, name: string, wrapper: (...args: any[]) => any) => void; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type ShimmerUnwrap = (target: any, name: string) => void; - -/** - * - * @param firestoreSupportedVersions - supported version of firebase/firestore - * @param wrap - reference to native instrumentation wrap function - * @param unwrap - reference to native instrumentation wrap function - */ -export function patchFirestore( - firestoreSupportedVersions: string[], - wrap: ShimmerWrap, - unwrap: ShimmerUnwrap, -): InstrumentationNodeModuleDefinition { - const moduleFirestoreCJS = new InstrumentationNodeModuleDefinition( - '@firebase/firestore', - firestoreSupportedVersions, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (moduleExports: any) => wrapMethods(moduleExports, wrap, unwrap), - ); - const files: string[] = [ - '@firebase/firestore/dist/lite/index.node.cjs.js', - '@firebase/firestore/dist/lite/index.node.mjs.js', - '@firebase/firestore/dist/lite/index.rn.esm2017.js', - '@firebase/firestore/dist/lite/index.cjs.js', - ]; - - for (const file of files) { - moduleFirestoreCJS.files.push( - new InstrumentationNodeModuleFile( - file, - firestoreSupportedVersions, - moduleExports => wrapMethods(moduleExports, wrap, unwrap), - moduleExports => unwrapMethods(moduleExports, unwrap), - ), - ); - } - - return moduleFirestoreCJS; -} - -function wrapMethods( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - moduleExports: any, - wrap: ShimmerWrap, - unwrap: ShimmerUnwrap, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -): any { - unwrapMethods(moduleExports, unwrap); - - wrap(moduleExports, 'addDoc', patchAddDoc()); - wrap(moduleExports, 'getDocs', patchGetDocs()); - wrap(moduleExports, 'setDoc', patchSetDoc()); - wrap(moduleExports, 'deleteDoc', patchDeleteDoc()); - - return moduleExports; -} - -function unwrapMethods( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - moduleExports: any, - unwrap: ShimmerUnwrap, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -): any { - for (const method of ['addDoc', 'getDocs', 'setDoc', 'deleteDoc']) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (isWrapped(moduleExports[method])) { - unwrap(moduleExports, method); - } - } - return moduleExports; -} - -function patchAddDoc(): ( - original: AddDocType, -) => ( - this: FirebaseInstrumentation, - reference: CollectionReference, - data: WithFieldValue, -) => Promise> { - return function addDoc(original: AddDocType) { - return function ( - reference: CollectionReference, - data: WithFieldValue, - ): Promise> { - return startFirestoreSpan('addDoc', reference, () => original(reference, data)); - }; - }; -} - -function patchDeleteDoc(): ( - original: DeleteDocType, -) => (this: FirebaseInstrumentation, reference: DocumentReference) => Promise { - return function deleteDoc(original: DeleteDocType) { - return function (reference: DocumentReference): Promise { - return startFirestoreSpan('deleteDoc', reference.parent || reference, () => original(reference)); - }; - }; -} - -function patchGetDocs(): ( - original: GetDocsType, -) => ( - this: FirebaseInstrumentation, - reference: CollectionReference, -) => Promise> { - return function getDocs(original: GetDocsType) { - return function ( - reference: CollectionReference, - ): Promise> { - return startFirestoreSpan('getDocs', reference, () => original(reference)); - }; - }; -} - -function patchSetDoc(): ( - original: SetDocType, -) => ( - this: FirebaseInstrumentation, - reference: DocumentReference, - data: WithFieldValue & PartialWithFieldValue, - options?: SetOptions, -) => Promise { - return function setDoc(original: SetDocType) { - return function ( - reference: DocumentReference, - data: WithFieldValue & PartialWithFieldValue, - options?: SetOptions, - ): Promise { - return startFirestoreSpan('setDoc', reference.parent || reference, () => { - return typeof options !== 'undefined' ? original(reference, data, options) : original(reference, data); - }); - }; - }; -} - -function startFirestoreSpan( - spanName: string, - reference: CollectionReference | DocumentReference, - callback: () => T, -): T { - return startSpan( - { - name: `${spanName} ${reference.path}`, - op: 'db.query', - attributes: { - [SENTRY_KIND]: 'client', - [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.firestore', - [DB_OPERATION_NAME]: spanName, - ...buildAttributes(reference), - }, - }, - callback, - ); -} - -/** - * Gets the server address and port attributes from the Firestore settings. - * It's best effort to extract the address and port from the settings, especially for IPv6. - * @param settings - The Firestore settings containing host information. - */ -export function getPortAndAddress(settings: FirestoreSettings): { - address?: string; - port?: number; -} { - let address: string | undefined; - let port: string | undefined; - - if (typeof settings.host === 'string') { - if (settings.host.startsWith('[')) { - // IPv6 addresses can be enclosed in square brackets, e.g., [2001:db8::1]:8080 - if (settings.host.endsWith(']')) { - // IPv6 with square brackets without port - address = settings.host.replace(/^\[|\]$/g, ''); - } else if (settings.host.includes(']:')) { - // IPv6 with square brackets with port - const lastColonIndex = settings.host.lastIndexOf(':'); - if (lastColonIndex !== -1) { - address = settings.host.slice(1, lastColonIndex).replace(/^\[|\]$/g, ''); - port = settings.host.slice(lastColonIndex + 1); - } - } - } else { - // IPv4 or IPv6 without square brackets - // If it's an IPv6 address without square brackets, we assume it does not have a port. - if (net.isIPv6(settings.host)) { - address = settings.host; - } - // If it's an IPv4 address, we can extract the port if it exists. - else { - const lastColonIndex = settings.host.lastIndexOf(':'); - if (lastColonIndex !== -1) { - address = settings.host.slice(0, lastColonIndex); - port = settings.host.slice(lastColonIndex + 1); - } else { - address = settings.host; - } - } - } - } - return { - address: address, - port: port ? parseInt(port, 10) : undefined, - }; -} - -function buildAttributes( - reference: CollectionReference | DocumentReference, -): SpanAttributes { - const firestoreApp: FirebaseApp = reference.firestore.app; - const firestoreOptions: FirebaseOptions = firestoreApp.options; - const json: { settings?: FirestoreSettings } = reference.firestore.toJSON() || {}; - const settings: FirestoreSettings = json.settings || {}; - - const attributes: SpanAttributes = { - [DB_COLLECTION_NAME]: reference.path, - [DB_NAMESPACE]: firestoreApp.name, - [DB_SYSTEM_NAME]: 'firebase.firestore', - 'firebase.firestore.type': reference.type, - 'firebase.firestore.options.projectId': firestoreOptions.projectId, - 'firebase.firestore.options.appId': firestoreOptions.appId, - 'firebase.firestore.options.messagingSenderId': firestoreOptions.messagingSenderId, - 'firebase.firestore.options.storageBucket': firestoreOptions.storageBucket, - }; - - const { address, port } = getPortAndAddress(settings); - - if (address) { - attributes[SERVER_ADDRESS] = address; - } - if (port) { - attributes[SERVER_PORT] = port; - } - - return attributes; -} diff --git a/packages/node/src/integrations/tracing/firebase/otel/patches/functions.ts b/packages/node/src/integrations/tracing/firebase/otel/patches/functions.ts deleted file mode 100644 index e54167d43d27..000000000000 --- a/packages/node/src/integrations/tracing/firebase/otel/patches/functions.ts +++ /dev/null @@ -1,191 +0,0 @@ -import type { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation'; -import { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile'; -import { SENTRY_KIND } from '@sentry/conventions/attributes'; -import type { SpanAttributes } from '@sentry/core'; -import { - captureException, - flush, - SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, - SPAN_STATUS_ERROR, - startSpanManual, -} from '@sentry/core'; -import type { FirebaseInstrumentation } from '../firebaseInstrumentation'; -import type { AvailableFirebaseFunctions, FirebaseFunctions, OverloadedParameters } from '../types'; - -/** - * Patches Firebase Functions v2 to add OpenTelemetry instrumentation - * @param functionsSupportedVersions - supported versions of firebase-functions - * @param wrap - reference to native instrumentation wrap function - * @param unwrap - reference to native instrumentation unwrap function - */ -export function patchFunctions( - functionsSupportedVersions: string[], - wrap: InstrumentationBase['_wrap'], - unwrap: InstrumentationBase['_unwrap'], -): InstrumentationNodeModuleDefinition { - const moduleFunctionsCJS = new InstrumentationNodeModuleDefinition('firebase-functions', functionsSupportedVersions); - const modulesToInstrument = [ - { name: 'firebase-functions/lib/v2/providers/https.js', triggerType: 'function' }, - { name: 'firebase-functions/lib/v2/providers/firestore.js', triggerType: 'firestore' }, - { name: 'firebase-functions/lib/v2/providers/scheduler.js', triggerType: 'scheduler' }, - { name: 'firebase-functions/lib/v2/storage.js', triggerType: 'storage' }, - ] as const; - - modulesToInstrument.forEach(({ name, triggerType }) => { - moduleFunctionsCJS.files.push( - new InstrumentationNodeModuleFile( - name, - functionsSupportedVersions, - moduleExports => wrapCommonFunctions(moduleExports, wrap, unwrap, triggerType), - moduleExports => unwrapCommonFunctions(moduleExports, unwrap), - ), - ); - }); - - return moduleFunctionsCJS; -} - -/** - * Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation - * - * @param triggerType - Type of trigger - * @returns A function that patches the function - */ -export function patchV2Functions( - triggerType: string, -): (original: T) => (...args: OverloadedParameters) => ReturnType { - return function v2FunctionsWrapper(original: T): (...args: OverloadedParameters) => ReturnType { - return function (this: FirebaseInstrumentation, ...args: OverloadedParameters): ReturnType { - const handler = typeof args[0] === 'function' ? args[0] : args[1]; - const documentOrOptions = typeof args[0] === 'function' ? undefined : args[0]; - - if (!handler) { - return original.call(this, ...args); - } - - const wrappedHandler = async function (this: unknown, ...handlerArgs: unknown[]): Promise { - const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || 'unknown'; - - const attributes: SpanAttributes = { - [SENTRY_KIND]: 'server', - [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.functions', - 'faas.name': functionName, - 'faas.trigger': triggerType, - 'faas.provider': 'firebase', - }; - - if (process.env.GCLOUD_PROJECT) { - attributes['cloud.project_id'] = process.env.GCLOUD_PROJECT; - } - - if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) { - attributes['cloud.event_source'] = process.env.EVENTARC_CLOUD_EVENT_SOURCE; - } - - // `startSpanManual` to keep the span active but while still allowing us to end it before flushing on error. - return startSpanManual( - { - name: `firebase.function.${triggerType}`, - op: 'http.request', - attributes, - }, - async span => { - try { - const result = await handler.apply(this, handlerArgs); - span.end(); - return result; - } catch (error) { - span.setStatus({ code: SPAN_STATUS_ERROR }); - captureException(error, { - mechanism: { - type: 'auto.firebase.otel.functions', - handled: false, - }, - }); - span.end(); - await flush(2000); - throw error; - } - }, - ); - }; - - if (documentOrOptions) { - return original.call(this, documentOrOptions, wrappedHandler); - } else { - return original.call(this, wrappedHandler); - } - }; - }; -} - -function wrapCommonFunctions( - moduleExports: AvailableFirebaseFunctions, - wrap: InstrumentationBase['_wrap'], - unwrap: InstrumentationBase['_unwrap'], - triggerType: 'function' | 'firestore' | 'scheduler' | 'storage', -): AvailableFirebaseFunctions { - unwrapCommonFunctions(moduleExports, unwrap); - - switch (triggerType) { - case 'function': - wrap(moduleExports, 'onRequest', patchV2Functions('http.request')); - wrap(moduleExports, 'onCall', patchV2Functions('http.call')); - break; - - case 'firestore': - wrap(moduleExports, 'onDocumentCreated', patchV2Functions('firestore.document.created')); - wrap(moduleExports, 'onDocumentUpdated', patchV2Functions('firestore.document.updated')); - wrap(moduleExports, 'onDocumentDeleted', patchV2Functions('firestore.document.deleted')); - wrap(moduleExports, 'onDocumentWritten', patchV2Functions('firestore.document.written')); - wrap(moduleExports, 'onDocumentCreatedWithAuthContext', patchV2Functions('firestore.document.created')); - wrap(moduleExports, 'onDocumentUpdatedWithAuthContext', patchV2Functions('firestore.document.updated')); - wrap(moduleExports, 'onDocumentDeletedWithAuthContext', patchV2Functions('firestore.document.deleted')); - wrap(moduleExports, 'onDocumentWrittenWithAuthContext', patchV2Functions('firestore.document.written')); - break; - - case 'scheduler': - wrap(moduleExports, 'onSchedule', patchV2Functions('scheduler.scheduled')); - break; - - case 'storage': - wrap(moduleExports, 'onObjectFinalized', patchV2Functions('storage.object.finalized')); - wrap(moduleExports, 'onObjectArchived', patchV2Functions('storage.object.archived')); - wrap(moduleExports, 'onObjectDeleted', patchV2Functions('storage.object.deleted')); - wrap(moduleExports, 'onObjectMetadataUpdated', patchV2Functions('storage.object.metadataUpdated')); - break; - } - - return moduleExports; -} - -function unwrapCommonFunctions( - moduleExports: AvailableFirebaseFunctions, - unwrap: InstrumentationBase['_unwrap'], -): AvailableFirebaseFunctions { - const methods: (keyof AvailableFirebaseFunctions)[] = [ - 'onSchedule', - 'onRequest', - 'onCall', - 'onObjectFinalized', - 'onObjectArchived', - 'onObjectDeleted', - 'onObjectMetadataUpdated', - 'onDocumentCreated', - 'onDocumentUpdated', - 'onDocumentDeleted', - 'onDocumentWritten', - 'onDocumentCreatedWithAuthContext', - 'onDocumentUpdatedWithAuthContext', - 'onDocumentDeletedWithAuthContext', - 'onDocumentWrittenWithAuthContext', - ]; - - for (const method of methods) { - if (isWrapped(moduleExports[method])) { - unwrap(moduleExports, method); - } - } - return moduleExports; -} diff --git a/packages/node/src/integrations/tracing/firebase/otel/types.ts b/packages/node/src/integrations/tracing/firebase/otel/types.ts deleted file mode 100644 index 6bba7d59a35b..000000000000 --- a/packages/node/src/integrations/tracing/firebase/otel/types.ts +++ /dev/null @@ -1,144 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ - -// Inlined types from 'firebase/app' -export interface FirebaseOptions { - [key: string]: any; - apiKey?: string; - authDomain?: string; - databaseURL?: string; - projectId?: string; - storageBucket?: string; - messagingSenderId?: string; - appId?: string; - measurementId?: string; -} - -export interface FirebaseApp { - name: string; - options: FirebaseOptions; - automaticDataCollectionEnabled: boolean; - delete(): Promise; -} - -// Inlined types from 'firebase/firestore' -export interface DocumentData { - [field: string]: any; -} - -export type WithFieldValue = T; - -export type PartialWithFieldValue = Partial; - -export interface SetOptions { - merge?: boolean; - mergeFields?: (string | number | symbol)[]; -} - -export interface DocumentReference { - id: string; - firestore: { - app: FirebaseApp; - settings: FirestoreSettings; - useEmulator: (host: string, port: number) => void; - toJSON: () => { - app: FirebaseApp; - settings: FirestoreSettings; - }; - }; - type: 'collection' | 'document' | string; - path: string; - parent: CollectionReference; -} - -export interface CollectionReference { - id: string; - firestore: { - app: FirebaseApp; - settings: FirestoreSettings; - useEmulator: (host: string, port: number) => void; - toJSON: () => { - app: FirebaseApp; - settings: FirestoreSettings; - }; - }; - type: string; // 'collection' or 'document' - path: string; - parent: DocumentReference | null; -} - -export interface QuerySnapshot { - docs: Array>; - size: number; - empty: boolean; -} - -export interface FirestoreSettings { - host?: string; - ssl?: boolean; - ignoreUndefinedProperties?: boolean; - cacheSizeBytes?: number; - experimentalForceLongPolling?: boolean; - experimentalAutoDetectLongPolling?: boolean; - useFetchStreams?: boolean; -} - -// Function types (addDoc, getDocs, setDoc, deleteDoc) are defined below as types -export type GetDocsType = ( - query: CollectionReference, -) => Promise>; - -export type SetDocType = (( - reference: DocumentReference, - data: WithFieldValue, -) => Promise) & - (( - reference: DocumentReference, - data: PartialWithFieldValue, - options: SetOptions, - ) => Promise); - -export type AddDocType = ( - reference: CollectionReference, - data: WithFieldValue, -) => Promise>; - -export type DeleteDocType = ( - reference: DocumentReference, -) => Promise; - -export type OverloadedParameters = T extends { - (...args: infer A1): unknown; - (...args: infer A2): unknown; -} - ? A1 | A2 - : T extends (...args: infer A) => unknown - ? A - : unknown; - -/** - * A bare minimum of how Cloud Functions for Firebase (v2) are defined. - */ -export type FirebaseFunctions = - | ((handler: () => Promise | unknown) => (...args: unknown[]) => Promise | unknown) - | (( - documentOrOptions: string | string[] | Record, - handler: () => Promise | unknown, - ) => (...args: unknown[]) => Promise | unknown); - -export type AvailableFirebaseFunctions = { - onRequest: FirebaseFunctions; - onCall: FirebaseFunctions; - onDocumentCreated: FirebaseFunctions; - onDocumentUpdated: FirebaseFunctions; - onDocumentDeleted: FirebaseFunctions; - onDocumentWritten: FirebaseFunctions; - onDocumentCreatedWithAuthContext: FirebaseFunctions; - onDocumentUpdatedWithAuthContext: FirebaseFunctions; - onDocumentDeletedWithAuthContext: FirebaseFunctions; - onDocumentWrittenWithAuthContext: FirebaseFunctions; - onSchedule: FirebaseFunctions; - onObjectFinalized: FirebaseFunctions; - onObjectArchived: FirebaseFunctions; - onObjectDeleted: FirebaseFunctions; - onObjectMetadataUpdated: FirebaseFunctions; -}; diff --git a/packages/node/test/integrations/tracing/firebase.test.ts b/packages/node/test/integrations/tracing/firebase.test.ts deleted file mode 100644 index 0fe0309f4449..000000000000 --- a/packages/node/test/integrations/tracing/firebase.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { getPortAndAddress } from '../../../src/integrations/tracing/firebase/otel/patches/firestore'; - -describe('setPortAndAddress', () => { - beforeEach(() => { - vi.clearAllMocks(); - }); - - describe('IPv6 addresses', () => { - it('should correctly parse IPv6 address without port', () => { - const { address, port } = getPortAndAddress({ host: '[2001:db8::1]' }); - - expect(address).toBe('2001:db8::1'); - expect(port).toBeUndefined(); - }); - - it('should correctly parse IPv6 address with port', () => { - const { address, port } = getPortAndAddress({ host: '[2001:db8::1]:8080' }); - expect(address).toBe('2001:db8::1'); - expect(port).toBe(8080); - }); - - it('should handle IPv6 localhost without port', () => { - const { address, port } = getPortAndAddress({ host: '[::1]' }); - - expect(address).toBe('::1'); - expect(port).toBeUndefined(); - }); - - it('should handle IPv6 localhost with port', () => { - const { address, port } = getPortAndAddress({ host: '[::1]:3000' }); - - expect(address).toBe('::1'); - expect(port).toBe(3000); - }); - }); - - describe('IPv4 and hostname addresses', () => { - it('should correctly parse IPv4 address with port', () => { - const { address, port } = getPortAndAddress({ host: '192.168.1.1:8080' }); - - expect(address).toBe('192.168.1.1'); - expect(port).toBe(8080); - }); - - it('should correctly parse hostname with port', () => { - const { address, port } = getPortAndAddress({ host: 'localhost:3000' }); - - expect(address).toBe('localhost'); - expect(port).toBe(3000); - }); - - it('should correctly parse hostname without port', () => { - const { address, port } = getPortAndAddress({ host: 'example.com' }); - - expect(address).toBe('example.com'); - expect(port).toBeUndefined(); - }); - - it('should correctly parse hostname with port', () => { - const { address, port } = getPortAndAddress({ host: 'example.com:4000' }); - - expect(address).toBe('example.com'); - expect(port).toBe(4000); - }); - - it('should handle empty string', () => { - const { address, port } = getPortAndAddress({ host: '' }); - - expect(address).toBe(''); - expect(port).toBeUndefined(); - }); - }); -});