This project adds OpenTelemetry instrumentation (https://github.com/open-telemetry/opentelemetry-go) to Go applications by automatically modifying their source code in similar way as compiler. It can instrument any golang project. It depends only on standard libraries and is platform agnostic.
In order to instrument your project you have to add following call in your entry point function, usually main (you can look at tests directory for reference) and invoke autotel tool.
func main() {
rtlib.AutotelEntryPoint__()
Autotel requires three parameters: command, path to project and package(s) pattern we would like to instrument.
./autotel --inject [path to your go project] [package(s) pattern]
Below concrete example with one of test instrumentation that is part of the project.
./autotel --inject ./tests/fib ./...
./...
works like wildcard in this case and it will instrument all packages in this path, but it can be invoked with
specific package as well
./autotel --inject ./tests/fib github.com/pdelewski/autotel/tests/fib
There are few passes during execution.
- Search for entry point, a function definition with
AutotelEntryPoint__()
call. - Building call graph. Traversing all calls from entry point through all function definitions.
- Injecting open telemetry calls into functions bodies. (The order of 3 and 4 has been changed and now injecting open telemetry calls pass is before context propagation due to fact of changing type signatures by context propagation)
- Context propagation. Adding additional context parameter to all function declarations and function call expressions that are visible (it will not add context argument to call expression without having visible function declaration).
This project is actively maintained by Sumo Logic and is currently in it's initial days. We would love to receive your ideas, feedback & contributions.
We welcome issues, questions, and pull requests.
This project is licensed under the terms of the Apache 2.0 open source license. Please refer to LICENSE for the full terms.