Skip to content

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

@DouglasHeriot

Description

@DouglasHeriot

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: my-cloud-run-service-name-00076-2lq
cloud.account.id: my-project-name
cloud.provider: gcp

I have a draft fix in pull request #14923

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions