Skip to content

Commit

Permalink
update scrapers
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Dec 2, 2024
1 parent 49e7d1e commit 55d9f1d
Show file tree
Hide file tree
Showing 241 changed files with 745 additions and 724 deletions.
4 changes: 2 additions & 2 deletions connector/datadogconnector/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exporter/datadogexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ require (
go.opentelemetry.io/collector/processor/processortest v0.114.1-0.20241130171227-c52d625647be // indirect
go.opentelemetry.io/collector/receiver/receiverprofiles v0.114.1-0.20241130171227-c52d625647be // indirect
go.opentelemetry.io/collector/receiver/receivertest v0.114.1-0.20241130171227-c52d625647be // indirect
go.opentelemetry.io/collector/scraper v0.114.0 // indirect
go.opentelemetry.io/collector/scraper v0.114.1-0.20241130171227-c52d625647be // indirect
go.opentelemetry.io/collector/service v0.114.1-0.20241130171227-c52d625647be // indirect
go.opentelemetry.io/contrib/bridges/otelzap v0.6.0 // indirect
go.opentelemetry.io/contrib/config v0.10.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions exporter/datadogexporter/integrationtest/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions internal/sqlquery/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"database/sql"
"errors"
"fmt"
"go.opentelemetry.io/collector/scraper"
"time"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -37,7 +38,7 @@ type Scraper struct {
Db *sql.DB
}

var _ scraperhelper.Scraper = (*Scraper)(nil)
var _ scraper.Metrics = (*Scraper)(nil)

func NewScraper(id component.ID, query Query, scrapeCfg scraperhelper.ControllerConfig, logger *zap.Logger, telemetry TelemetryConfig, dbProviderFunc DbProviderFunc, clientProviderFunc ClientProviderFunc) *Scraper {
return &Scraper{
Expand Down Expand Up @@ -67,7 +68,7 @@ func (s *Scraper) Start(context.Context, component.Host) error {
return nil
}

func (s *Scraper) Scrape(ctx context.Context) (pmetric.Metrics, error) {
func (s *Scraper) ScrapeMetrics(ctx context.Context) (pmetric.Metrics, error) {
out := pmetric.NewMetrics()
rows, err := s.Client.QueryRows(ctx)
if err != nil {
Expand Down
32 changes: 16 additions & 16 deletions internal/sqlquery/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestScraper_ClientErrorOnScrape(t *testing.T) {
scrpr := Scraper{
Client: client,
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
require.Error(t, err)
}

Expand All @@ -57,7 +57,7 @@ func TestScraper_RowToMetricErrorOnScrape_Float(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.Error(t, err)
}

Expand All @@ -79,7 +79,7 @@ func TestScraper_RowToMetricErrorOnScrape_Int(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.Error(t, err)
}

Expand All @@ -102,7 +102,7 @@ func TestScraper_RowToMetricMultiErrorsOnScrape(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.Error(t, err)
}

Expand Down Expand Up @@ -135,7 +135,7 @@ func TestScraper_SingleRow_MultiMetrics(t *testing.T) {
},
},
}
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
rms := metrics.ResourceMetrics()
assert.Equal(t, 1, rms.Len())
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestScraper_MultiRow(t *testing.T) {
},
},
}
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
ms := metrics.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics()
{
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestScraper_MultiResults_DeltaSum(t *testing.T) {
}

func assertTransactionCount(t *testing.T, scrpr Scraper, expected int, agg pmetric.AggregationTemporality) {
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
metric := metrics.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
assert.Equal(t, "transaction.count", metric.Name())
Expand Down Expand Up @@ -301,7 +301,7 @@ func TestScraper_Float(t *testing.T) {
}},
},
}
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
metric := metrics.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
assert.Equal(t, 123.4, metric.Gauge().DataPoints().At(0).DoubleValue())
Expand All @@ -324,7 +324,7 @@ func TestScraper_DescriptionAndUnit(t *testing.T) {
}},
},
}
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
z := metrics.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
assert.Equal(t, "my-unit", z.Unit())
Expand All @@ -346,7 +346,7 @@ func TestScraper_FakeDB_Warnings(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
}

Expand All @@ -365,7 +365,7 @@ func TestScraper_FakeDB_MultiRows_Warnings(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
// No error is expected because we're not actually asking for metrics from the
// NULL column. Instead the errors from the NULL reads should just log warnings.
assert.NoError(t, err)
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestScraper_FakeDB_MultiRows_Error(t *testing.T) {
},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
// We expect an error here not directly because of the NULL values but because
// the column was also requested in Query.Metrics[1] but wasn't found. It's just
// a partial scrape error though so it shouldn't cause a Scraper shutdown.
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestScraper_StartAndTSColumn(t *testing.T) {
}},
},
}
metrics, err := scrpr.Scrape(context.Background())
metrics, err := scrpr.ScrapeMetrics(context.Background())
require.NoError(t, err)
metric := metrics.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
assert.Equal(t, pcommon.Timestamp(1682417791), metric.Sum().DataPoints().At(0).StartTimestamp())
Expand Down Expand Up @@ -453,7 +453,7 @@ func TestScraper_StartAndTS_ErrorOnColumnNotFound(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.Error(t, err)
}

Expand All @@ -479,7 +479,7 @@ func TestScraper_CollectRowToMetricsErrors(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.ErrorContains(t, err, "rowToMetric: start_ts_column not found")
assert.ErrorContains(t, err, "rowToMetric: ts_column not found")
assert.ErrorContains(t, err, "rowToMetric: value_column 'mycol_na' not found in result set")
Expand Down Expand Up @@ -507,6 +507,6 @@ func TestScraper_StartAndTS_ErrorOnParse(t *testing.T) {
}},
},
}
_, err := scrpr.Scrape(context.Background())
_, err := scrpr.ScrapeMetrics(context.Background())
assert.Error(t, err)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 55d9f1d

Please sign in to comment.