Slackbot
07/07/2022, 11:30 AMnitya-signoz
07/07/2022, 11:42 AMShreyas Mishra
07/07/2022, 11:44 AMShreyas Mishra
07/07/2022, 11:46 AMif err := db.Use(otelgorm.NewPlugin()); err != nil {
panic(err)
}
using it like this
if err := DB.WithContext(ctx).Model(&Dbuse{}).Where("something = ", value).Error; err != nil {
return
}
nitya-signoz
07/07/2022, 11:50 AMdb
and DB
are two different variables or they are the same ?Shreyas Mishra
07/07/2022, 11:53 AMShreyas Mishra
07/07/2022, 11:53 AMShreyas Mishra
07/07/2022, 11:55 AMfunc connectDB() *gorm.DB {
dsn := ""
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
fmt.Println("error")
return nil
}
db.AutoMigrate(&Dbuse{})
if err := db.Use(otelgorm.NewPlugin()); err != nil {
panic(err)
}
fmt.Println("DB connected")
return db
}
DB = connectDB()
if err := DB.WithContext(ctx).Model(&Dbuse{}).Where("something = ", "somevalue").Error; err != nil {
return
}
nitya-signoz
07/07/2022, 12:03 PMexporter, err := stdouttrace.New(
stdouttrace.WithWriter(os.Stdout),
stdouttrace.WithPrettyPrint(),
stdouttrace.WithoutTimestamps(),
)
and try running the application and check if the traces are generated. This way we will know if it’s a instrumentation problem or a problem on signoz.Shreyas Mishra
07/07/2022, 12:06 PM{
"Name": "testing func",
"SpanContext": {
"TraceID": "5ed96977eba66e713e4cbbf2649aa170",
"SpanID": "3f1f8a03b6fa0c8e",
"TraceFlags": "01",
"TraceState": "",
"Remote": false
},
"Parent": {
"TraceID": "5ed96977eba66e713e4cbbf2649aa170",
"SpanID": "6271e1ff1b13427f",
"TraceFlags": "01",
"TraceState": "",
"Remote": false
},
"SpanKind": 1,
"StartTime": "0001-01-01T00:00:00Z",
"EndTime": "0001-01-01T00:00:00Z",
"Attributes": [
{
"Key": "goApp",
"Value": {
"Type": "STRING",
"Value": "testfunc"
}
}
],
"Events": [
{
"Name": "This is a sample event in test1",
"Attributes": [
{
"Key": "pid",
"Value": {
"Type": "INT64",
"Value": 4329
}
},
{
"Key": "sampleAttribute",
"Value": {
"Type": "STRING",
"Value": "TestFunc"
}
}
],
"DroppedAttributeCount": 0,
"Time": "0001-01-01T00:00:00Z"
}
],
"Links": null,
"Status": {
"Code": "Unset",
"Description": ""
},
"DroppedAttributes": 0,
"DroppedEvents": 0,
"DroppedLinks": 0,
"ChildSpanCount": 0,
"Resource": [
{
"Key": "library.language",
"Value": {
"Type": "STRING",
"Value": "go"
}
},
{
"Key": "service.name",
"Value": {
"Type": "STRING",
"Value": "goApp"
}
}
],
"InstrumentationLibrary": {
"Name": "test",
"Version": "",
"SchemaURL": ""
}
}
{
"Name": "/test1",
"SpanContext": {
"TraceID": "5ed96977eba66e713e4cbbf2649aa170",
"SpanID": "6271e1ff1b13427f",
"TraceFlags": "01",
"TraceState": "",
"Remote": false
},
"Parent": {
"TraceID": "00000000000000000000000000000000",
"SpanID": "0000000000000000",
"TraceFlags": "00",
"TraceState": "",
"Remote": false
},
"SpanKind": 2,
"StartTime": "0001-01-01T00:00:00Z",
"EndTime": "0001-01-01T00:00:00Z",
"Attributes": [
{
"Key": "net.transport",
"Value": {
"Type": "STRING",
"Value": "ip_tcp"
}
},
{
"Key": "net.peer.ip",
"Value": {
"Type": "STRING",
"Value": "::1"
}
},
{
"Key": "net.peer.port",
"Value": {
"Type": "INT64",
"Value": 56184
}
},
{
"Key": "net.host.name",
"Value": {
"Type": "STRING",
"Value": "localhost"
}
},
{
"Key": "net.host.port",
"Value": {
"Type": "INT64",
"Value": 8080
}
},
{
"Key": "http.method",
"Value": {
"Type": "STRING",
"Value": "POST"
}
},
{
"Key": "http.target",
"Value": {
"Type": "STRING",
"Value": "/test1"
}
},
{
"Key": "http.server_name",
"Value": {
"Type": "STRING",
"Value": "goApp"
}
},
{
"Key": "http.route",
"Value": {
"Type": "STRING",
"Value": "/test1"
}
},
{
"Key": "http.user_agent",
"Value": {
"Type": "STRING",
"Value": "PostmanRuntime/7.29.0"
}
},
{
"Key": "http.scheme",
"Value": {
"Type": "STRING",
"Value": "http"
}
},
{
"Key": "http.host",
"Value": {
"Type": "STRING",
"Value": "localhost:8080"
}
},
{
"Key": "http.flavor",
"Value": {
"Type": "STRING",
"Value": "1.1"
}
},
{
"Key": "goApp",
"Value": {
"Type": "STRING",
"Value": "endpoint1new"
}
}
],
"Events": [
{
"Name": "This is a sample event in test1",
"Attributes": [
{
"Key": "pid",
"Value": {
"Type": "INT64",
"Value": 4328
}
},
{
"Key": "sampleAttribute",
"Value": {
"Type": "STRING",
"Value": "Test1"
}
}
],
"DroppedAttributeCount": 0,
"Time": "0001-01-01T00:00:00Z"
}
],
"Links": null,
"Status": {
"Code": "Unset",
"Description": ""
},
"DroppedAttributes": 0,
"DroppedEvents": 0,
"DroppedLinks": 0,
"ChildSpanCount": 1,
"Resource": [
{
"Key": "library.language",
"Value": {
"Type": "STRING",
"Value": "go"
}
},
{
"Key": "service.name",
"Value": {
"Type": "STRING",
"Value": "goApp"
}
}
],
"InstrumentationLibrary": {
"Name": "<http://go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux|go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux>",
"Version": "semver:0.32.0",
"SchemaURL": ""
}
}
nitya-signoz
07/07/2022, 12:23 PM{
"Name": "gorm.Query",
.....
"InstrumentationLibrary": {
"Name": "<http://github.com/uptrace/opentelemetry-go-extra/otelgorm|github.com/uptrace/opentelemetry-go-extra/otelgorm>",
"Version": "",
"SchemaURL": ""
}
}
would have been printed.nitya-signoz
07/07/2022, 12:25 PMShreyas Mishra
07/08/2022, 12:13 PMnitya-signoz
07/08/2022, 12:28 PMVishal Sharma
07/12/2022, 8:19 AMShreyas Mishra
07/12/2022, 8:56 AMdb.where()
its working for create delete and updateShreyas Mishra
07/12/2022, 8:57 AM