Golang APM

Get the most out of Middleware OpsAI for your Go applications by using the Middleware Golang SDK (version 1.7.0 or newer) and Gin Middleware (version 1.0.0 or newer).

🚀 Key Features

  • Captures exception and error details automatically
  • Works with popular Go frameworks like Gin
  • Function code recording for all files
  • Library file detection for better error tracking

🛠️ APM Setup

  1. Install the Middleware packages:

  2. Initialize the tracker at the top of your main file:

⚡ Exception Code Capturing

The SDK automatically captures:

  • Exception types and messages
  • Stack traces with line numbers
  • Function names and bodies
  • File paths and line ranges
  • Library file detection (for files in /go/src, /go/pkg/mod, vendor, and third_party directories)

⚙️ VCS Metadata Configuration

Middleware can automatically detect VCS (Version Control System) metadata from your .git directory, similar to Node.js and Python implementations. This helps Middleware suggest fixes and even open GitHub pull requests for you.

Automatic Detection

The SDK will automatically detect:

  • Git commit SHA
  • Repository URL from your project's .git directory. No additional configuration is needed if your project is a git repository.

Manual Configuration

If you need to override the automatic detection or if your project is not a git repository, you can set these environment variables:

This lets Middleware know exactly which version of your code is running, so it can suggest the right fix and even create a solution PR for you.

📚 Resources