This is a sample application demonstrating a bug in the OpenTelemetry instrumentation with Cloud Spanner using the Spanner emulator.
- Node 16+
- Cloud Spanner Emulator - Setup Instructions
- Start the Spanner emulator:
docker pull gcr.io/cloud-spanner-emulator/emulator
docker run -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator- Install dependencies:
npm install- Start the application:
npm startBasic query example:
curl http://localhost:8080/The application is instrumented with OpenTelemetry Node SDK and outputs traces to the console. Each request will generate a trace with multiple spans showing the Spanner operations.
Example trace output:
{
"traceId": "abc123...",
"spanId": "def456...",
"name": "CloudSpanner.executeStreamingSql",
"attributes": {
"db.system": "spanner",
"db.name": "otel-spanner-test-database"
}
}
PORT- Server port (default: 8080)
This application uses the Spanner emulator for local development. For production use, you'll need to configure actual Google Cloud credentials and update the Spanner connection settings.