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

AWS X-Ray exporter: Only convert SQL information for SQL databases. #379

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exporter/awsxrayexporter/translator/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func makeSQL(attributes map[string]string) (map[string]string, *SQLData) {
}
}

if len(filtered) == len(attributes) {
// Didn't filter any attributes meaning didn't have any SQL information.
if dbType != "sql" {
// Either no DB attributes or this is not an SQL DB.
return attributes, nil
}

Expand Down
16 changes: 16 additions & 0 deletions exporter/awsxrayexporter/translator/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ func TestClientSpanWithStatementAttribute(t *testing.T) {
testWriters.release(w)
assert.True(t, strings.Contains(jsonStr, "mysql://db.example.com:3306/customers"))
}

func TestClientSpanWithNonSQLDatabase(t *testing.T) {
attributes := make(map[string]string)
attributes[semconventions.AttributeComponent] = "db"
attributes[semconventions.AttributeDBType] = "redis"
attributes[semconventions.AttributeDBInstance] = "0"
attributes[semconventions.AttributeDBStatement] = "SET key value"
attributes[semconventions.AttributeDBUser] = "readonly_user"
attributes[semconventions.AttributeDBURL] = "redis://db.example.com:3306"
attributes[semconventions.AttributeNetPeerName] = "db.example.com"
attributes[semconventions.AttributeNetPeerPort] = "3306"

filtered, sqlData := makeSQL(attributes)
assert.Nil(t, sqlData)
assert.NotNil(t, filtered)
}