opentelemetry-collector-contrib icon indicating copy to clipboard operation
opentelemetry-collector-contrib copied to clipboard

[receiver/mongodbreceiver] Check if mongodb.flushes.rate metric is enabled before trying to collect

Open odorT opened this issue 4 months ago • 15 comments

Description

This PR fixes the issue stated below, where mongodb receiver tries to collect WiredTiger checkpoint data for disabled metric mongodb.flushes.rate. I think we should add if clause to all metrics that can be disabled, let's discuss.

Link to tracking issue

Fixes https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/41465

odorT avatar Jul 27 '25 15:07 odorT

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: odorT / name: Kamran Karimov (5ad9c24221e848054208070e3725777531951a32)

@justinianvoss22 should I add if clause to all metrics that can be disabled?

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/ef72f9e9904f887122072f787391c7a09573dd3f/receiver/mongodbreceiver/scraper.go#L254-L269

odorT avatar Jul 27 '25 15:07 odorT

please run make chlog-new and add the changelog file to your PR.

atoulme avatar Jul 28 '25 23:07 atoulme

[like] Kamran Karimov reacted to your message:


From: Antoine Toulme @.> Sent: Monday, July 28, 2025 11:16:07 PM To: open-telemetry/opentelemetry-collector-contrib @.> Cc: Kamran Karimov @.>; Mention @.> Subject: Re: [open-telemetry/opentelemetry-collector-contrib] [receiver/mongodbreceiver] Check if mongodb.flushes.rate metric is enabled before trying to collect (PR #41604)

[https://avatars.githubusercontent.com/u/16758?s=20&v=4]atoulme left a comment (open-telemetry/opentelemetry-collector-contrib#41604)https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/41604#issuecomment-3130103537

please run make chlog-new and add the changelog file to your PR.

— Reply to this email directly, view it on GitHubhttps://github.com/open-telemetry/opentelemetry-collector-contrib/pull/41604#issuecomment-3130103537, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN6E2NBCTVZC3PZJSXSR3UL3K2VLPAVCNFSM6AAAAACCO67V2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMZQGEYDGNJTG4. You are receiving this because you were mentioned.Message ID: @.***>

odorT avatar Jul 29 '25 06:07 odorT

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Aug 13 '25 05:08 github-actions[bot]

@justinianvoss22 can you please review as the codeowner for MongoDB receiver?

andrzej-stencel avatar Aug 26 '25 21:08 andrzej-stencel

@justinianvoss22 please review as codeowner

atoulme avatar Oct 04 '25 05:10 atoulme

@justinianvoss22 should I add if clause to all metrics that can be disabled?

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/ef72f9e9904f887122072f787391c7a09573dd3f/receiver/mongodbreceiver/scraper.go#L254-L269

@odorT Sorry for the delay in response.

It makes sense to add condition checks to all metrics that can be disabled. Looks like many metrics in recordAdminStats and some in recordNormalServerStats can be checked.

justinianvoss22 avatar Oct 06 '25 14:10 justinianvoss22

Thanks for response @justinianvoss22 , sure, will send commit this week

odorT avatar Oct 08 '25 08:10 odorT

@justinianvoss22 Could you please elaborate on why we shouldn't check them all? I'm concerned I may have missed a key point there

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/ef72f9e9904f887122072f787391c7a09573dd3f/receiver/mongodbreceiver/scraper.go#L243-L251

odorT avatar Oct 18 '25 17:10 odorT

@justinianvoss22 Could you please elaborate on why we shouldn't check them all? I'm concerned I may have missed a key point there

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/ef72f9e9904f887122072f787391c7a09573dd3f/receiver/mongodbreceiver/scraper.go#L243-L251

Sorry if I wasn't clear, I am agreeing with you, we should check them all. I was giving a few examples when looking around.

justinianvoss22 avatar Oct 20 '25 18:10 justinianvoss22

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Nov 04 '25 05:11 github-actions[bot]

Hi, @odorT! Been waiting for a response from you, but to follow up again, the changes you are making are reasonable, and it would make sense to do these checks for recordDBStats and recordNormalServerStats as well. For example, the starting at the top of recordNormalServerStats:

	if s.config.Metrics.MongodbCollectionCount.Enabled {
		s.recordCollections(now, doc, dbName, errs)
	}

	if s.config.Metrics.MongodbDataSize.Enabled {
		s.recordDataSize(now, doc, dbName, errs)
	}
...

justinianvoss22 avatar Nov 17 '25 13:11 justinianvoss22

Sorry, this slipped my mind. I’ll make the changes and send the commit over the weekend.

odorT avatar Nov 17 '25 17:11 odorT

@justinianvoss22 please have a look when you get a chance

odorT avatar Dec 07 '25 18:12 odorT

@odor Pinging just to remind to update the unit tests for scraper_test.go, as per my comment above

justinianvoss22 avatar Dec 15 '25 18:12 justinianvoss22

Hi @justinianvoss22 , I apologize for the slow response. I've been dealing with some work and personal commitments, but I'll have time to address this after(or during) the holidays

odorT avatar Dec 15 '25 19:12 odorT

Hi @justinianvoss22 , I apologize for the slow response. I've been dealing with some work and personal commitments, but I'll have time to address this after(or during) the holidays

No worries at all! Sounds good 👍

justinianvoss22 avatar Dec 15 '25 21:12 justinianvoss22