Skip to content

Commit

Permalink
[GCP] Log ListTimeSeries and AggregatedList requests duration (#4…
Browse files Browse the repository at this point in the history
…0661)

* log total time taken for ListTimeSeries requests

* add changelog entry

* fix PR id

* log total time taken for AggregatedList request

* update changelog entry

* remove log

* Update x-pack/metricbeat/module/gcp/metrics/compute/metadata.go

Co-authored-by: subham sarkar <sarkar.subhams2@gmail.com>

* Update x-pack/metricbeat/module/gcp/metrics/metrics_requester.go

Co-authored-by: subham sarkar <sarkar.subhams2@gmail.com>

* Update x-pack/metricbeat/module/gcp/metrics/compute/metadata.go

Co-authored-by: Harnish Chavda <118714680+harnish-elastic@users.noreply.github.com>

* Update x-pack/metricbeat/module/gcp/metrics/metrics_requester.go

Co-authored-by: Harnish Chavda <118714680+harnish-elastic@users.noreply.github.com>

---------

Co-authored-by: subham sarkar <sarkar.subhams2@gmail.com>
Co-authored-by: Harnish Chavda <118714680+harnish-elastic@users.noreply.github.com>
(cherry picked from commit 3f3e57d)
  • Loading branch information
gpop63 authored and mergify[bot] committed Sep 16, 2024
1 parent 29ccd48 commit db4e051
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add metrics related to alert in all the vSphere metricsets. {pull}40714[40714]
- Add support for period based intervalID in vSphere host and datastore metricsets {pull}40678[40678]
- Add new metrics for datastore and minor changes to overall vSphere metrics {pull}40766[40766]
- Log the total time taken for GCP `ListTimeSeries` and `AggregatedList` requests {pull}40661[40661]

*Metricbeat*

Expand Down
6 changes: 6 additions & 0 deletions x-pack/metricbeat/module/gcp/metrics/compute/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"strconv"
"strings"
"time"

compute "cloud.google.com/go/compute/apiv1"
"cloud.google.com/go/compute/apiv1/computepb"
Expand Down Expand Up @@ -188,6 +189,11 @@ func (s *metadataCollector) getComputeInstances(ctx context.Context) {

defer instancesClient.Close()

start := time.Now()
defer func() {
s.logger.Debugf("Total time taken for compute AggregatedList request: %s", time.Since(start))
}()

it := instancesClient.AggregatedList(ctx, &computepb.AggregatedListInstancesRequest{
Project: s.projectID,
})
Expand Down
5 changes: 5 additions & 0 deletions x-pack/metricbeat/module/gcp/metrics/metrics_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func (r *metricsRequester) Metrics(ctx context.Context, serviceName string, alig
}
}

start := time.Now()
defer func() {
r.logger.Debugf("Total time taken for all ListTimeSeries requests: %s and config period: %s", time.Since(start), r.config.period.AsDuration())
}()

for mt, meta := range metricsToCollect {
wg.Add(1)

Expand Down

0 comments on commit db4e051

Please sign in to comment.