Skip to content

Commit

Permalink
[receiver/mongodbatlasreceiver]: add / rename a few attributes (#7960)
Browse files Browse the repository at this point in the history
* [receiver/mongodbatlasreceiver]: add a few useful attributes to receiver

* [receivers/mongodbatlasreceiver] add and rename a few attributes

* Update CHANGELOG.md

Co-authored-by: Alex Boten <[email protected]>
  • Loading branch information
Mark Stumpf and codeboten authored Feb 25, 2022
1 parent c887d27 commit be014c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
### 🛑 Breaking changes 🛑

- Remove deprecated functions from jaeger translator (#8032)
- `mongodbatlasreceiver`: rename `mongodb.atlas.*` attributes to `mongodb_atlas.*` adhering to naming guidelines. Adding 3 new attributes (#7960)

### 🚩 Deprecations 🚩

Expand Down
11 changes: 7 additions & 4 deletions receiver/mongodbatlasreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ func (s *receiver) poll(ctx context.Context, time timeconstraints) (pdata.Metric
return pdata.Metrics{}, errors.Wrap(err, "error retrieving organizations")
}
for _, org := range orgs {
resourceAttributes.InsertString("mongodb.atlas.org_name", org.Name)
resourceAttributes.InsertString("mongodb_atlas.org_name", org.Name)
projects, err := s.client.Projects(ctx, org.ID)
if err != nil {
return pdata.Metrics{}, errors.Wrap(err, "error retrieving projects")
}
for _, project := range projects {
resourceAttributes.InsertString("mongodb.atlas.project", project.Name)
resourceAttributes.InsertString("mongodb_atlas.project.name", project.Name)
resourceAttributes.InsertString("mongodb_atlas.project.id", project.ID)
processes, err := s.client.Processes(ctx, project.ID)
if err != nil {
return pdata.Metrics{}, errors.Wrap(err, "error retrieving MongoDB Atlas processes")
Expand All @@ -99,6 +100,8 @@ func (s *receiver) poll(ctx context.Context, time timeconstraints) (pdata.Metric
resourceAttributes.CopyTo(resource.Attributes())
resource.Attributes().InsertString("host.name", process.Hostname)
resource.Attributes().InsertString("process.port", strconv.Itoa(process.Port))
resource.Attributes().InsertString("process.type_name", process.TypeName)
resource.Attributes().InsertString("process.id", process.ID)
resourceMetrics, err := s.extractProcessMetrics(
ctx,
time,
Expand Down Expand Up @@ -188,7 +191,7 @@ func (s *receiver) extractProcessDatabaseMetrics(
dbResource := pdata.NewResource()
resource.CopyTo(dbResource)
resource.Attributes().
InsertString("mongodb.atlas.database_name", db.DatabaseName)
InsertString("mongodb_atlas.db.name", db.DatabaseName)
metrics, err := s.client.ProcessDatabaseMetrics(
ctx,
resource,
Expand Down Expand Up @@ -223,7 +226,7 @@ func (s *receiver) extractProcessDiskMetrics(
diskResource := pdata.NewResource()
resource.CopyTo(diskResource)
diskResource.Attributes().
InsertString("mongodb.atlas.partition", disk.PartitionName)
InsertString("mongodb_atlas.disk.partition", disk.PartitionName)
metrics, err := s.client.ProcessDiskMetrics(
ctx,
diskResource,
Expand Down

0 comments on commit be014c3

Please sign in to comment.