neo4j_tracing

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 4

README

RAITO - Neo4J Tracing

Version Build Contribute Go version Software License Go Reference

Introduction

neo4jtracing is a go library that enables otel distribute tracing for neo4j driver v5.

Getting Started

Add this library as a dependency via go get github.com/raito-io/neo4j-tracing

Enable 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
}
Options

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BookmarkManagerTracer

type BookmarkManagerTracer struct {
	// Actual neo4j BookmarkManager
	neo4j.BookmarkManager
	// contains filtered or unexported fields
}

BookmarkManagerTracer wraps a neo4j.BookmarkManager object so the calls can be traced with open telemetry distributed tracing

func (*BookmarkManagerTracer) GetBookmarks

func (b *BookmarkManagerTracer) GetBookmarks(ctx context.Context) (_ neo4j.Bookmarks, err error)

GetBookmarks calls neo4j.BookmarkManager.GetBookmarks and trace the call

func (*BookmarkManagerTracer) UpdateBookmarks

func (b *BookmarkManagerTracer) UpdateBookmarks(ctx context.Context, previousBookmarks, newBookmarks neo4j.Bookmarks) (err error)

UpdateBookmarks calls neo4j.BookmarkManager.UpdateBookmarks and trace the call

type DriverWithContextTracer

type DriverWithContextTracer struct {
	neo4j.DriverWithContext
	// contains filtered or unexported fields
}

func (*DriverWithContextTracer) ExecuteQueryBookmarkManager

func (n *DriverWithContextTracer) ExecuteQueryBookmarkManager() neo4j.BookmarkManager

ExecuteQueryBookmarkManager calls neo4j.DriverWithContext.ExecuteQueryBookmarkManager and wraps the resulting neo4j.BookmarkManager with a tracing object

func (*DriverWithContextTracer) GetServerInfo

func (n *DriverWithContextTracer) GetServerInfo(ctx context.Context) (_ neo4j.ServerInfo, err error)

GetServerInfo calls neo4j.GetServerInfo.VerifyConnectivity and trace the call

func (*DriverWithContextTracer) NewSession

NewSession calls neo4j.DriverWithContext.NewSession and wraps the resulting neo4j.SessionWithContext with a tracing object

func (*DriverWithContextTracer) VerifyAuthentication

func (n *DriverWithContextTracer) VerifyAuthentication(ctx context.Context, auth *neo4j.AuthToken) (err error)

VerifyAuthentication calls neo4j.DriverWithContext.VerifyAuthentication and trace the call

func (*DriverWithContextTracer) VerifyConnectivity

func (n *DriverWithContextTracer) VerifyConnectivity(ctx context.Context) (err error)

VerifyConnectivity calls neo4j.DriverWithContext.VerifyConnectivity and trace the call

type ExplicitTransactionTracer

type ExplicitTransactionTracer struct {
	neo4j.ExplicitTransaction
	// contains filtered or unexported fields
}

ExplicitTransactionTracer wraps a neo4j.ExplicitTransaction object so the calls can be traced with open telemetry distributed tracing

func NewExplicitTransactionTracer

func NewExplicitTransactionTracer(ctx context.Context, tx neo4j.ExplicitTransaction, txSpan trace.Span, tracer trace.Tracer) *ExplicitTransactionTracer

NewExplicitTransactionTracer returns a new ExplicitTransactionTracer that wraps a neo4j.ExplicitTransaction with correct tracing details

func (*ExplicitTransactionTracer) Close

func (t *ExplicitTransactionTracer) Close(ctx context.Context) (err error)

Close calls neo4j.ExplicitTransaction.Close and trace the call

func (*ExplicitTransactionTracer) Commit

func (t *ExplicitTransactionTracer) Commit(ctx context.Context) (err error)

Commit calls neo4j.ExplicitTransaction.Commit and trace the call

func (*ExplicitTransactionTracer) Rollback

func (t *ExplicitTransactionTracer) Rollback(ctx context.Context) (err error)

Rollback calls neo4j.ExplicitTransaction.Rollback and trace the call

func (*ExplicitTransactionTracer) Run

func (t *ExplicitTransactionTracer) Run(ctx context.Context, cypher string, params map[string]any) (_ neo4j.ResultWithContext, err error)

Run calls neo4j.ExplicitTransaction.Run and trace the call

type ManagedTransactionTracer

type ManagedTransactionTracer struct {
	neo4j.ManagedTransaction
	// contains filtered or unexported fields
}

ManagedTransactionTracer wraps a neo4j.ManagedTransaction object so the calls can be traced with open telemetry distributed tracing

func NewManagedTransactionTracer

func NewManagedTransactionTracer(ctx context.Context, tx neo4j.ManagedTransaction, tracer trace.Tracer) *ManagedTransactionTracer

NewManagedTransactionTracer returns a new ManagedTransactionTracer that wraps a neo4j.ManagedTransaction with correct tracing details

func (*ManagedTransactionTracer) Run

func (t *ManagedTransactionTracer) Run(ctx context.Context, cypher string, params map[string]any) (_ neo4j.ResultWithContext, err error)

Run calls neo4j.ManagedTransaction.Run and trace the call

type Neo4jTracer

type Neo4jTracer struct {
	// contains filtered or unexported fields
}

Neo4jTracer wraps a neo4j.Tracer object so the calls can be traced with open telemetry distributed tracing

func NewNeo4jTracer

func NewNeo4jTracer(opts ...Option) *Neo4jTracer

NewNeo4jTracer creates an object that will wrap neo4j drivers with a tracing object

func (*Neo4jTracer) NewDriverWithContext

func (t *Neo4jTracer) NewDriverWithContext(target string, auth auth.TokenManager, configurers ...func(config2 *neo4j.Config)) (_ neo4j.DriverWithContext, err error)

NewDriverWithContext is the entry point to the neo4j driver to create an instance of a neo4j.DriverWithContext that is wrapped by a tracing object More information about the arguments can be found in the underlying neo4j driver call neo4j.NewDriverWithContext

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

type SessionWithContextTracer

type SessionWithContextTracer struct {
	neo4j.SessionWithContext
	// contains filtered or unexported fields
}

SessionWithContextTracer wraps a neo4j.SessionWithContext object so the calls can be traced with open telemetry distributed tracing

func (*SessionWithContextTracer) BeginTransaction

func (s *SessionWithContextTracer) BeginTransaction(ctx context.Context, configurers ...func(config *neo4j.TransactionConfig)) (neo4j.ExplicitTransaction, error)

BeginTransaction calls neo4j.SessionWithContext.BeginTransaction and trace the call

func (*SessionWithContextTracer) ExecuteRead

func (s *SessionWithContextTracer) ExecuteRead(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(config *neo4j.TransactionConfig)) (_ any, err error)

ExecuteRead calls neo4j.SessionWithContext.ExecuteRead and trace the call. The neo4j.ManagedTransaction object that is passed to the work function will be wrapped with a tracer.

func (*SessionWithContextTracer) ExecuteWrite

func (s *SessionWithContextTracer) ExecuteWrite(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(config *neo4j.TransactionConfig)) (_ any, err error)

ExecuteWrite calls neo4j.SessionWithContext.ExecuteWrite and trace the call. The neo4j.ManagedTransaction object that is passed to the work function will be wrapped with a tracer.

func (*SessionWithContextTracer) Run

func (s *SessionWithContextTracer) Run(ctx context.Context, cypher string, params map[string]any, configurers ...func(config *neo4j.TransactionConfig)) (_ neo4j.ResultWithContext, err error)

Run calls neo4j.SessionWithContext.Run and trace the call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL