This message was deleted.
# support
s
This message was deleted.
n
Did you initialize the tracer as given in the example https://github.com/SigNoz/sample-golang-app/blob/90aa1f10cb5ec4e543c705851d7e4092022cdb31/main.go#L71 ? Also you are not able to see it on Services page or Traces page or both ?
s
yup did as given in the example and not able to see it on both the page
Copy code
if err := db.Use(otelgorm.NewPlugin()); err != nil {
		panic(err)
	}
using it like this
Copy code
if err := DB.WithContext(ctx).Model(&Dbuse{}).Where("something = ", value).Error; err != nil {
		return
	}
n
db
and
DB
are two different variables or they are the same ?
s
same variable
DB is a global variable
Copy code
func 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
}
Copy code
DB = connectDB()
    	if err := DB.WithContext(ctx).Model(&Dbuse{}).Where("something = ", "somevalue").Error; err != nil {
		return
	}
n
In your initTracer function change your exporter to stdout like this
Copy code
exporter, 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.
s
Copy code
{
        "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": ""
        }
}
n
This means that it’s an issue with the code. If it was properly instrumented a span like
Copy code
{
	"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.
👍 1
@Vishal Sharma do you have idea about what might be the issue here ?
s
hey,any idea what i can do to receive the trace
n
Can you try comparing if the versions of different packages like otel, db, tracing library etc are similar to the one present in the example, given that your code is similar as the one we have in example.
👍 1
v
@Shreyas Mishra Were you able to solve it?
s
yes i was i went through the uptrace repo and apparently there is no option to generate trace for
db.where()
its working for create delete and update
i have successfully deployed the tracing in production
1