This guide provides a detailed overview of configuring and using the otel tool effectively. This tool allows you to set various configuration options, build your projects, and customize your workflow for optimal performance.
The primary method of configuring the tool is through the otel set command. This command allows you to specify various settings tailored to your needs:
Logging: Set a custom log file to store logs generated by the tool.
$ otel set -log=/path/to/file.logThe default log file is .otel-build/preprocess/debug.log. You can
log to stdout by setting -log=/dev/stdout.
Verbose Logging: Enable verbose logging to receive detailed output from the tool, which is helpful for troubleshooting and understanding the tool's processes.
$ otel set -verboseDebug Mode: Turn on debug mode to gather debug-level insights and information.
$ otel set -debugMultiple Configurations: Set multiple configurations at once. For instance, enable both debug and verbose modes while using a custom rule file:
$ otel set -debug -verbose -rule=custom.jsonCustom Rules Only: Disable the default rule set and apply only specific custom rules. This is particularly useful when you need a tailored rule set for your project.
$ otel set -disabledefault -rule=custom.jsonCombination of Default and Custom Rules: Use both the default rules and custom rules to provide a comprehensive configuration:
$ otel set -rule=custom.jsonMultiple Rule Files: Combine multiple custom rule files along with the default rules, which can be specified as a comma-separated list:
$ otel set -rule=a.json,b.jsonIn addition to using the otel set command, configuration can also be overridden using environment variables. For example, the OTELTOOL_DEBUG environment variable allows you to force the tool into debug mode temporarily, making this approach effective for one-time configurations without altering permanent settings.
$ export OTELTOOL_DEBUG=true
$ export OTELTOOL_VERBOSE=trueThe names of the environment variables correspond to the configuration options available in the otel set command with the OTELTOOL_ prefix.
Full List of Environment Variables:
OTELTOOL_DEBUG: Enable debug mode.OTELTOOL_VERBOSE: Enable verbose logging.OTELTOOL_RULE_JSON_FILES: Specify custom rule files.OTELTOOL_DISABLE_DEFAULT: Disable default rules.
This approach provides flexibility for testing changes and experimenting with configurations without permanently altering your existing setup.
Once configurations are in place, you can build your project with prefixed otel commands. This integrates the tool's configuration directly into the build process:
Standard Build: Build your project with default settings.
$ otel go buildOutput to Specific Location: Build your project and specify an output location.
$ otel go build -o app cmd/appPassing Compiler Flags: Use compiler flags for more customized builds.
$ otel go build -gcflags="-m" cmd/appNo matter how complex your project is, the otel tool simplifies the process by automatically instrumenting your code for effective observability, the only requirement being the addition of the otel prefix to your build commands.