Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion OBSERVABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ const spanner = new Spanner({

In addition to client-side tracing, you can opt in for end-to-end tracing. End-to-end tracing helps you understand and debug latency issues that are specific to Spanner. Refer [here](https://cloud.google.com/spanner/docs/tracing-overview) for more information.

You can opt-in by either:
To configure end-to-end tracing.

1. Opt in for end-to-end tracing. You can opt-in by either:
* Setting the environment variable `SPANNER_ENABLE_END_TO_END_TRACING=true` before your application is started
* In code, setting `enableEndToEndTracing: true` in your SpannerOptions before creating the Cloud Spanner client

Expand All @@ -103,6 +104,13 @@ const spanner = new Spanner({
}),
```

2. Set the trace context propagation in OpenTelemetry.
```javascript
const {propagation} = require('@opentelemetry/api');
const {W3CTraceContextPropagator} = require('@opentelemetry/core');
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
```

#### OpenTelemetry gRPC instrumentation

Optionally, you can enable OpenTelemetry gRPC instrumentation which produces traces of executed remote procedure calls (RPCs)
Expand Down
5 changes: 5 additions & 0 deletions samples/observability-traces.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const provider = new NodeTracerProvider({
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter));

// Set global propagator to propogate the trace context for end to end tracing.
const {propagation} = require('@opentelemetry/api');
const {W3CTraceContextPropagator} = require('@opentelemetry/core');
propagation.setGlobalPropagator(new W3CTraceContextPropagator());

// Uncomment following line to register global tracerProvider instead
// of passing it into SpannerOptions.observabilityOptions.
// provider.register();
Expand Down
2 changes: 2 additions & 0 deletions samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"@opentelemetry/instrumentation-grpc": "^0.54.0",
"@opentelemetry/sdk-trace-base": "^1.26.0",
"@opentelemetry/sdk-trace-node": "^1.26.0",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/core": "^1.27.0",
"chai": "^4.2.0",
"mocha": "^9.0.0",
"p-limit": "^3.0.1"
Expand Down
Loading