-
Notifications
You must be signed in to change notification settings - Fork 8
ENGTAI-63552: adding filter eval for client spans #250
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
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b6b4296
adding filter call to grpc
varkey98 c780f19
add code for http client
varkey98 3e9b294
separate imports
varkey98 cec5b81
add support for sql client
varkey98 a53951b
adding sql client in options wrapper
varkey98 96942cc
adding pgx support
varkey98 a2de06a
fix lint and add some more unit tests
varkey98 31415ba
remove unwanted heap allocation
varkey98 67017c2
fixing unit tests
varkey98 e88d487
adding options pattern to hypersql and hyperpgx
varkey98 3621fd5
fix example go module file
varkey98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package hypersql // import "github.com/hypertrace/goagent/instrumentation/hypertrace/database/hypersql" | ||
|
||
import ( | ||
"github.com/hypertrace/goagent/sdk/filter" | ||
sdkSQL "github.com/hypertrace/goagent/sdk/instrumentation/database/sql" | ||
) | ||
|
||
type options struct { | ||
Filter filter.Filter | ||
} | ||
|
||
func (o *options) toSDKOptions() *sdkSQL.Options { | ||
opts := (sdkSQL.Options)(*o) | ||
return &opts | ||
} | ||
|
||
type Option func(o *options) | ||
|
||
// WithFilter adds a filter to the GRPC option. | ||
func WithFilter(f filter.Filter) Option { | ||
return func(o *options) { | ||
o.Filter = f | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
instrumentation/hypertrace/database/hypersql/options_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package hypersql // import "github.com/hypertrace/goagent/instrumentation/hypertrace/database/hypersql" | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hypertrace/goagent/sdk/filter" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestOptionsToSDK(t *testing.T) { | ||
o := &options{ | ||
Filter: filter.NoopFilter{}, | ||
} | ||
assert.Equal(t, filter.NoopFilter{}, o.toSDKOptions().Filter) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
package hypersql // import "github.com/hypertrace/goagent/instrumentation/hypertrace/database/hypersql" | ||
|
||
import ( | ||
"database/sql/driver" | ||
otelsql "github.com/hypertrace/goagent/instrumentation/opentelemetry/database/hypersql" | ||
) | ||
|
||
// Wrap takes a SQL driver and wraps it with Hypertrace instrumentation. | ||
var Wrap = otelsql.Wrap | ||
func Wrap(d driver.Driver, opts ...Option) driver.Driver { | ||
o := &options{} | ||
for _, opt := range opts { | ||
opt(o) | ||
} | ||
|
||
return otelsql.Wrap(d, o.toSDKOptions()) | ||
} | ||
|
||
// Register initializes and registers the hypersql wrapped database driver | ||
// identified by its driverName. On success it | ||
// returns the generated driverName to use when calling sql.Open. | ||
var Register = otelsql.Register | ||
func Register(driverName string, opts ...Option) (string, error) { | ||
o := &options{} | ||
for _, opt := range opts { | ||
opt(o) | ||
} | ||
return otelsql.Register(driverName, o.toSDKOptions()) | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
instrumentation/hypertrace/github.com/jackc/hyperpgx/options.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package hyperpgx // import "github.com/hypertrace/goagent/instrumentation/hypertrace/github.com/jackc/hyperpgx" | ||
|
||
import ( | ||
otelpgx "github.com/hypertrace/goagent/instrumentation/opentelemetry/github.com/jackc/hyperpgx" | ||
"github.com/hypertrace/goagent/sdk/filter" | ||
) | ||
|
||
type options struct { | ||
Filter filter.Filter | ||
} | ||
|
||
func (o *options) toSDKOptions() *otelpgx.Options { | ||
opts := (otelpgx.Options)(*o) | ||
return &opts | ||
} | ||
|
||
type Option func(o *options) | ||
|
||
// WithFilter adds a filter to the GRPC option. | ||
func WithFilter(f filter.Filter) Option { | ||
return func(o *options) { | ||
o.Filter = f | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
instrumentation/hypertrace/github.com/jackc/hyperpgx/options_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package hyperpgx // import "github.com/hypertrace/goagent/instrumentation/hypertrace/github.com/jackc/hyperpgx" | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hypertrace/goagent/sdk/filter" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestOptionsToSDK(t *testing.T) { | ||
o := &options{ | ||
Filter: filter.NoopFilter{}, | ||
} | ||
assert.Equal(t, filter.NoopFilter{}, o.toSDKOptions().Filter) | ||
} |
15 changes: 13 additions & 2 deletions
15
instrumentation/hypertrace/github.com/jackc/hyperpgx/pgx.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package hyperpgx // import "github.com/hypertrace/goagent/instrumentation/hypertrace/github.com/jackc/hyperpgx" | ||
|
||
import otelpgx "github.com/hypertrace/goagent/instrumentation/opentelemetry/github.com/jackc/hyperpgx" | ||
import ( | ||
"context" | ||
|
||
var Connect = otelpgx.Connect | ||
otelpgx "github.com/hypertrace/goagent/instrumentation/opentelemetry/github.com/jackc/hyperpgx" | ||
) | ||
|
||
func Connect(ctx context.Context, connString string, opts ...Option) (otelpgx.PGXConn, error) { | ||
o := &options{} | ||
for _, opt := range opts { | ||
opt(o) | ||
} | ||
|
||
return otelpgx.Connect(ctx, connString, o.toSDKOptions()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to check why we need this replace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one replace was always there pointing to the opentelemetry one's go module. When I added options pattern I added it only to the hypertrace wrapper (for other instrumentations like the grpc one we only had it for our hypertrace wrapper). So for using it I switched the replace from the otel one to hypertrace. But stranger part was that
replace
was not working transitively, hence needed to add both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully it does not give me trouble during the migration :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, 🤞