neo4jtracing
is a go library that enables otel distribute tracing for neo4j driver v5.
Add this library as a dependency via go get github.com/raito-io/neo4j-tracing
Tracing can be enabled by using the neo4j_tracing.Neo4jTracer
object.
The Neo4jTracer
a factory that creates neo4j.DriverWithContext
objects that are wrapped so distributed tracing can be applied.
Start using tracing is very easy. A regular neo4j driver will be created as follows:
package main
import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)
func main() {
dbUri := "neo4j://localhost" // scheme://host(:port) (default port is 7687)
driver, err := neo4j.NewDriverWithContext(dbUri, neo4j.BasicAuth("neo4j", "letmein!", ""))
if err != nil {
panic(err)
}
// Do something useful
}
To enable tracing you need to create your driver by using the Neo4jTracer
object.
package main
import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
neo4j_tracing "github.com/raito-io/neo4j-tracing"
)
func main() {
driverFactory := neo4j_tracing.NewNeo4jTracer()
dbUri := "neo4j://localhost" // scheme://host(:port) (default port is 7687)
driver, err := driverFactory.NewDriverWithContext(dbUri, neo4j.BasicAuth("neo4j", "letmein!", ""))
if err != nil {
panic(err)
}
// Do something useful
}
The following options could be used to customize the tracing behavior:
WithTracerProvider(provider)
: Specifies a custom tracer provider. By default, the global OpenTelemetry tracer provider is used.
Those options are passed as argument to the neo4j_tracing.NewNeo4jTracer()
function.