Skip to content

Commit 3c853e1

Browse files
authored
chore: Update end to end tracing documentation (#2212)
1 parent d2ff046 commit 3c853e1

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

OBSERVABILITY.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ const spanner = new Spanner({
8888

8989
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.
9090

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

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

@@ -103,6 +104,13 @@ const spanner = new Spanner({
103104
}),
104105
```
105106

107+
2. Set the trace context propagation in OpenTelemetry.
108+
```javascript
109+
const {propagation} = require('@opentelemetry/api');
110+
const {W3CTraceContextPropagator} = require('@opentelemetry/core');
111+
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
112+
```
113+
106114
#### OpenTelemetry gRPC instrumentation
107115

108116
Optionally, you can enable OpenTelemetry gRPC instrumentation which produces traces of executed remote procedure calls (RPCs)

samples/observability-traces.js

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const provider = new NodeTracerProvider({
4141
});
4242
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
4343

44+
// Set global propagator to propogate the trace context for end to end tracing.
45+
const {propagation} = require('@opentelemetry/api');
46+
const {W3CTraceContextPropagator} = require('@opentelemetry/core');
47+
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
48+
4449
// Uncomment following line to register global tracerProvider instead
4550
// of passing it into SpannerOptions.observabilityOptions.
4651
// provider.register();

samples/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"@opentelemetry/instrumentation-grpc": "^0.54.0",
2828
"@opentelemetry/sdk-trace-base": "^1.26.0",
2929
"@opentelemetry/sdk-trace-node": "^1.26.0",
30+
"@opentelemetry/api": "^1.9.0",
31+
"@opentelemetry/core": "^1.27.0",
3032
"chai": "^4.2.0",
3133
"mocha": "^9.0.0",
3234
"p-limit": "^3.0.1"

0 commit comments

Comments
 (0)