1 回答

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊
既然您沒(méi)有在上面提到它:您是否檢測(cè)了 Go 應(yīng)用程序?Elastic APM Go“代理”是一個(gè)用于檢測(cè)應(yīng)用程序源代碼的包。它不是一個(gè)獨(dú)立的進(jìn)程,而是在您的應(yīng)用程序中運(yùn)行。
因此,首先(如果您還沒(méi)有)檢測(cè)您的應(yīng)用程序。請(qǐng)參閱https://www.elastic.co/guide/en/apm/agent/go/current/getting-started.html#instrumenting-source
這是一個(gè)使用Echo和apmechov4檢測(cè)模塊的示例 Web 服務(wù)器:
package main
import (
"fmt"
"net/http"
echo "github.com/labstack/echo/v4"
"go.elastic.co/apm/module/apmechov4"
)
func main() {
e := echo.New()
e.Use(apmechov4.Middleware())
e.GET("/hello/:name", func(c echo.Context) error {
fmt.Println(c.Param("name"))
return nil
})
http.ListenAndServe(":8080", e)
}
如果您運(yùn)行它并向 發(fā)送一些請(qǐng)求http://localhost:8080/hello/world,您應(yīng)該很快就會(huì)在 Kibana 的 APM 應(yīng)用程序中看到請(qǐng)求。
如果您在 Kibana 中仍然看不到任何內(nèi)容,可以按照https://www.elastic.co/guide/en/apm/agent/go/current/troubleshooting.html#agent-logging啟用日志記錄。如果代理能夠成功地將數(shù)據(jù)發(fā)送到服務(wù)器,您可以看到以下內(nèi)容:
$ ELASTIC_APM_LOG_FILE=stderr ELASTIC_APM_LOG_LEVEL=debug go run main.go
{"level":"debug","time":"2020-08-19T13:33:28+08:00","message":"sent request with 3 transactions, 0 spans, 0 errors, 0 metricsets"}
{"level":"debug","time":"2020-08-19T13:33:46+08:00","message":"gathering metrics"}
{"level":"debug","time":"2020-08-19T13:33:56+08:00","message":"sent request with 0 transactions, 0 spans, 0 errors, 3 metricsets"}
另一方面,如果服務(wù)器無(wú)法訪問(wèn),您會(huì)看到如下內(nèi)容:
{"level":"error","time":"2020-08-19T13:38:01+08:00","message":"config request failed: sending config request failed: Get \"http://localhost:8200/config/v1/agents?service.name=main\": dial tcp 127.0.0.1:8200: connect: connection refused"}
- 1 回答
- 0 關(guān)注
- 192 瀏覽
添加回答
舉報(bào)