Skip to content

Commit

Permalink
[chore][internal/sqlquery] Make error public for future use (#32175)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
This is part of
#31915,
to try to make it more manageable in size. This variable will be used by
the SQL Server receiver.
  • Loading branch information
crobert-1 authored Apr 16, 2024
1 parent a980e8e commit 368c773
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/sqlquery/db_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestDBSQLClient_Nulls(t *testing.T) {
}
rows, err := cl.QueryRows(context.Background())
assert.Error(t, err)
assert.True(t, errors.Is(err, errNullValueWarning))
assert.True(t, errors.Is(err, ErrNullValueWarning))
assert.Len(t, rows, 1)
assert.EqualValues(t, map[string]string{
"col_0": "42",
Expand All @@ -96,7 +96,7 @@ func TestDBSQLClient_Nulls_MultiRow(t *testing.T) {
assert.Len(t, uw, 2)

for _, err := range uw {
assert.True(t, errors.Is(err, errNullValueWarning))
assert.True(t, errors.Is(err, ErrNullValueWarning))
}
}
assert.Len(t, rows, 2)
Expand Down
4 changes: 2 additions & 2 deletions internal/sqlquery/row_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"go.uber.org/multierr"
)

var errNullValueWarning = errors.New("NULL value")
var ErrNullValueWarning = errors.New("NULL value")

type rowScanner struct {
cols map[string]func() (string, error)
Expand All @@ -28,7 +28,7 @@ func newRowScanner(colTypes []colType) *rowScanner {
var v any
rs.cols[colName] = func() (string, error) {
if v == nil {
return "", errNullValueWarning
return "", ErrNullValueWarning
}
format := "%v"
if t, isTime := v.(time.Time); isTime {
Expand Down
2 changes: 1 addition & 1 deletion internal/sqlquery/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Scraper) Scrape(ctx context.Context) (pmetric.Metrics, error) {
out := pmetric.NewMetrics()
rows, err := s.Client.QueryRows(ctx)
if err != nil {
if errors.Is(err, errNullValueWarning) {
if errors.Is(err, ErrNullValueWarning) {
s.Logger.Warn("problems encountered getting metric rows", zap.Error(err))
} else {
return out, fmt.Errorf("Scraper: %w", err)
Expand Down

0 comments on commit 368c773

Please sign in to comment.