We want to start adding basic tracing into graphsync. The request manager is simpler cause each request starts with a context. Our main challenge is setting up tracing across go routines.
How open telemetry works
OpenTelemetry is an API for tracer that can be backed by one or more actual libraries to export data to a tracing service. Fortunately, in Graphsync, we are NOT concerned with configuring data export -- that is left to the consumer of go-graphsync. However, we would like, if someone sets up a program with open telemetry tracing configured, for graphsync to provide useful trace information within the context whatever tracing the calling program has setup.
Note: this is a basic setup just to insure we have two traces inside and outside the go-routine. We will likely add more tracing to the request manager later
What
We want to start adding basic tracing into graphsync. The request manager is simpler cause each request starts with a context. Our main challenge is setting up tracing across go routines.
How open telemetry works
OpenTelemetry is an API for tracer that can be backed by one or more actual libraries to export data to a tracing service. Fortunately, in Graphsync, we are NOT concerned with configuring data export -- that is left to the consumer of go-graphsync. However, we would like, if someone sets up a program with open telemetry tracing configured, for graphsync to provide useful trace information within the context whatever tracing the calling program has setup.
You can find a basic OpenTelemtry example here
We'll tackle the RequestManager first.
Requirements
First, we need to create a tracer at the top level in the main implementation at start time and pass it down to the request manager.
The call we use is documented here -- we can simply name our instrumentation "graphsync".
Now, we want to properly instrument a request.