Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query args to instrumentation #314

Merged
merged 3 commits into from Oct 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions instrumentation.go
Expand Up @@ -9,19 +9,19 @@ import (

// Instrumenter defines function type that can be used for instrumetation.
// This function should return a function with no argument as a callback for finished execution.
type Instrumenter func(ctx context.Context, op string, message string) func(err error)
type Instrumenter func(ctx context.Context, op string, message string, args ...any) func(err error)

// Observe operation.
func (i Instrumenter) Observe(ctx context.Context, op string, message string) func(err error) {
func (i Instrumenter) Observe(ctx context.Context, op string, message string, args ...any) func(err error) {
if i != nil {
return i(ctx, op, message)
return i(ctx, op, message, args)
}

return func(err error) {}
}

// DefaultLogger instrumentation to log queries and rel operation.
func DefaultLogger(ctx context.Context, op string, message string) func(err error) {
func DefaultLogger(ctx context.Context, op string, message string, args ...any) func(err error) {
// no op for rel functions.
if strings.HasPrefix(op, "rel-") {
return func(error) {}
Expand Down