Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func waitForHealthy() {
return
}
ticker := time.NewTicker(time.Duration(*healthCheckFreq) * time.Second)
for _ = range ticker.C {
for range ticker.C {
if healthCheck() == nil {
ticker.Stop()
return
Expand All @@ -258,7 +258,7 @@ func runHealthChecks() {
// immediately.
ticker := time.NewTicker(time.Duration(*healthCheckFreq) * time.Second)
badHealthChecks := 0
for _ = range ticker.C {
for range ticker.C {
if healthCheck() != nil {
badHealthChecks++
} else {
Expand Down
8 changes: 4 additions & 4 deletions agent/banner/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func (w *bannerResponseWriter) getFavIconLink() (string, error) {
}
var favIconLinkBuf bytes.Buffer
templateVals := &struct {
FavIconUrl string
FavIconURL string
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is already being referenced by the updated name in the favIconLinkTemplate.

}{
FavIconUrl: w.favIconURL,
FavIconURL: w.favIconURL,
}
if err := favIconLinkTmpl.Execute(&favIconLinkBuf, templateVals); err != nil {
return "", err
Expand Down Expand Up @@ -185,9 +185,9 @@ func (w *bannerResponseWriter) WriteHeader(statusCode int) {
w.wrapped.WriteHeader(statusCode)
w.writeBytes = true
return
} else {
w.Header().Del(contentEncodingHeader)
}
w.Header().Del(contentEncodingHeader)

favIconLink, err := w.getFavIconLink()
if err != nil {
sc := http.StatusInternalServerError
Expand Down
4 changes: 3 additions & 1 deletion agent/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type metricClient interface {
CreateTimeSeries(ctx context.Context, req *monitoringpb.CreateTimeSeriesRequest, opts ...gax.CallOption) error
}

// MetricHandler handles metrics collections/writes to cloud monarch
type MetricHandler struct {
mu sync.Mutex
projectID string
Expand Down Expand Up @@ -147,7 +148,7 @@ func parseGCEResourceLabels(resourceKeyValues string) (*map[string]string, error
"zone": "",
}
err := parseResourceLabels(resourceKeyValues, &flags)
for key, _ := range res {
for key := range res {
flagKey := responseCountResourceKeyToFlagName[key]
flagValue := flags[flagKey]
if flagValue == "" {
Expand Down Expand Up @@ -178,6 +179,7 @@ func parseResourceLabels(resourceKeyValues string, labels *map[string]string) er
return nil
}

// GetResponseCountMetricType constructs and returns a string representing the response_count metric type
func (h *MetricHandler) GetResponseCountMetricType() string {
if h == nil {
return ""
Expand Down
6 changes: 3 additions & 3 deletions agent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ func parseRequestIDs(response *http.Response, metricHandler *metrics.MetricHandl
}
responseBytes, err := ioutil.ReadAll(responseBody)
if err != nil {
return nil, fmt.Errorf("Failed to read the forwarded request: %q\n", err.Error())
return nil, fmt.Errorf("failed to read the forwarded request: %q", err.Error())
}
if response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Failed to list pending requests: %d, %q", response.StatusCode, responseBytes)
return nil, fmt.Errorf("failed to list pending requests: %d, %q", response.StatusCode, responseBytes)
}
if len(responseBytes) <= 0 {
return []string{}, nil
}

var requests []string
if err := json.Unmarshal(responseBytes, &requests); err != nil {
return nil, fmt.Errorf("Failed to parse the requests: %q\n", err.Error())
return nil, fmt.Errorf("failed to parse the requests: %q", err.Error())
}
return requests, nil
}
Expand Down
1 change: 1 addition & 0 deletions agent/websockets/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func (sb *shimmedBody) Close() error {
return sb.closer.Close()
}

// ShimBody returns a function that injects code into a *http.Response Body
func ShimBody(shimPath string) (func(resp *http.Response) error, error) {
var templateBuf bytes.Buffer
if err := shimTmpl.Execute(&templateBuf, &struct{ ShimPath string }{ShimPath: shimPath}); err != nil {
Expand Down
1 change: 1 addition & 0 deletions testing/runlocal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
respTmpl = template.Must(template.New("response").Parse(responseTemplate))
)

// RunLocalProxy runs a proxy locally
func RunLocalProxy(ctx context.Context) (int, error) {
// This assumes that "Make build" has been run
proxyArgs := fmt.Sprintf("${GOPATH}/bin/inverting-proxy --port=%d", *port)
Expand Down