Closed rysinal closed 2 years ago
@rysinal It looks like GRPCReporter
was closed early, please check your code :)
@rysinal It looks like
GRPCReporter
was closed early, please check your code :)
@arugal I tested the following scenarios
func RunWindowsServer() {
Router := initialize.Routers()
// The code for skywalking is placed here,it's just record /user/:name ,but not initialize.Routers()
rp, err := reporter.NewGRPCReporter("10.0.xx.xxx:11800", reporter.WithCheckInterval(time.Second))
if err != nil {
global.GVA_LOG.Error("new reporter error", zap.Error(err))
}
defer rp.Close()
tracer, err := go2sky.NewTracer(os.Getenv("SW_AGENT_NAME"), go2sky.WithReporter(rp), go2sky.WithInstance(os.Getenv("SW_AGENT_INSTANCE")))
if err != nil {
global.GVA_LOG.Error("create tracer error", zap.Error(err))
}
Router.Use(v3.Middleware(Router, tracer))
Router.GET("/user/:name", func(c *gin.Context) {
name := c.Param("name")
c.String(http.StatusOK, "Hello %s", name)
})
Router.Run(":8000")
}
1、This code will cause the initialize.Routers() method route above to not be injected into skywalking, but the /user/:name route at the bottom to be injected properly 2、When the code of skywalking is put into the initialize.Routers() function, it will report an error,
send keep alive signal error rpc error: code = Unavailable desc = error reading from server: read tcp 10.85.xx.xx:64424->10.0.xx.xx:11800: use of closed network connection
Just like the following sample code
func Routers() *gin.Engine {
Router := gin.Default()
rp, err := reporter.NewGRPCReporter("10.0.xx.xxx:11800", reporter.WithCheckInterval(time.Second))
if err != nil {
global.GVA_LOG.Error("new reporter error", zap.Error(err))
}
defer rp.Close()
tracer, err := go2sky.NewTracer(os.Getenv("SW_AGENT_NAME"), go2sky.WithReporter(rp), go2sky.WithInstance(os.Getenv("SW_AGENT_INSTANCE")))
if err != nil {
global.GVA_LOG.Error("create tracer error", zap.Error(err))
}
Router.Use(v3.Middleware(Router, tracer))
Router.GET("/user/:name", func(c *gin.Context) {
name := c.Param("name")
c.String(http.StatusOK, "Hello %s", name)
})
return Router
}
I just started to learn golang, please help to see where the problem, thanks!:)
func Routers() *gin.Engine {
Router := gin.Default()
rp, err := reporter.NewGRPCReporter("10.0.xx.xxx:11800", reporter.WithCheckInterval(time.Second))
if err != nil {
global.GVA_LOG.Error("new reporter error", zap.Error(err))
}
defer rp.Close()
tracer, err := go2sky.NewTracer(os.Getenv("SW_AGENT_NAME"), go2sky.WithReporter(rp), go2sky.WithInstance(os.Getenv("SW_AGENT_INSTANCE")))
if err != nil {
global.GVA_LOG.Error("create tracer error", zap.Error(err))
}
Router.Use(v3.Middleware(Router, tracer))
Router.GET("/user/:name", func(c *gin.Context) {
name := c.Param("name")
c.String(http.StatusOK, "Hello %s", name)
})
return Router
}
Just like your code, GRPCReporter
closed by defer rp.Close()
.
Describe the bug
first set env:
and this is my demo code:
i got an error message when my project start or access some api interface, and i can't see any message from skywalking-ui
To Reproduce Steps to reproduce the behavior:
Expected behavior can send trace message to the oap server
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.