Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

a new exporter without a location returns an error about setting default location #164

Closed
odeke-em opened this issue Jun 25, 2019 · 7 comments · Fixed by #165
Closed

a new exporter without a location returns an error about setting default location #164

odeke-em opened this issue Jun 25, 2019 · 7 comments · Fixed by #165
Labels
bug Something isn't working

Comments

@odeke-em
Copy link
Contributor

Given code that used to work in the past

        projectID := "odeke-sandbox"
        sde, err := stackdriver.NewExporter(stackdriver.Options{
                ProjectID: projectID,
        })
        if err != nil {
                log.Fatalf("Failed to start Stackdriver OpenCensus exporter: %v", err)
        }
        defer sde.Flush()
        trace.RegisterExporter(sde)

I get back an unexpected error

$ GOOGLE_APPLICATION_CREDENTIALS=odeke-sandbox.json go run main.go 
2019/06/24 17:40:06 Setting Stackdriver default location failed: Get \
http://169.254.169.254/computeMetadata/v1/instance/zone: dial tcp 169.254.169.254:80: \
i/o timeout

I believe we should only be trying to find a default location if we are on GCE and in the past we've been able to run this exporter on local computers or even on other clouds.

@odeke-em odeke-em added the bug Something isn't working label Jun 25, 2019
@DazWilkin
Copy link

I just noticed this too.

I am using the Agent to export to Stackdriver and, when I saw the error, reconfigured my client to use the Stackdriver exporter directly. Since the agent uses the same code, it's unsurprising that both fail.

Curiously, I do have some measurements recorded to Stackdriver so, somehow -- and I don't understand how -- I had this working albeit briefly.

@DazWilkin
Copy link

DazWilkin commented Jun 26, 2019

What's curious is that it's looking for /instance/zone in the metadata.

When I deployed the agent to a GCE VM, it incorrectly (because it's using this metadata link) binds to the VM's zone:

2019/06/26 16:47:06 Setting Stackdriver default location to "us-west1-c"

So, it's both ignoring my specified project value and it's choosing to reference ./instance/zone when I assume it should be looking for:

curl \
--header "Metadata-Flavor: Google" \
http://169.254.169.254/computeMetadata/v1/project/project-id

See comment below: the error is confusing but accurate. It is setting the default location to the correct zone. I just don't know why it's doing this. I need to determine whether there's another reason why I'm not getting measurements (consistently) to Stackdriver.

@DazWilkin
Copy link

DazWilkin commented Jun 26, 2019

Hmmm:
https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/blame/master/stackdriver.go#L293

Adding Location to the Stackdriver Exporter avoids the error:

sd, err := stackdriver.NewExporter(stackdriver.Options{
		ProjectID:    "...",
		Location:     "us-west1-c",
	})

But:

  1. Why is the Location necessary?
  2. The OpenCensus Agent does not currently provide a mechanism to define Location

@odeke-em
Copy link
Contributor Author

Kindly paging @fabxc @rghetia from #84

@rghetia
Copy link
Contributor

rghetia commented Jun 26, 2019

It is misleading to print that message when it is not running on GCE. @odeke-em , @DazWilkin it should still continue to export the metrics/traces without location. Does it not?

Agent does not inject resource labels but it simply forwards those it receives from the client.

@DazWilkin
Copy link

I think so.

Confirming now.

I think this was a red-herring error for another issue that my client has.

@DazWilkin
Copy link

Yes, measurements are being reported by Stackdriver.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants