Skip to content
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
31 changes: 31 additions & 0 deletions .chloggen/fix-logs-scraper-metric-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Log scrapers now emit log-appropriate receiver telemetry

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

# (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: |
Log scrapers previously emitted the same receiver telemetry as metric scrapers,
such as the otelcol_receiver_accepted_metric_points metric (instead of otelcol_receiver_accepted_log_records),
or spans named receiver/myreceiver/MetricsReceived (instead of receiver/myreceiver/LogsReceived).

This did not affect scraper-specific spans and metrics.


# 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: []
4 changes: 2 additions & 2 deletions scraper/scraperhelper/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ func scrapeLogs(c *controller.Controller[scraper.Logs], nextConsumer consumer.Lo
}

logRecordCount := logs.LogRecordCount()
ctx = c.Obsrecv.StartMetricsOp(ctx)
ctx = c.Obsrecv.StartLogsOp(ctx)
err := nextConsumer.ConsumeLogs(ctx, logs)
c.Obsrecv.EndMetricsOp(ctx, "", logRecordCount, err)
c.Obsrecv.EndLogsOp(ctx, "", logRecordCount, err)
}

func scrapeMetrics(c *controller.Controller[scraper.Metrics], nextConsumer consumer.Metrics) {
Expand Down
17 changes: 14 additions & 3 deletions scraper/scraperhelper/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestLogsScrapeController(t *testing.T) {
}

spans := tel.SpanRecorder.Ended()
assertReceiverSpan(t, spans)
assertLogsReceiverSpan(t, spans)
testhelper.AssertScraperSpan(t, test.scrapeErr, spans, "scraper/scraper/ScrapeLogs")
assertLogsScraperObsMetrics(t, tel, receiverID, component.MustNewID("scraper"), test.scrapeErr, sink)
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func TestMetricsScrapeController(t *testing.T) {
}

spans := tel.SpanRecorder.Ended()
assertReceiverSpan(t, spans)
assertMetricsReceiverSpan(t, spans)
testhelper.AssertScraperSpan(t, test.scrapeErr, spans, "scraper/scraper/ScrapeMetrics")
assertMetricsScraperObsMetrics(t, tel, receiverID, component.MustNewID("scraper"), test.scrapeErr, sink)
}
Expand Down Expand Up @@ -378,7 +378,7 @@ func getExpectedShutdownErr(test scraperTestCase) error {
return errs
}

func assertReceiverSpan(t *testing.T, spans []sdktrace.ReadOnlySpan) {
func assertMetricsReceiverSpan(t *testing.T, spans []sdktrace.ReadOnlySpan) {
receiverSpan := false
for _, span := range spans {
if span.Name() == "receiver/receiver/MetricsReceived" {
Expand All @@ -389,6 +389,17 @@ func assertReceiverSpan(t *testing.T, spans []sdktrace.ReadOnlySpan) {
assert.True(t, receiverSpan)
}

func assertLogsReceiverSpan(t *testing.T, spans []sdktrace.ReadOnlySpan) {
receiverSpan := false
for _, span := range spans {
if span.Name() == "receiver/receiver/LogsReceived" {
receiverSpan = true
break
}
}
assert.True(t, receiverSpan)
}

func assertLogsScraperObsMetrics(t *testing.T, tel *componenttest.Telemetry, receiver, scraper component.ID, expectedErr error, sink *consumertest.LogsSink) {
logRecordCounts := 0
for _, md := range sink.AllLogs() {
Expand Down
Loading