OpenTelemetry auto-instrumentation tool. It injects a common tracing block to all exported functions.
Features:
- Custom templates are supported. Example: template.
- If the function contains a named
errresult parameter, thenerrwill be recorded in the span. - It supports different names of
ctxparameter. - This can also be used with OpenTracing, but will require a custom template.
- Using creativity, this can be used for any inserts at the beginning of the function.
brew install hedhyw/main/otelinjiLatest DEB and RPM packages are available on the releases page.
go install github.com/hedhyw/otelinji/cmd/otelinji@latestgit clone git@github.com:hedhyw/otelinji.git
cd gherkingen
task build # Requires https://taskfile.dev/
cp ./bin/gherkingen /usr/local/bin
chmod +x /usr/local/binInject the layer and rewrite the file (be careful, always commit all changes first).
-
otelinji -filename input_file.go > input_file.goor
-
otelinji -w -filename input_file.goor in docker
-
docker run \ --rm \ --read-only \ --network none \ --rm \ --volume $PWD:/host \ hedhyw/otelinji:latest \ -filename /host/internal/pkg/assets/assets_test.go
Running for all Go files in the current directory.
# It will inject the layer to all exported functions.
# It will ignore vendor and .git folders, test and generated files.
find . -name "*.go" \
| grep -v "vendor/\|.git/\|_test.go" \
| xargs -n 1 -t otelinji -w -filenameThe same in docker:
docker run \
--rm \
--read-only \
--network none \
--volume $PWD:/host \
--entrypoint sh \
hedhyw/otelinji:latest \
-c " \
find /host -name \"*.go\" \
| grep -v \"vendor/\|.git/\|_test.go\" \
| xargs -n 1 -t /app/otelinji -w -filename \
"otelinji --help
Usage of otelinji:
-filename string
golang file [required]
-skip-generated DO NOT EDIT
skip files with DO NOT EDIT comment (default true)
-template string
path to template file [optional] (default "@/otel")
-version
print application version and quit
-w write result to file [optional]
MIT.
