Skip to content

Commit

Permalink
Add Raw function to otConn (#100)
Browse files Browse the repository at this point in the history
* Add Raw function to otConn

* Update CHANGELOG
  • Loading branch information
XSAM authored Jul 7, 2022
1 parent 4ae4662 commit 2f96852
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The minimum supported Go version is `1.17`.
### Added

- Option `OmitResetSession` that if set to true will suppress `sql.conn.reset_session` spans. (#87)
- Function `Raw` to `otConn` to return the underlying driver connection. (#100)

### Changed

Expand Down
6 changes: 6 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,9 @@ func (c *otConn) CheckNamedValue(namedValue *driver.NamedValue) error {

return namedValueChecker.CheckNamedValue(namedValue)
}

// Raw returns the underlying driver connection
// Issue: https://github.com/XSAM/otelsql/issues/98
func (c *otConn) Raw() driver.Conn {
return c.Conn
}
7 changes: 7 additions & 0 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,10 @@ func TestOtConn_ResetSession(t *testing.T) {
})
}
}

func TestOtConn_Raw(t *testing.T) {
raw := newMockConn(false)
conn := newConn(raw, config{})

assert.Equal(t, raw, conn.Raw())
}

0 comments on commit 2f96852

Please sign in to comment.