Google Cloud Trace
Google Cloud Trace collects and analyzes latency data from distributed applications. PURISTA sends traces via the Google Cloud Trace OTLP exporter — no global SDK initialization required.
Install
npm install @google-cloud/opentelemetry-cloud-trace-exporter @opentelemetry/sdk-trace-node
TypeScript setup
The Cloud Trace exporter implements the SpanExporter interface, so you wrap it in a SimpleSpanProcessor and pass it directly to PURISTA.
import { TraceExporter } from '@google-cloud/opentelemetry-cloud-trace-exporter'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'
export function getSpanProcessor() {
// Uses Application Default Credentials automatically
const exporter = new TraceExporter({
projectId: process.env.GOOGLE_CLOUD_PROJECT,
})
return new SimpleSpanProcessor(exporter)
}
Wire it into your application:
import { getSpanProcessor } from './tracing.js'
import { AmqpBridge } from '@purista/amqpbridge'
const spanProcessor = getSpanProcessor()
const eventBridge = new AmqpBridge({ spanProcessor })
await eventBridge.start()
const myService = await myV1Service.getInstance(eventBridge, { spanProcessor })
await myService.start()
Authentication
The exporter uses Application Default Credentials:
- Local development:
gcloud auth application-default login - Cloud Run / GKE / Compute Engine: the default service account is used automatically
- CI/CD: set
GOOGLE_APPLICATION_CREDENTIALSto the path of a service account JSON key
Required IAM permission
The service account needs the cloudtrace.traces.patch permission (included in the Cloud Trace Agent role).
Environment variables
| Variable | Description |
|---|---|
GOOGLE_CLOUD_PROJECT | GCP project ID |
GOOGLE_APPLICATION_CREDENTIALS | Path to service account key (optional in most environments) |
OTEL_SERVICE_NAME | Service name shown in Cloud Trace |
Viewing traces
- Open Cloud Trace in the GCP Console
- Select your project
- Use the trace list or waterfall view to navigate the PURISTA message flow across services