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

gcp: Cloud Run Application details are not labeled on traces #817

Closed
ahmetb opened this issue Jun 9, 2021 · 2 comments
Closed

gcp: Cloud Run Application details are not labeled on traces #817

ahmetb opened this issue Jun 9, 2021 · 2 comments
Assignees
Milestone

Comments

@ahmetb
Copy link

ahmetb commented Jun 9, 2021

I am opening this issue because of this file that does Cloud Run detection

// Part of Cloud Run container runtime contract.
// See https://cloud.google.com/run/docs/reference/container-contract
if service := c.getenv("K_SERVICE"); service == "" {
errInfo = append(errInfo, "envvar K_SERVICE contains empty string.")
} else {
attributes = append(attributes, semconv.ServiceNameKey.String(service))
}
resource, err := resource.New(ctx, resource.WithAttributes(attributes...))
if err != nil {
errInfo = append(errInfo, err.Error())
}
Please migrate the issue to the right repo if that's wrong.

Right now, it seems that the traces are exported (from libraries such as otelgrpc or otelmux) do not properly label the Cloud Run service details such as:

  • service name
  • service revision (a Cloud Run concept)
  • region (a GCP concept)
  • project ID (a GCP concept)

as a result, the Google Cloud Trace UI shows something like this which is not linking back to the Cloud Run service properly:

image

I expected to get labels out of the trace spans that contain the application info

@dashpole dashpole self-assigned this Sep 13, 2021
@dashpole
Copy link
Contributor

dashpole commented Feb 10, 2022

I was able to get this to work when I tried it. See GoogleCloudPlatform/golang-samples@main...dashpole:opentelemetry_demo#diff-5351ce38b44519584b4f0959dc4095b977aa13372f7873f3d82f8c70daf85236R65-R68 for how to use the resource detector. Are you installing the cloud run detector?

In my service's logs, when I send a request to the service, I get this:

...
Resource: [
  0: {
    Key: "cloud.account.id"
    Value: {
      Type: "STRING"
      Value: "<project id>"
    }}
  1: {
    Key: "cloud.provider"
    Value: {
      Type: "STRING"
      Value: "gcp"
    }}
  2: {
    Key: "cloud.region"
    Value: {
      Type: "STRING"
      Value: "projects/<project number>/regions/us-east1"
  }}
  3: {
    Key: "service.instance.id"
    Value: {
      Type: "STRING"
      Value: "<ID>"
  }}
  4: {
    Key: "service.name"
    Value: {
      Type: "STRING"
      Value: "helloworld"
  }}
  5: {
    Key: "service.namespace"
    Value: {
      Type: "STRING"
      Value: "cloud-run-managed"
  }}
]

plantfansam referenced this issue in plantfansam/opentelemetry-go-contrib Mar 18, 2022
…lp (#817)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Liz Fong-Jones <lizf@honeycomb.io>
Co-authored-by: lizthegrey <lizthegrey@users.noreply.github.com>
@dashpole
Copy link
Contributor

Feel free to reopen if you have further qustions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants