Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCP] Log ListTimeSeries and AggregatedList requests duration #40661

Merged
merged 10 commits into from
Sep 3, 2024
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,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
Loading