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

How do I add a custom detector to allow seamless snowflake integration? #453

Open
amanangira opened this issue Feb 22, 2024 · 2 comments
Open

Comments

@amanangira
Copy link

amanangira commented Feb 22, 2024

Hello, below are the details of what I am trying to do

import (
    _ "github.com/snowflakedb/gosnowflake" // Snowflake
    "github.com/aws/aws-xray-sdk-go/xray"
    "github.com/jmoiron/sqlx"
)

func main() {
    dsn := ""
    sqlDB, err := xray.SQLContext("snowflake", dsn)
    if err != nil {
        panic(err)
    }
    sqlxDB := sqlx.NewDb(sqlDB, "snowflake")
    rows, rowErr := sqlxDB.QueryContext(context.Background(), "SELECT 1")
    if rowErr != nil {
	panic(rowErr)
    }
}

During debugging the QueryContext context statement I found the below call stack.

Screenshot 2024-02-22 at 4 04 12 PM

Now the problem as per my understanding is that the [newDBAttribute](https://github.com/aws/aws-xray-sdk-go/blob/e9627da6f47902f96f26c577cbe6f9244987a4fb/xray/sql_context.go#L370) call under sql_context.go only seems to be supporting postgres, mysql, and oracle driver types because of which the meta query being fired in case of snowflake is SELECT version(), current_user, current_database() and the Snowflake version() equivalent is [current_version()](https://docs.snowflake.com/en/sql-reference/functions/current_version) which results in some error logs.

Version I am using
go 1.21.0
aws-xray-sdk-go v1.8.3
snowflakedb/gosnowflake v1.8.0

@wangzlei
Copy link
Contributor

wangzlei commented Feb 26, 2024

@amanangira Please help confirm that my understanding is correct. To support the snowflake in sql instrumentation, we can add an new API likeaddDetector(), if you don't mind, could you help submit a PR for it? We can review and add unit testing for the changes.

@amanangira
Copy link
Author

amanangira commented Feb 27, 2024

Hello @wangzlei , I don't mind. I sure can try and respond to the review changes as they are reviewed. Before moving forward I wanted to confirm if there was no existing API to do the same.

Are there any instructions to keep in mind when working on a new PR?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants