DataDog / integrations-core

Core integrations of the Datadog Agent
BSD 3-Clause "New" or "Revised" License
937 stars 1.41k forks source link

[mongo] fix db name parsing when namespace has no collection #18953

Closed lu-zhengda closed 2 weeks ago

lu-zhengda commented 2 weeks ago

What does this PR do?

This PR fixes a bug in parsing db name from namespace when namespace has no collection name, e.g. admin.$cmd vs. admin. This usually happens with database level administration command on earlier MongoDB version (version 5 or earlier).

Motivation

https://datadoghq.atlassian.net/browse/DBMON-4723

Review checklist (to be filled by reviewers)

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.30%. Comparing base (ce674ce) to head (0423e2b). Report is 1 commits behind head on master.

Additional details and impacted files | [Flag](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [activemq](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [cassandra](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [hive](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [hivemq](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [hudi](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [ignite](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [jboss_wildfly](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [kafka](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [mongo](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `93.09% <68.42%> (-0.44%)` | :arrow_down: | | [presto](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | | [solr](https://app.codecov.io/gh/DataDog/integrations-core/pull/18953/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more.