{"repo":"nikolaydubina/go-instrument","free":true,"listed":false,"github":"https://github.com/nikolaydubina/go-instrument","clone":"git clone https://github.com/nikolaydubina/go-instrument.git","description":"⚡️ Automatically add Trace Spans to Go functions","language":"Go","stars":299,"topics":["go","golang","datadog","instrumentation","newrelic","opentelemetry","monitoring","ast","tooling","auto-instrumentation"],"license":"MIT","category":"analytics","readme_excerpt":"⚡️ go-instrument Automatically add Trace Spans to Go functions Functions with context.Context in arguments will be instrumented with span Example HTTP server go-instrument-example as it appears in Datadog. This tool uses standard Go library to modify AST with instrumentation. You can add new instrumentations by defining your own Instrumenter and invoking Processor like it is done in main . Motivation It is laborious to add tracing code to every function manually. The code repeats 99% of time. Other languages can either modify code or have wrapper notations that makes even manual tracing much less laborious. As of 2025-05-11 , official Go does not support automatic function traces[^2]. Is there a way to automatically intercept each function call and create traces? Go doesn’t provide a way to automatically intercept every function call and create trace spans. You need to manually instrument your code to create, end, and annotate spans. Thus, providing automated version to add Trace Spans annotation. Performance Go Compiler Inlining Since we are adding multiple functions calls, it affects Go compiler decisions on inlining. It is expected that Go will less likely inline. For example, can inline function Can not inline after instrumentation Appendix A: Related Work https://github.com/hedhyw/otelinji — Very similar to current project. This tool gracefully handles code comments, so that its output can be tracked with normal code in version control. Main difference current project fo","default_branch":null,"files":null,"tree":[],"storefront":"/r/nikolaydubina","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/nikolaydubina/go-instrument/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}