Skip to content

Commit

Permalink
fix(storage): monitored resource detection (#11197)
Browse files Browse the repository at this point in the history
* fix(storage): populate monitored resource correctly

* refactor with additional integration tests

* refactor initialization of metricsContext

* remove exporter experimental option and add manual reader for tests

* go mod tidy

* dependency inject gcp detector for testing

* revert removal of metricExporter option

* revert changes to metricExporter option tests

* use struct embedding

* pass in resource correctly to exporter

* update test using resource value

* add tests checking resource values

* add option to disable exporter in unit tests

* address feedback

* use project-id not project_id...
  • Loading branch information
frankyn authored Dec 20, 2024
1 parent a3cb8c4 commit 911bcd8
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 198 deletions.
19 changes: 19 additions & 0 deletions storage/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
"google.golang.org/api/transport"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/encoding"
Expand Down Expand Up @@ -118,6 +119,24 @@ type grpcStorageClient struct {
settings *settings
}

func enableClientMetrics(ctx context.Context, s *settings, config storageConfig) (*metricsContext, error) {
var project string
// TODO: use new auth client
c, err := transport.Creds(ctx, s.clientOption...)
if err == nil {
project = c.ProjectID
}
metricsContext, err := newGRPCMetricContext(ctx, metricsConfig{
project: project,
interval: config.metricInterval,
manualReader: config.manualReader},
)
if err != nil {
return nil, fmt.Errorf("gRPC Metrics: %w", err)
}
return metricsContext, nil
}

// newGRPCStorageClient initializes a new storageClient that uses the gRPC
// Storage API.
func newGRPCStorageClient(ctx context.Context, opts ...storageOption) (storageClient, error) {
Expand Down
Loading

0 comments on commit 911bcd8

Please sign in to comment.