Home

Awesome

otelinji

Version Build Status Go Report Card go-recipes Coverage Status

OpenTelemetry auto-instrumentation tool. It injects a common tracing block to all exported functions.

OpenTelemetry diff

Features:

Installation

MacOS/Linux HomeBrew

brew install hedhyw/main/otelinji

Deb/Rpm

Latest DEB and RPM packages are available on the releases page.

Go

go install github.com/hedhyw/otelinji/cmd/otelinji@latest

Source

git 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/bin

Usage

Basic usage

Inject the layer and rewrite the file (be careful, always commit all changes first).

Recursive run

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 -filename

The 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 \
      "

Help

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]

IDE

License

MIT.