diff --git a/dev/system-test/tracing.ts b/dev/system-test/tracing.ts index 9d772dcf2..bf97ae246 100644 --- a/dev/system-test/tracing.ts +++ b/dev/system-test/tracing.ts @@ -67,7 +67,7 @@ import { } from '../src/telemetry/trace-util'; import {AsyncLocalStorageContextManager} from '@opentelemetry/context-async-hooks'; import {deepStrictEqual} from 'assert'; -import {cloudtrace_v1, auth as gAuth} from '@googleapis/cloudtrace'; +import {cloudtrace_v1, cloudtrace_v2} from '@googleapis/cloudtrace'; import {GoogleAuth} from 'google-gax'; import Schema$Trace = cloudtrace_v1.Schema$Trace; import Schema$TraceSpan = cloudtrace_v1.Schema$TraceSpan; @@ -325,6 +325,22 @@ describe.only('Tracing Tests', () => { ); } + async function authenticate() : Promise { + try { + const auth = new GoogleAuth({ + scopes: ['https://www.googleapis.com/auth/cloud-platform'] + }); + + const client = await auth.getClient(); + console.log(client); // The authenticated client + console.log(`authenticated for project:${client.projectId}`); + return auth; + } catch (error) { + console.error('Authentication failed:', error); + return null; + } + } + // Returns true on success, and false otherwise. async function waitForCompletedInMemorySpans(): Promise { await tracerProvider.forceFlush(); @@ -337,14 +353,17 @@ describe.only('Tracing Tests', () => { async function waitForCompletedCloudTraceSpans( numExpectedSpans: number ): Promise { - const auth = new gAuth.GoogleAuth({ - scopes: ['https://www.googleapis.com/auth/cloud-platform'], - }); + // const auth = new gAuth.GoogleAuth({ + // scopes: ['https://www.googleapis.com/auth/cloud-platform'], + // }); + // const client = new cloudtrace_v1.Cloudtrace({ // auth: new GoogleAuth({ // projectId: firestore.projectId, // }), // }); + + const auth = await authenticate(); const client = new cloudtrace_v1.Cloudtrace({auth}); const projectTraces = new cloudtrace_v1.Resource$Projects$Traces( client.context @@ -360,10 +379,12 @@ describe.only('Tracing Tests', () => { let receivedFullTrace = false; do { try { + console.log('going to get traces'); const getTraceResponse = await projectTraces.get({ projectId: firestore.projectId, traceId: customSpanContext.traceId, }); + console.log(`got ${getTraceResponse}`); cloudTraceInfo = getTraceResponse.data;