Skip to content

Commit

Permalink
Added missing resource attributes (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun-mw authored and bhogayatakb committed Jun 12, 2024
1 parent 86adfcc commit 1966562
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
16 changes: 8 additions & 8 deletions receiver/k8sclusterreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,14 @@ Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4
| k8s.deployment.uid | The UID of the Deployment. | Any Str | true |
| k8s.hpa.name | The k8s hpa name. | Any Str | true |
| k8s.hpa.uid | The k8s hpa uid. | Any Str | true |
| k8s.ingress.annotations | Annotations of the Role. | Any Str | true |
| k8s.ingress.labels | Labels of the Role. | Any Str | true |
| k8s.ingress.name | The name of the Role. | Any Str | true |
| k8s.ingress.namespace | The namespace of the Role. | Any Str | true |
| k8s.ingress.rules | Rules of the Role. | Any Str | true |
| k8s.ingress.start_time | The start time of the Role. | Any Str | true |
| k8s.ingress.type | The type of the Role. | Any Str | true |
| k8s.ingress.uid | The UID of the Role. | Any Str | true |
| k8s.ingress.annotations | Annotations of the Ingress. | Any Str | true |
| k8s.ingress.labels | Labels of the Ingress. | Any Str | true |
| k8s.ingress.name | The name of the Ingress. | Any Str | true |
| k8s.ingress.namespace | The namespace of the Ingress. | Any Str | true |
| k8s.ingress.rules | Rules of the Ingress. | Any Str | true |
| k8s.ingress.start_time | The start time of the Ingress. | Any Str | true |
| k8s.ingress.type | The type of the Ingress. | Any Str | true |
| k8s.ingress.uid | The UID of the Ingress. | Any Str | true |
| k8s.job.name | The k8s pod name. | Any Str | true |
| k8s.job.uid | The k8s job uid. | Any Str | true |
| k8s.kubelet.version | The version of Kubelet running on the node. | Any Str | false |
Expand Down
2 changes: 1 addition & 1 deletion receiver/mongodbreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@ The amount of time that the server has been running.
| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| database | The name of a database. | Any Str | true |
| mongodb.database.name | The name of a database (redundant). | Any Str | false |
| mongodb.database.name | The name of a database (redundant). | Any Str | true |

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions receiver/mongodbreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource_attributes:
type: string
mongodb.database.name:
description: The name of a database (redundant).
enabled: true
type: string

attributes:
Expand Down
26 changes: 24 additions & 2 deletions receiver/mongodbreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ func (s *mongodbScraper) collectAdminDatabase(ctx context.Context, now pcommon.T
return
}
s.recordAdminStats(now, serverStatus, errs)
s.mb.EmitForResource()

rb := s.mb.NewResourceBuilder()
rb.SetDatabase("N/A")
rb.SetMongodbDatabaseName("N/A")

s.mb.EmitForResource(
metadata.WithResource(rb.Emit()),
)
}

func (s *mongodbScraper) collectTopStats(ctx context.Context, now pcommon.Timestamp, errs *scrapererror.ScrapeErrors) {
Expand All @@ -169,7 +176,14 @@ func (s *mongodbScraper) collectTopStats(ctx context.Context, now pcommon.Timest
return
}
s.recordOperationTime(now, topStats, errs)
s.mb.EmitForResource()

rb := s.mb.NewResourceBuilder()
rb.SetDatabase("N/A")
rb.SetMongodbDatabaseName("N/A")

s.mb.EmitForResource(
metadata.WithResource(rb.Emit()),
)
}

func (s *mongodbScraper) collectIndexStats(ctx context.Context, now pcommon.Timestamp, databaseName string, collectionName string, errs *scrapererror.ScrapeErrors) {
Expand All @@ -183,6 +197,14 @@ func (s *mongodbScraper) collectIndexStats(ctx context.Context, now pcommon.Time
}
s.recordIndexStats(now, indexStats, databaseName, collectionName, errs)

rb := s.mb.NewResourceBuilder()
rb.SetDatabase("N/A")
rb.SetMongodbDatabaseName("N/A")

s.mb.EmitForResource(
metadata.WithResource(rb.Emit()),
)

if s.removeDatabaseAttr {
rb := s.mb.NewResourceBuilder()
rb.SetDatabase(databaseName)
Expand Down
5 changes: 5 additions & 0 deletions receiver/postgresqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ func (p *postgreSQLScraper) scrape(ctx context.Context) (pmetric.Metrics, error)
p.collectMaxConnections(ctx, now, listClient, &errs)
p.collectDatabaseLocks(ctx, now, listClient, &errs)


rb := p.mb.NewResourceBuilder()
rb.SetPostgresqlDatabaseName("N/A")
p.mb.EmitForResource(metadata.WithResource(rb.Emit()))

return p.mb.Emit(), errs.combine()
}

Expand Down

0 comments on commit 1966562

Please sign in to comment.