Troubleshooting the Middleware Go APM
If you encounter issues or don't see data appearing in your Middleware.io dashboard, here are common troubleshooting steps.
Check Configuration:
- API Key (
accessToken
) and Target URL (target
): Double-check that yourMW_API_KEY
(oraccessToken
intrack.Track
) andMW_TARGET
(ortarget
) are correctly set and free of typos. These are critical for connecting to Middleware.io. - Service Name (
service
): EnsureMW_SERVICE_NAME
(orservice
intrack.Track
) is set. This is how your application is identified in the Middleware.io UI. - Environment Variables vs. Code: Remember that environment variables take precedence. If you're setting values in code and they don't seem to apply, check if an environment variable is overriding them.
- API Key (
Verify Agent Initialization:
- Ensure
track.Track()
is called exactly once at the beginning of yourmain
function. - Confirm that
defer config.Shutdown()
is present to properly flush telemetry data on exit. Without this, some data might be lost.
- Ensure
Check Go Module Installation:
Verify dependencies: After
go get
commands, ensure yourgo.mod
file has entries likegithub.com/middleware-labs/golang-apm/tracker
.Run
go mod tidy
: This command cleans up yourgo.mod
andgo.sum
files by removing unused dependencies and adding any missing ones necessary for your project. Run it after adding newgo get
dependencies.go mod tidy
Explanation:
go mod tidy
ensures thatgo.mod
accurately reflects the project's imports and thatgo.sum
contains correct checksums for all dependencies. Expected Output (if changes are made):go: added <some_dependency> vX.Y.Z go: removed <some_unused_dependency>
(No output if everything is already tidy.)
Run
go mod vendor
(if using vendoring): If your project uses Go modules' vendoring feature (where dependencies are copied into avendor
directory within your project), ensure you run this command.go mod vendor
Explanation:
go mod vendor
copies all necessary dependencies into a localvendor/
directory, allowing your build to be completely isolated from network access to module proxies. This is common in some CI/CD environments. Expected Output (similar to):go: vendoring modules in <your_project_path>/vendor
Increase Agent Logging Level:
- Set the
MW_LOG_LEVEL
environment variable toDEBUG
(e.g.,export MW_LOG_LEVEL=DEBUG
) or usetrack.WithConfigTag("logLevel", "DEBUG")
during initialization. - Examine your application's console output for any log messages from
middleware-io
oropentelemetry
. Look forERROR
orWARN
messages that indicate connection issues, authentication failures, or processing problems. You should see messages indicating successful initialization and data export.
- Set the
Network Connectivity:
From the host or container where your Go application is running, try to
ping
orcurl
yourMW_TARGET
URL to confirm network reachability on port 443.curl -v -o /dev/null -s -w "%{http_code}\n" https://your_middleware_uid.middleware.io:443
Explanation: This command attempts to make an HTTPS connection. A
200
or30X
HTTP status code indicates a successful connection to the endpoint. Expected Output (for successful connection):* Trying <IP_ADDRESS>:443... * Connected to your_middleware_uid.middleware.io (<IP_ADDRESS>) port 443 * ALPN: offers h2 * ALPN: offers http/1.1 ... < HTTP/1.1 200 OK ... 200
(If you see "Connection refused", "Operation timed out", or similar, it indicates a network issue.)
Check firewall rules, security groups, or proxy configurations that might be blocking outbound HTTPS traffic to the Middleware.io ingestion endpoint.
Application Activity:
Ensure your application is actively handling requests or performing operations that would generate traces, metrics, and logs. If your Go web server isn't receiving requests, there won't be any APM data. Manually make some requests to your application's endpoints using
curl
or a web browser.curl http://localhost:8080/hello
Expected Output:
{"message":"Hello from Go APM!"}
(And you should see corresponding logs in your application's console if
MW_CONSOLE_EXPORTER
is true.)Resource Limits (Kubernetes/Containers): In containerized environments, confirm that your pods have sufficient CPU and memory resources. A resource-starved application or agent might struggle to process and export telemetry data. Review your Kubernetes
resource
limits and requests.
Time Synchronization:
- Ensure the system clock on your application host is synchronized using NTP. Significant clock drift can lead to issues with timestamping and data correlation in observability platforms.
OpenTelemetry Compatibility:
- Middleware.io's agent is OpenTelemetry-native. If you're using other OpenTelemetry libraries directly, ensure they are compatible and correctly configured to use the global
TracerProvider
andMeterProvider
initialized bymiddleware-io/golang-apm/tracker
.
- Middleware.io's agent is OpenTelemetry-native. If you're using other OpenTelemetry libraries directly, ensure they are compatible and correctly configured to use the global