You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the 2nd ExitSpan, ctx.ActiveSpan() returns nil, Then createSpan0() returns NoopSpan.
The following is debug mode: Gin CreateEntrySpan,ctx:
The first CreateExitSpan within the goroutine, ctx:
Second CreateExitSpan inside goroutine, ctx:
What you expected to happen
In the first ExitSpan, The stackCount of ActiveSpan() obtained by GetTracingContext() should be 1.
in the 2nd ExitSpan, getTracingContext() -> ActiveSpan() Should not be nil.
How to reproduce
After changing the sampling rate to 0, run the following test code.
package main
import (
"fmt"
_ "github.com/apache/skywalking-go"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"golang.org/x/sync/errgroup"
)
type ErrorGroup struct {
errgroup.Group
}
func main() {
r := gin.Default()
r.GET("/mongo_get", mongoGet)
r.Run()
}
func mongoGet(c *gin.Context) {
var e ErrorGroup
var m, _ = mongo.Connect(c, options.Client().ApplyURI("mongodb://127.0.0.1:27017"))
filter := bson.D{{"name", "test"}}
e.Go(func() (err error) {
collection := m.Database("demo").Collection("testCollection")
_, err = collection.Find(c, filter)
if err != nil {
return err
}
fmt.Println("first Find Done")
_, err = collection.Find(c, filter)
if err != nil {
return err
}
fmt.Println("second Find Done")
return nil
})
err := e.Wait()
if err != nil {
fmt.Println(err)
}
}
Observe the log, you can find that the log will print the following error: cannot create exit span on mongo client: span type is wrong
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Yes I am willing to submit a pull request on my own!
Search before asking
Apache SkyWalking Component
Go Agent (apache/skywalking-go)
What happened
In the following scenario, Gin handler serves as the entry point and calls 2 mongo operations through goroutine.
Gin -- EntrySpan (NewNoopSpan() -> SET_GLS(NoopSpan{stackCount: 1}))
|
(sync.Group)
MongoClient ExitSpan (GET_GLS() -> NoopSpan{stackCount:0} -> noop.enterNoSpan() -> span.End() -> SET_GLS(nil) )
| (Why stackCount is 0 ?)
MongoClient ExitSpan (GET_GLS() -> nil)
In the 2nd ExitSpan, ctx.ActiveSpan() returns nil, Then createSpan0() returns NoopSpan.

The following is debug mode:

Gin CreateEntrySpan,ctx:
The first CreateExitSpan within the goroutine, ctx:

Second CreateExitSpan inside goroutine, ctx:

What you expected to happen
In the first ExitSpan, The stackCount of ActiveSpan() obtained by GetTracingContext() should be 1.
in the 2nd ExitSpan, getTracingContext() -> ActiveSpan() Should not be nil.
How to reproduce
After changing the sampling rate to 0, run the following test code.
Observe the log, you can find that the log will print the following error:
cannot create exit span on mongo client: span type is wrong
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Code of Conduct
The text was updated successfully, but these errors were encountered: