| 1 | # OpenCensus binary propagation example |
| 2 | |
| 3 | The server uses OpenTelemetry with the OpenCensus binary propagation format. |
| 4 | The client uses OpenCensus, which is hard-coded to use the OpenCensus binary |
| 5 | propagation format. Since the client and server use the same propagation |
| 6 | format, the ParentSpanID from the server spans should match the SpanID from |
| 7 | the client spans, and both should share the same TraceID. |
| 8 | |
| 9 | ## Usage |
| 10 | |
| 11 | First, start the opentelemetry server: |
| 12 | |
| 13 | ```bash |
| 14 | go run opentelemetry_server/server.go |
| 15 | ``` |
| 16 | |
| 17 | In another shell, start the OpenCensus client: |
| 18 | |
| 19 | ```bash |
| 20 | go run opencensus_client/client.go |
| 21 | ``` |
| 22 | |
| 23 | ### Example Client Output |
| 24 | |
| 25 | ``` |
| 26 | Configuring OpenCensus, and registering the Print exporter. |
| 27 | |
| 28 | TraceID: 9d59b1bdbde34cdaac6cfb5b8f3c4685 |
| 29 | SpanID: 07733a2559ef492d |
| 30 | ... |
| 31 | Greeting: Hello world |
| 32 | ``` |
| 33 | |
| 34 | Note that there is no ParentSpanID listed in the client. |
| 35 | |
| 36 | ### Example Server Output |
| 37 | |
| 38 | ``` |
| 39 | Registering opentelemetry stdout exporter. |
| 40 | Starting the GRPC server, and using the OpenCensus binary propagation format. |
| 41 | [ |
| 42 | { |
| 43 | "SpanContext": { |
| 44 | "TraceID": "9d59b1bdbde34cdaac6cfb5b8f3c4685", |
| 45 | "SpanID": "94738571415fdb63", |
| 46 | "TraceFlags": 1 |
| 47 | }, |
| 48 | "ParentSpanID": "07733a2559ef492d", |
| 49 | ... |
| 50 | } |
| 51 | ] |
| 52 | ``` |
| 53 | |
| 54 | The TraceID matches the TraceID from the OpenCensus client span, and the ParentSpanID matches the SpanID of the OpenCensus client span. |