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

OpenTelemetry on Cloud Run does not include task_id in Monitored Resource #14925

Open
DouglasHeriot opened this issue Jan 10, 2025 · 0 comments · May be fixed by #14923
Open

OpenTelemetry on Cloud Run does not include task_id in Monitored Resource #14925

DouglasHeriot opened this issue Jan 10, 2025 · 0 comments · May be fixed by #14923
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@DouglasHeriot
Copy link

What component of google-cloud-cpp is this related to?: google/cloud/opentelemetry

Describe the bug: When inside a Cloud Run environment, the MonitoredResource in a CreateTimeSeriesRequest to the Cloud Monitoring API does not include the necessary fields for the generic_task resource type, and is rejected.

To Reproduce

  • Deploy a binary on Cloud Run that uses MakeResourceDetector() to create an OTel Resource object, and uses MakeMonitoringExporter() to export to Cloud Monitoring
  • Observe errors in Cloud Monitoring audit logs:

One or more TimeSeries could not be written: timeSeries[1]: The set of resource labels is incomplete. Missing labels: (namespace task_id).; timeSeries[0]: The set of resource labels is incomplete. Missing labels: (namespace task_id).; timeSeries[2]: The set of resource labels is incomplete. Missing labels: (namespace task_id).

Expected behavior: Should follow the well-tested Golang implementation where the faas.instance OTel Resource Attribute is mapped to MonitoredResource task_id. As the service.namespace OTel Resource Attribute is not set by the Resource Detector from within Cloud Run, it should be mapped as an empty string (as in golang implementation), rather than being left absent.

What version of google-cloud-cpp are you using?: 2.3.0

Example OTel Resource Attributes from within Cloud Run:

service.name: unknown_service
telemetry.sdk.name: opentelemetry
faas.name: my-cloud-run-service-name
telemetry.sdk.version: 1.16.1
cloud.platform: gcp_cloud_run
telemetry.sdk.language: cpp
faas.instance: 0066d92480fc484796ce902f1b607e033bc3750442848d702f657a75e12c4b4dd89466b825feca5caf88fda7618a27794c7f4724cabd17de134aadde1d2e8abbf124fc5d2f
faas.version: a-us-central1-pbs-cloud-run-00076-2lq
cloud.account.id: my-project-name
cloud.provider: gcp

I have a draft fix in pull request #14923

@DouglasHeriot DouglasHeriot added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 10, 2025
DouglasHeriot added a commit to DouglasHeriot/google-cloud-cpp that referenced this issue Jan 10, 2025
…d Run

Fixes googleapis#14925

When inside a Cloud Run environment, the [`MonitoredResource`](https://cloud.google.com/monitoring/api/ref_v3/rpc/google.monitoring.v3#google.monitoring.v3.TimeSeries) in a [`CreateTimeSeriesRequest`](https://cloud.google.com/monitoring/api/ref_v3/rpc/google.monitoring.v3#google.monitoring.v3.CreateTimeSeriesRequest) to the Cloud Monitoring API does not include the necessary fields for the [`generic_task`](https://cloud.google.com/monitoring/api/resources#tag_generic_task) resource type, and is rejected.

Should follow the [well-tested Golang implementation](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/8da0f42dab085c916987891419461d583a2aa96e/internal/resourcemapping/resourcemapping.go#L153) where the `faas.instance` OTel Resource Attribute is mapped to `MonitoredResource` `task_id`. As the `service.namespace` OTel Resource Attribute is not set by the Resource Detector from within Cloud Run, it should be mapped as an empty string (as in [golang implementation](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/8da0f42dab085c916987891419461d583a2aa96e/internal/resourcemapping/resourcemapping.go#L250)), rather than being left absent.
DouglasHeriot added a commit to DouglasHeriot/google-cloud-cpp that referenced this issue Jan 10, 2025
Fixes googleapis#14925

When inside a Cloud Run environment, the `MonitoredResource` in a `CreateTimeSeriesRequest` to the Cloud Monitoring API does not include the necessary fields for the `generic_task` resource type, and is rejected.

Should follow the well-tested Golang implementation where the `faas.instance` OTel Resource Attribute is mapped to `MonitoredResource` `task_id`. As the `service.namespace` OTel Resource Attribute is not set by the Resource Detector from within Cloud Run, it should be mapped as an empty string, rather than being left absent.

https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/8da0f42dab085c916987891419461d583a2aa96e/internal/resourcemapping/resourcemapping.go#L153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
1 participant