Skip to content

Commit

Permalink
[scraperhelper] remove deprecated obsreport funcs/structs (#11086)
Browse files Browse the repository at this point in the history
These were only used inside scraperhelper, should have no impact.

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten authored Sep 9, 2024
1 parent 3f9bc53 commit 46d04a5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
25 changes: 25 additions & 0 deletions .chloggen/codeboten_rm-dep-funs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: scraperhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Remove deprecated `ObsReport`, `ObsReportSettings`, `NewObsReport` types/funcs"

# One or more tracking issues or pull requests related to the change
issues: [11086]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
29 changes: 9 additions & 20 deletions receiver/scraperhelper/obsreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import (
"go.opentelemetry.io/collector/receiver/scraperhelper/internal/metadata"
)

// ObsReport is a helper to add observability to a scraper.
//
// Deprecated: [v0.108.0] will be removed.
type ObsReport struct {
// obsReport is a helper to add observability to a scraper.
type obsReport struct {
receiverID component.ID
scraper component.ID
tracer trace.Tracer
Expand All @@ -31,28 +29,19 @@ type ObsReport struct {
telemetryBuilder *metadata.TelemetryBuilder
}

// ObsReportSettings are settings for creating an ObsReport.
//
// Deprecated: [v0.108.0] will be removed.
type ObsReportSettings struct {
// obsReportSettings are settings for creating an ObsReport.
type obsReportSettings struct {
ReceiverID component.ID
Scraper component.ID
ReceiverCreateSettings receiver.Settings
}

// NewObsReport creates a new ObsReport.
//
// Deprecated: [v0.108.0] will be removed, scrapers should use NewScraperControllerReceiver instead.
func NewObsReport(cfg ObsReportSettings) (*ObsReport, error) {
return newScraper(cfg)
}

func newScraper(cfg ObsReportSettings) (*ObsReport, error) {
func newScraper(cfg obsReportSettings) (*obsReport, error) {
telemetryBuilder, err := metadata.NewTelemetryBuilder(cfg.ReceiverCreateSettings.TelemetrySettings)
if err != nil {
return nil, err
}
return &ObsReport{
return &obsReport{
receiverID: cfg.ReceiverID,
scraper: cfg.Scraper,
tracer: cfg.ReceiverCreateSettings.TracerProvider.Tracer(cfg.Scraper.String()),
Expand All @@ -68,15 +57,15 @@ func newScraper(cfg ObsReportSettings) (*ObsReport, error) {
// StartMetricsOp is called when a scrape operation is started. The
// returned context should be used in other calls to the obsreport functions
// dealing with the same scrape operation.
func (s *ObsReport) StartMetricsOp(ctx context.Context) context.Context {
func (s *obsReport) StartMetricsOp(ctx context.Context) context.Context {
spanName := obsmetrics.ScraperPrefix + s.receiverID.String() + obsmetrics.SpanNameSep + s.scraper.String() + obsmetrics.ScraperMetricsOperationSuffix
ctx, _ = s.tracer.Start(ctx, spanName)
return ctx
}

// EndMetricsOp completes the scrape operation that was started with
// StartMetricsOp.
func (s *ObsReport) EndMetricsOp(
func (s *obsReport) EndMetricsOp(
scraperCtx context.Context,
numScrapedMetrics int,
err error,
Expand Down Expand Up @@ -112,7 +101,7 @@ func (s *ObsReport) EndMetricsOp(
span.End()
}

func (s *ObsReport) recordMetrics(scraperCtx context.Context, numScrapedMetrics, numErroredMetrics int) {
func (s *obsReport) recordMetrics(scraperCtx context.Context, numScrapedMetrics, numErroredMetrics int) {
s.telemetryBuilder.ScraperScrapedMetricPoints.Add(scraperCtx, int64(numScrapedMetrics), metric.WithAttributes(s.otelAttrs...))
s.telemetryBuilder.ScraperErroredMetricPoints.Add(scraperCtx, int64(numErroredMetrics), metric.WithAttributes(s.otelAttrs...))
}
4 changes: 2 additions & 2 deletions receiver/scraperhelper/obsreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestScrapeMetricsDataOp(t *testing.T) {
{items: 15, err: nil},
}
for i := range params {
scrp, err := newScraper(ObsReportSettings{
scrp, err := newScraper(obsReportSettings{
ReceiverID: receiverID,
Scraper: scraperID,
ReceiverCreateSettings: receiver.Settings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()},
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestCheckScraperMetricsViews(t *testing.T) {
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

s, err := newScraper(ObsReportSettings{
s, err := newScraper(obsReportSettings{
ReceiverID: receiverID,
Scraper: scraperID,
ReceiverCreateSettings: receiver.Settings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()},
Expand Down
6 changes: 3 additions & 3 deletions receiver/scraperhelper/scrapercontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type controller struct {
nextConsumer consumer.Metrics

scrapers []Scraper
obsScrapers []*ObsReport
obsScrapers []*obsReport

tickerCh <-chan time.Time

Expand Down Expand Up @@ -101,9 +101,9 @@ func NewScraperControllerReceiver(
op(sc)
}

sc.obsScrapers = make([]*ObsReport, len(sc.scrapers))
sc.obsScrapers = make([]*obsReport, len(sc.scrapers))
for i, scraper := range sc.scrapers {
scrp, err := newScraper(ObsReportSettings{
scrp, err := newScraper(obsReportSettings{
ReceiverID: sc.id,
Scraper: scraper.ID(),
ReceiverCreateSettings: sc.recvSettings,
Expand Down

0 comments on commit 46d04a5

Please sign in to comment.