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

tests: TestExportMetrics_conversionFromViewData doesn't work with proxies #77

Open
jamie-digital opened this issue Sep 5, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@jamie-digital
Copy link

Please answer these questions before submitting a bug report.

What version of the Exporter are you using?

v0.6.0

What version of OpenCensus are you using?

N/A

What version of Go are you using?

go version go1.13 darwin/amd64

What did you do?

If possible, provide a recipe for reproducing the error.

$ HTTP_PROXY=http://127.0.0.1:1234/ go test
--- FAIL: TestExportMetrics_conversionFromViewData (0.16s)
    viewdata_to_metrics_test.go:146: Got:
        null
        Want:
        [
          {
            "node": {
              "identifier": {
                "pid": 74790,
                "start_timestamp": {
                  "seconds": 1567689400,
                  "nanos": 12477000
                }
              },
              "library_info": {
                "language": 4,
                "exporter_version": "0.0.1",
                "core_library_version": "0.22.0"
              },
              "service_info": {}
            },
            "resource": {}
          },
          {
            "metrics": [
              {
                "metric_descriptor": {
                  "name": "ocagent.io/latency",
                  "description": "The latency of the various methods",
                  "unit": "ms",
                  "type": 4
                },
                "timeseries": [
                  {
                    "start_timestamp": {
                      "seconds": 1543160298,
                      "nanos": 997
                    },
                    "points": [
                      {
                        "timestamp": {
                          "seconds": 1543160298,
                          "nanos": 100000997
                        },
                        "Value": {
                          "Int64Value": 4
                        }
                      }
                    ]
                  }
                ]
              }
            ],
            "resource": {}
          }
        ]
FAIL
exit status 1
FAIL	contrib.go.opencensus.io/exporter/ocagent	3.289s

What did you expect to see?

Tests pass.

What did you see instead?

TestExportMetrics_conversionFromViewData fails, as the exporter attempts but fails to use an HTTP proxy for the host "".

Additional context

The test supplies an agent address with a port but no host:

	ocexp, err := NewExporter(
		WithInsecure(),
		WithAddress(":"+agentPortStr),      // <- no host here
		WithReconnectionPeriod(reconnectionPeriod),
	)

If HTTP_PROXY is set in the env, grpc (I assume) attempts to use an HTTP proxy. As the HTTP proxy code (https://github.com/golang/net/blob/master/http/httpproxy/proxy.go#L256) treats an empty host as an error, it isn't possible to set NO_PROXY to ignore the proxy for requests with no host. As a result, the exporter is unable to export metrics, causing TestExportMetrics_conversionFromViewData to fail.

The simplest fix would be to specify localhost or similar as the host.

@jamie-digital jamie-digital added the bug Something isn't working label Sep 5, 2019
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

No branches or pull requests

1 participant