Skip to content

Commit

Permalink
[receiver/mongodbatlas] Refactored to use New metric builder (#9093)
Browse files Browse the repository at this point in the history
* Refactored mongodbatlas to use new metric builder

Signed-off-by: Corbin Phelps <[email protected]>

* Updated changelog with pr number

Signed-off-by: Corbin Phelps <[email protected]>

* Fixed linter issues

Signed-off-by: Corbin Phelps <[email protected]>

* Switched mongodbatlas metric lookup to switch statement

Signed-off-by: Corbin Phelps <[email protected]>
  • Loading branch information
Corbin Phelps authored Apr 9, 2022
1 parent 44aca08 commit 439369e
Show file tree
Hide file tree
Showing 13 changed files with 5,357 additions and 1,875 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- A detailed [Upgrade Guide](https://github.com/open-telemetry/opentelemetry-log-collection/releases/tag/v0.28.0) is available in the log-collection v0.28.0 release notes.
- `datadogexporter`: Remove `OnlyMetadata` method from `Config` struct (#8980)
- `datadogexporter`: Remove `GetCensoredKey` method from `APIConfig` struct (#8980)
- `mongodbatlasreceiver`: Updated to uses newer metric builder which changed some metric and resource attributes (#9093)
- `dynatraceexporter`: Make `serialization` package `/internal` (#9097)

### 🧰 Bug fixes 🧰
Expand Down
9 changes: 6 additions & 3 deletions receiver/mongodbatlasreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ import (
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver/internal/metadata"
)

var _ config.Receiver = (*Config)(nil)

type Config struct {
scraperhelper.ScraperControllerSettings `mapstructure:",squash"`
PublicKey string `mapstructure:"public_key"`
PrivateKey string `mapstructure:"private_key"`
Granularity string `mapstructure:"granularity"`
PublicKey string `mapstructure:"public_key"`
PrivateKey string `mapstructure:"private_key"`
Granularity string `mapstructure:"granularity"`
Metrics metadata.MetricsSettings `mapstructure:"metrics"`

RetrySettings exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
}
2 changes: 1 addition & 1 deletion receiver/mongodbatlasreceiver/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//go:build !windows
// +build !windows

//go:generate mdatagen metadata.yaml
//go:generate mdatagen --experimental-gen metadata.yaml

package mongodbatlasreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver"
32 changes: 27 additions & 5 deletions receiver/mongodbatlasreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ These are the metrics available for this scraper.
| **mongodbatlas.disk.partition.space.max** | Disk partition space Aggregate of MongoDB Metrics DISK_PARTITION_SPACE_FREE, DISK_PARTITION_SPACE_USED | By | Gauge(Double) | <ul> <li>disk_status</li> </ul> |
| **mongodbatlas.disk.partition.usage.average** | Disk partition usage (%) Aggregate of MongoDB Metrics DISK_PARTITION_SPACE_PERCENT_FREE, DISK_PARTITION_SPACE_PERCENT_USED | 1 | Gauge(Double) | <ul> <li>disk_status</li> </ul> |
| **mongodbatlas.disk.partition.usage.max** | Disk partition usage (%) Aggregate of MongoDB Metrics MAX_DISK_PARTITION_SPACE_PERCENT_USED, MAX_DISK_PARTITION_SPACE_PERCENT_FREE | 1 | Gauge(Double) | <ul> <li>disk_status</li> </ul> |
| **mongodbatlas.disk.partition.utilization.average** | Disk partition utilization (%) MongoDB Metrics DISK_PARTITION_UTILIZATION | 1 | Gauge(Double) | <ul> </ul> |
| **mongodbatlas.disk.partition.utilization.max** | Disk partition utilization (%) MongoDB Metrics MAX_DISK_PARTITION_UTILIZATION | 1 | Gauge(Double) | <ul> </ul> |
| **mongodbatlas.disk.partition.utilization.average** | Disk partition utilization (%) MongoDB Metrics DISK_PARTITION_UTILIZATION | 1 | Gauge(Double) | <ul> <li>disk_status</li> </ul> |
| **mongodbatlas.disk.partition.utilization.max** | Disk partition utilization (%) MongoDB Metrics MAX_DISK_PARTITION_UTILIZATION | 1 | Gauge(Double) | <ul> <li>disk_status</li> </ul> |
| **mongodbatlas.process.asserts** | Number of assertions per second Aggregate of MongoDB Metrics ASSERT_REGULAR, ASSERT_USER, ASSERT_MSG, ASSERT_WARNING | {assertions}/s | Gauge(Double) | <ul> <li>assert_type</li> </ul> |
| **mongodbatlas.process.background_flush** | Amount of data flushed in the background MongoDB Metric BACKGROUND_FLUSH_AVG | 1 | Gauge(Double) | <ul> </ul> |
| **mongodbatlas.process.cache.io** | Cache throughput (per second) Aggregate of MongoDB Metrics CACHE_BYTES_READ_INTO, CACHE_BYTES_WRITTEN_FROM | By | Gauge(Double) | <ul> <li>cache_direction</li> </ul> |
Expand Down Expand Up @@ -63,16 +63,37 @@ These are the metrics available for this scraper.
| **mongodbatlas.system.fts.cpu.usage** | Full-text search (%) | 1 | Gauge(Double) | <ul> <li>cpu_state</li> </ul> |
| **mongodbatlas.system.fts.disk.used** | Full text search disk usage MongoDB Metric FTS_DISK_USAGE | By | Gauge(Double) | <ul> </ul> |
| **mongodbatlas.system.fts.memory.usage** | Full-text search Aggregate of MongoDB Metrics FTS_MEMORY_MAPPED, FTS_PROCESS_SHARED_MEMORY, FTS_PROCESS_RESIDENT_MEMORY, FTS_PROCESS_VIRTUAL_MEMORY | MiBy | Sum(Double) | <ul> <li>memory_state</li> </ul> |
| **mongodbatlas.system.memory.usage.average** | System Memory Usage Aggregate of MongoDB Metrics SYSTEM_MEMORY_AVAILABLE, SYSTEM_MEMORY_BUFFERS, SYSTEM_MEMORY_USED, SYSTEM_MEMORY_CACHED, SYSTEM_MEMORY_SHARED, SYSTEM_MEMORY_FREE | KiBy | Gauge(Double) | <ul> <li>memory_state</li> </ul> |
| **mongodbatlas.system.memory.usage.max** | System Memory Usage Aggregate of MongoDB Metrics MAX_SYSTEM_MEMORY_CACHED, MAX_SYSTEM_MEMORY_AVAILABLE, MAX_SYSTEM_MEMORY_USED, MAX_SYSTEM_MEMORY_BUFFERS, MAX_SYSTEM_MEMORY_FREE, MAX_SYSTEM_MEMORY_SHARED | KiBy | Gauge(Double) | <ul> <li>memory_state</li> </ul> |
| **mongodbatlas.system.memory.usage.average** | System Memory Usage Aggregate of MongoDB Metrics SYSTEM_MEMORY_AVAILABLE, SYSTEM_MEMORY_BUFFERS, SYSTEM_MEMORY_USED, SYSTEM_MEMORY_CACHED, SYSTEM_MEMORY_SHARED, SYSTEM_MEMORY_FREE | KiBy | Gauge(Double) | <ul> <li>memory_status</li> </ul> |
| **mongodbatlas.system.memory.usage.max** | System Memory Usage Aggregate of MongoDB Metrics MAX_SYSTEM_MEMORY_CACHED, MAX_SYSTEM_MEMORY_AVAILABLE, MAX_SYSTEM_MEMORY_USED, MAX_SYSTEM_MEMORY_BUFFERS, MAX_SYSTEM_MEMORY_FREE, MAX_SYSTEM_MEMORY_SHARED | KiBy | Gauge(Double) | <ul> <li>memory_status</li> </ul> |
| **mongodbatlas.system.network.io.average** | System Network IO Aggregate of MongoDB Metrics SYSTEM_NETWORK_IN, SYSTEM_NETWORK_OUT | By/s | Gauge(Double) | <ul> <li>direction</li> </ul> |
| **mongodbatlas.system.network.io.max** | System Network IO Aggregate of MongoDB Metrics MAX_SYSTEM_NETWORK_OUT, MAX_SYSTEM_NETWORK_IN | By/s | Gauge(Double) | <ul> <li>direction</li> </ul> |
| **mongodbatlas.system.paging.io.average** | Swap IO Aggregate of MongoDB Metrics SWAP_IO_IN, SWAP_IO_OUT | {pages}/s | Gauge(Double) | <ul> <li>direction</li> </ul> |
| **mongodbatlas.system.paging.io.max** | Swap IO Aggregate of MongoDB Metrics MAX_SWAP_IO_IN, MAX_SWAP_IO_OUT | {pages}/s | Gauge(Double) | <ul> <li>direction</li> </ul> |
| **mongodbatlas.system.paging.usage.average** | Swap usage Aggregate of MongoDB Metrics SWAP_USAGE_FREE, SWAP_USAGE_USED | KiBy | Gauge(Double) | <ul> <li>direction</li> </ul> |
| **mongodbatlas.system.paging.usage.max** | Swap usage Aggregate of MongoDB Metrics MAX_SWAP_USAGE_FREE, MAX_SWAP_USAGE_USED | KiBy | Gauge(Double) | <ul> <li>direction</li> </ul> |

**Highlighted metrics** are emitted by default.
**Highlighted metrics** are emitted by default. Other metrics are optional and not emitted by default.
Any metric can be enabled or disabled with the following scraper configuration:

```yaml
metrics:
<metric_name>:
enabled: <true|false>
```
## Resource attributes
| Name | Description | Type |
| ---- | ----------- | ---- |
| mongodb_atlas.db.name | Name of the Database | String |
| mongodb_atlas.disk.partition | Name of a disk partition | String |
| mongodb_atlas.host.name | Hostname of the process | String |
| mongodb_atlas.org_name | Organization Name | String |
| mongodb_atlas.process.id | ID of the process | String |
| mongodb_atlas.process.port | Port process is bound to | String |
| mongodb_atlas.process.type_name | Process type | String |
| mongodb_atlas.project.id | Project ID | String |
| mongodb_atlas.project.name | Project Name | String |
## Metric attributes
Expand All @@ -93,6 +114,7 @@ These are the metrics available for this scraper.
| global_lock_state | Which queue is locked |
| memory_issue_type | Type of memory issue encountered |
| memory_state | Memory usage type |
| memory_status | Memory measurement type |
| object_type | MongoDB object type |
| operation | Type of database operation |
| oplog_type | Oplog type |
Expand Down
3 changes: 3 additions & 0 deletions receiver/mongodbatlasreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver/internal/metadata"
)

const (
Expand Down Expand Up @@ -58,5 +60,6 @@ func createDefaultConfig() config.Receiver {
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(typeStr),
Granularity: defaultGranularity,
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
Metrics: metadata.DefaultMetricsSettings(),
}
}
Loading

0 comments on commit 439369e

Please sign in to comment.