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 <[email protected]>

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

Co-authored-by: subham sarkar <[email protected]>

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

Co-authored-by: Harnish Chavda <[email protected]>

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

Co-authored-by: Harnish Chavda <[email protected]>

---------

Co-authored-by: subham sarkar <[email protected]>
Co-authored-by: Harnish Chavda <[email protected]>
  • Loading branch information
3 people authored Sep 3, 2024
1 parent 6715964 commit 3f3e57d
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 @@ -324,6 +324,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add SSL support for aerospike module {pull}38126[38126]
- Add new metricset network for the vSphere module. {pull}40559[40559]
- Add new metricset resourcepool for the vSphere module. {pull}40456[40456]
- 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 3f3e57d

Please sign in to comment.