census-instrumentation / opencensus-service

OpenCensus service allows OpenCensus libraries to export to an exporter service rather than having to link vendor-specific exports.
Apache License 2.0
153 stars 63 forks source link

Error from zpages #123

Closed moooofly closed 6 years ago

moooofly commented 6 years ago

As the following shows:

[#300#root@ubuntu-1604 /go/src/github.com/census-instrumentation/opencensus-service]$GOOGLE_APPLICATION_CREDENTIALS=./stackdriver-moooofly-fa114f37b0b2.json ./bin/ocagent_linux -c cmd/ocagent/config.yaml
2018/10/19 14:43:20 "stackdriver" trace-exporter enabled
2018/10/19 14:43:20 "zipkin" trace-exporter enabled
2018/10/19 14:43:20 Running OpenCensus interceptor as a gRPC service at "127.0.0.1:55678"
2018/10/19 14:43:20 Running zPages at ":55679"
2018/10/19 14:43:50 zpages: executing template: template: rpcz:31:41: executing "rpcz" at <count>: wrong type for value; expected int64; got int

it is from here

// WriteHTMLRpczSummary writes HTML to w containing per-method RPC stats.
//
// It includes neither a header nor footer, so you can embed this data in other pages.
func WriteHTMLRpczSummary(w io.Writer) {
    mu.Lock()
    if err := statsTemplate.Execute(w, getStatsPage()); err != nil {     // here
        log.Printf("zpages: executing template: %v", err)
    }
    mu.Unlock()
}
odeke-em commented 6 years ago

Thanks for this report @moooofly, what version of OpenCensus-Go are you using?

Firstly, please do go get -u -v go.opencensus.io/... and then afterwards if that fails, let's file an issue on OpenCensus-Go https://github.com/census-instrumentation/opencensus-go as this issue is from that repository

moooofly commented 6 years ago

After go get -u -v go.opencensus.io/..., still get this error message as above.

[#251#root@ubuntu-1604 /go/src/go.opencensus.io]$git branch
  another_way
  comment_and_test
* master
[#252#root@ubuntu-1604 /go/src/go.opencensus.io]$git lg1 -1
* 1eb9a13 - (4 days ago) set countFormatter param to int64 (#948) — Philippe MARTIN (HEAD -> master, origin/master, origin/HEAD)
[#253#root@ubuntu-1604 /go/src/go.opencensus.io]$

@odeke-em

odeke-em commented 6 years ago

Thanks for the confirmation @moooofly, please let me know if this patch on go.opencensus.io/zpages fixes it for you

diff --git a/zpages/rpcz.go b/zpages/rpcz.go
index 30193d1..158ea15 100644
--- a/zpages/rpcz.go
+++ b/zpages/rpcz.go
@@ -170,9 +170,9 @@ type statSnapshot struct {
    // TODO: compute hour/minute values from cumulative
    Method           string
    Received         bool
-   CountMinute      int
-   CountHour        int
-   CountTotal       int
+   CountMinute      int64
+   CountHour        int64
+   CountTotal       int64
    AvgLatencyMinute time.Duration
    AvgLatencyHour   time.Duration
    AvgLatencyTotal  time.Duration
@@ -185,9 +185,9 @@ type statSnapshot struct {
    OutputRateMinute float64
    OutputRateHour   float64
    OutputRateTotal  float64
-   ErrorsMinute     int
-   ErrorsHour       int
-   ErrorsTotal      int
+   ErrorsMinute     int64
+   ErrorsHour       int64
+   ErrorsTotal      int64
 }

 type methodKey struct {
@@ -267,7 +267,7 @@ func (s snapExporter) ExportView(vd *view.Data) {
            }
            for _, tag := range row.Tags {
                if tag.Key == ocgrpc.KeyClientStatus && tag.Value != "OK" {
-                   s.ErrorsTotal += int(count)
+                   s.ErrorsTotal += int64(count)
                }
            }

@@ -281,7 +281,7 @@ func (s snapExporter) ExportView(vd *view.Data) {
            s.InputRateTotal = computeRate(0, sum)

        case ocgrpc.ClientSentMessagesPerRPCView:
-           s.CountTotal = int(count)
+           s.CountTotal = int64(count)
            s.RPCRateTotal = computeRate(0, count)

        case ocgrpc.ClientReceivedMessagesPerRPCView:
@@ -294,7 +294,7 @@ func (s snapExporter) ExportView(vd *view.Data) {
            }
            for _, tag := range row.Tags {
                if tag.Key == ocgrpc.KeyServerStatus && tag.Value != "OK" {
-                   s.ErrorsTotal += int(count)
+                   s.ErrorsTotal += int64(count)
                }
            }

@@ -305,7 +305,7 @@ func (s snapExporter) ExportView(vd *view.Data) {
            s.OutputRateTotal = computeRate(0, sum)

        case ocgrpc.ServerReceivedMessagesPerRPCView:
-           s.CountTotal = int(count)
+           s.CountTotal = int64(count)
            s.RPCRateTotal = computeRate(0, count)

        case ocgrpc.ServerSentMessagesPerRPCView:

If it does, please file a bug on OpenCensus-Go letting them know that the last PR needs to have been completed with changing those values from int to int64

odeke-em commented 6 years ago

Thank you @moooofly for the patience! I've filed a bug at OpenCensus-Go in https://github.com/census-instrumentation/opencensus-go/issues/951 and then submitted PR https://github.com/census-instrumentation/opencensus-go/pull/952 to fix the problem. When that PR is merged I'll ping you and then you can update your version of go.opencensus.io/zpages and all should then be good.

moooofly commented 6 years ago

Thank you @odeke-em , the patch above do work well, sorry for update late.

odeke-em commented 6 years ago

Alright, this change is updated in https://github.com/census-instrumentation/opencensus-go/pull/952, please get the latest OpenCensus-Go and it should be fixed. Thanks for reporting this.