diff --git a/internal/apmcloudutil/gcp.go b/internal/apmcloudutil/gcp.go index fc2d291c1..f2034d299 100644 --- a/internal/apmcloudutil/gcp.go +++ b/internal/apmcloudutil/gcp.go @@ -24,7 +24,6 @@ import ( "fmt" "net/http" "path" - "strconv" "strings" "go.elastic.co/apm/v2/model" @@ -60,8 +59,7 @@ func getGCPCloudMetadata(ctx context.Context, client *http.Client, out *model.Cl Zone string `json:"zone"` } `json:"instance"` Project struct { - NumericProjectID *int `json:"numericProjectId"` - ProjectID string `json:"projectId"` + ProjectID string `json:"projectId"` } `json:"project"` } decoder := json.NewDecoder(resp.Body) @@ -82,11 +80,8 @@ func getGCPCloudMetadata(ctx context.Context, client *http.Client, out *model.Cl if gcpMetadata.Instance.MachineType != "" { out.Machine = &model.CloudMachine{Type: splitGCPMachineType(gcpMetadata.Instance.MachineType)} } - if gcpMetadata.Project.NumericProjectID != nil || gcpMetadata.Project.ProjectID != "" { - out.Project = &model.CloudProject{Name: gcpMetadata.Project.ProjectID} - if gcpMetadata.Project.NumericProjectID != nil { - out.Project.ID = strconv.Itoa(*gcpMetadata.Project.NumericProjectID) - } + if gcpMetadata.Project.ProjectID != "" { + out.Project = &model.CloudProject{ID: gcpMetadata.Project.ProjectID} } return nil } diff --git a/internal/apmcloudutil/gcp_test.go b/internal/apmcloudutil/gcp_test.go index ecfa82865..ea110ad60 100644 --- a/internal/apmcloudutil/gcp_test.go +++ b/internal/apmcloudutil/gcp_test.go @@ -50,8 +50,7 @@ func TestGCPCloudMetadata(t *testing.T) { Type: "n1-standard-1", }, Project: &model.CloudProject{ - ID: "513326162531", - Name: "elastic-apm", + ID: "elastic-apm", }, }, out) } @@ -73,8 +72,7 @@ func TestGCPCloudMetadata(t *testing.T) { ID: "00bf4bf02ddbda278fb9b4d70365018bd18a7d3ea42991e2cb03320b48a72b69b6d3765ff526347d7b8e0934dda4591cb1be3ead93086f0b390187fae88ee7cf8acdae7383", }, Project: &model.CloudProject{ - ID: "513326162531", - Name: "elastic-apm", + ID: "elastic-apm", }, }, out) })