lotus/documentation/en/dev-tools-jaegar-tracing.md

35 lines
1.3 KiB
Markdown
Raw Normal View History

# Tracing
2019-12-04 15:39:41 +00:00
Lotus has tracing built into many of its internals. To view the traces, first download [Jaeger](https://www.jaegertracing.io/download/) (Choose the 'all-in-one' binary). Then run it somewhere, start up the lotus daemon, and open up localhost:16686 in your browser.
## Open Census
2019-10-14 01:44:11 +00:00
Lotus uses [OpenCensus](https://opencensus.io/) for tracing application flow.
This generates spans
through the execution of annotated code paths.
2019-12-04 15:39:41 +00:00
Currently it is set up to use Jaeger, though other tracing backends should be
2019-10-14 01:44:11 +00:00
fairly easy to swap in.
## Running Locally
To easily run and view tracing locally, first, install jaeger. The easiest way
to do this is to [download the binaries](https://www.jaegertracing.io/download/) and then run the `jaeger-all-in-one`
2019-10-14 01:44:11 +00:00
binary. This will start up jaeger, listen for spans on `localhost:6831`, and
expose a web UI for viewing traces on `http://localhost:16686/`.
2019-12-04 15:39:41 +00:00
Now, to start sending traces from Lotus to Jaeger, set the environment variable
2019-10-14 01:44:11 +00:00
`LOTUS_JAEGER` to `localhost:6831`, and start the `lotus daemon`.
Now, to view any generated traces, open up `http://localhost:16686/` in your
browser.
## Adding Spans
2019-10-14 01:44:11 +00:00
To annotate a new codepath with spans, add the following lines to the top of the function you wish to trace:
```go
ctx, span := trace.StartSpan(ctx, "put function name here")
defer span.End()
```