...

Source file src/edge-infra.dev/pkg/lib/gcp/monitoring/metrics/metrics.go

Documentation: edge-infra.dev/pkg/lib/gcp/monitoring/metrics

     1  package metrics
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	monitoring "cloud.google.com/go/monitoring/apiv3/v2"
     8  )
     9  
    10  type Client struct {
    11  	client    *monitoring.MetricClient
    12  	ctx       context.Context
    13  	ProjectID string
    14  }
    15  
    16  // New creates a new GCP Metric client.
    17  func New(ctx context.Context, projectID string) (*Client, error) {
    18  	client, err := monitoring.NewMetricClient(ctx) // may need to add options later
    19  	if err != nil {
    20  		return nil, fmt.Errorf("metrics.New: failed to create metric client. error: %w", err)
    21  	}
    22  
    23  	return &Client{
    24  		client:    client,
    25  		ctx:       ctx,
    26  		ProjectID: projectID,
    27  	}, nil
    28  }
    29  

View as plain text