Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add obs for logs in scraper/scraperhelper #12036

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sincejune
Copy link
Contributor

Description

This PR adds obs for logs in scraper/scraperhelper, also introduced new metrics for scraping logs.

Link to tracking issue

Relates to #11238

Testing

Added

Documentation

Added

@sincejune sincejune requested a review from a team as a code owner January 7, 2025 14:00
@sincejune sincejune requested a review from bogdandrutu January 7, 2025 14:00
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 84.12698% with 10 lines in your changes missing coverage. Please review.

Project coverage is 91.65%. Comparing base (cdea826) to head (2b1e685).

Files with missing lines Patch % Lines
component/componenttest/otelchecker.go 0.00% 5 Missing ⚠️
scraper/scraperhelper/obs_logs.go 93.18% 2 Missing and 1 partial ⚠️
component/componenttest/obsreporttest.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12036      +/-   ##
==========================================
- Coverage   91.67%   91.65%   -0.02%     
==========================================
  Files         455      456       +1     
  Lines       24010    24073      +63     
==========================================
+ Hits        22010    22063      +53     
- Misses       1629     1638       +9     
- Partials      371      372       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sincejune
Copy link
Contributor Author

@bogdandrutu otelchecker.go and obsreporttest.go seem to be helper files for unit test, and have no test file covered. Are we able to skip tests for these two files?

@@ -86,6 +86,12 @@ func (tts *TestTelemetry) CheckReceiverMetrics(protocol string, acceptedMetricPo
return checkReceiverMetrics(tts.reader, tts.id, protocol, acceptedMetricPoints, droppedMetricPoints)
}

// CheckScraperLogs checks that for the current exported values for logs scraper metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckScraperLogs(receiver component.ID, scraper component.ID, scrapedLogRecords, erroredLogRecords int64) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually planning to remove the other one. So I don't think this is necessary.

@@ -15,6 +15,13 @@ import (
"go.opentelemetry.io/collector/component"
)

func checkScraperLogs(reader *sdkmetric.ManualReader, receiver component.ID, scraper component.ID, scrapedLogRecords, erroredLogRecords int64) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

switch {
case params[i].err == nil:
scrapedLogRecords += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: scrapedLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use attribute.Int64 instead of manually construct the key and the value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants