@@ -28,7 +28,6 @@ import (
2828 "golang.org/x/pkgsite/internal/derrors"
2929 "golang.org/x/pkgsite/internal/log"
3030 "golang.org/x/pkgsite/internal/secrets"
31- mrpb "google.golang.org/genproto/googleapis/api/monitoredres"
3231 "gopkg.in/yaml.v3"
3332)
3433
@@ -151,7 +150,7 @@ type Config struct {
151150 // "An object representing a resource that can be used for monitoring, logging,
152151 // billing, or other purposes. Examples include virtual machine instances,
153152 // databases, and storage devices such as disks.""
154- MonitoredResource * mrpb. MonitoredResource
153+ MonitoredResource * MonitoredResource
155154
156155 // FallbackVersionLabel is used as the VersionLabel when not hosting on
157156 // AppEngine.
@@ -193,6 +192,19 @@ type Config struct {
193192 VulnDB string
194193}
195194
195+ // MonitoredResource represents the resource that is running the current binary.
196+ // It might be a Google AppEngine app, a Cloud Run service, or a Kubernetes pod.
197+ // See https://cloud.google.com/monitoring/api/resources for more
198+ // details:
199+ // "An object representing a resource that can be used for monitoring, logging,
200+ // billing, or other purposes. Examples include virtual machine instances,
201+ // databases, and storage devices such as disks."
202+ type MonitoredResource struct {
203+ Type string `yaml:"type,omitempty"`
204+
205+ Labels map [string ]string `yaml:"labels,omitempty"`
206+ }
207+
196208// AppVersionLabel returns the version label for the current instance. This is
197209// the AppVersionID available, otherwise a string constructed using the
198210// timestamp of process start.
@@ -444,7 +456,7 @@ func Init(ctx context.Context) (_ *Config, err error) {
444456 // Use the gae_app monitored resource. It would be better to use the
445457 // gae_instance monitored resource, but that's not currently supported:
446458 // https://cloud.google.com/logging/docs/api/v2/resource-list#resource-types
447- cfg .MonitoredResource = & mrpb. MonitoredResource {
459+ cfg .MonitoredResource = & MonitoredResource {
448460 Type : "gae_app" ,
449461 Labels : map [string ]string {
450462 "project_id" : cfg .ProjectID ,
@@ -454,7 +466,7 @@ func Init(ctx context.Context) (_ *Config, err error) {
454466 },
455467 }
456468 case cfg .OnCloudRun ():
457- cfg .MonitoredResource = & mrpb. MonitoredResource {
469+ cfg .MonitoredResource = & MonitoredResource {
458470 Type : "cloud_run_revision" ,
459471 Labels : map [string ]string {
460472 "project_id" : cfg .ProjectID ,
@@ -464,7 +476,7 @@ func Init(ctx context.Context) (_ *Config, err error) {
464476 },
465477 }
466478 case cfg .OnGKE ():
467- cfg .MonitoredResource = & mrpb. MonitoredResource {
479+ cfg .MonitoredResource = & MonitoredResource {
468480 Type : "k8s_container" ,
469481 Labels : map [string ]string {
470482 "project_id" : cfg .ProjectID ,
@@ -486,7 +498,7 @@ func Init(ctx context.Context) (_ *Config, err error) {
486498 cfg .InstanceID = id
487499 }
488500 } else { // running locally, perhaps
489- cfg .MonitoredResource = & mrpb. MonitoredResource {
501+ cfg .MonitoredResource = & MonitoredResource {
490502 Type : "global" ,
491503 Labels : map [string ]string {"project_id" : cfg .ProjectID },
492504 }
0 commit comments