├── .travis.yml ├── Pinba ├── Makefile ├── pinba.proto └── pinba.pb.go ├── monotime_go19.go ├── monotime_goold.go ├── README.md ├── .gitignore ├── cmd └── testserver │ └── main.go ├── LICENSE ├── gopinba_test.go └── gopinba.go /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | -------------------------------------------------------------------------------- /Pinba/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | (protoc --proto_path=${GOPATH}/src:${GOPATH}/src/github.com/gogo/protobuf/protobuf:. --gogo_out=. pinba.proto) 3 | -------------------------------------------------------------------------------- /monotime_go19.go: -------------------------------------------------------------------------------- 1 | // +build go1.9 2 | 3 | package gopinba 4 | 5 | import "time" 6 | 7 | func now() time.Time { 8 | return time.Now() 9 | } 10 | -------------------------------------------------------------------------------- /monotime_goold.go: -------------------------------------------------------------------------------- 1 | // +build !go1.9 2 | 3 | package gopinba 4 | 5 | import ( 6 | "github.com/mkevac/monotime" 7 | "time" 8 | ) 9 | 10 | func now() time.Time { 11 | return monotime.Now() 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gopinba [![Build Status](https://travis-ci.org/mkevac/gopinba.svg?branch=master)](https://travis-ci.org/mkevac/gopinba) 2 | ======= 3 | 4 | Pinba (http://pinba.org) Go client. 5 | 6 | Documentation can be found [here](https://godoc.org/github.com/mkevac/gopinba). 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /cmd/testserver/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net" 6 | ) 7 | 8 | func main() { 9 | // We listen on a random port 10 | udpAddr, err := net.ResolveUDPAddr("udp", "0.0.0.0:6666") 11 | if err != nil { 12 | log.Fatalf("net.ResolveUDPAddr() failed: %v", err) 13 | } 14 | 15 | udpListener, err := net.ListenUDP("udp", udpAddr) 16 | if err != nil { 17 | log.Fatalf("net.ListenUDP() failed: %v", err) 18 | } 19 | 20 | var udpBuf = make([]byte, 4096) 21 | 22 | for { 23 | _, _, _ = udpListener.ReadFromUDP(udpBuf) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Marko Kevac 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Pinba/pinba.proto: -------------------------------------------------------------------------------- 1 | package Pinba; 2 | option optimize_for = LITE_RUNTIME; 3 | 4 | // to generate .pb.go, run something like this 5 | // $ cd pinba/proto 6 | // $ protoc --gogo_out=. -I$GOPATH/src:$GOPATH/src/github.com/gogo/protobuf/protobuf:. pinba.proto 7 | 8 | // gogoprotobuf page and build instructions: https://github.com/gogo/protobuf 9 | // options we use: 10 | // sizer_all, unsafe_marshaler_all, unsafe_unmarshaler_all - generate marshal/unmarshal code for each message (fast fast!) 11 | // (gogoproto.nullable) = false - generate non pointer fields (reduces GC pressure, most fields are of primitive type anyway) 12 | 13 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 14 | option (gogoproto.sizer_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = true; 16 | option (gogoproto.unsafe_unmarshaler_all) = true; 17 | 18 | message Request { 19 | required string hostname = 1 [(gogoproto.nullable) = false]; 20 | required string server_name = 2 [(gogoproto.nullable) = false]; 21 | required string script_name = 3 [(gogoproto.nullable) = false]; 22 | required uint32 request_count = 4 [(gogoproto.nullable) = false]; 23 | required uint32 document_size = 5 [(gogoproto.nullable) = false]; 24 | required uint32 memory_peak = 6 [(gogoproto.nullable) = false]; 25 | required float request_time = 7 [(gogoproto.nullable) = false]; 26 | required float ru_utime = 8 [(gogoproto.nullable) = false]; 27 | required float ru_stime = 9 [(gogoproto.nullable) = false]; 28 | 29 | repeated uint32 timer_hit_count = 10; 30 | repeated float timer_value = 11; 31 | repeated uint32 timer_tag_count = 12; 32 | repeated uint32 timer_tag_name = 13; 33 | repeated uint32 timer_tag_value = 14; 34 | repeated string dictionary = 15; 35 | optional uint32 status = 16 [(gogoproto.nullable) = false]; 36 | optional uint32 memory_footprint = 17 [(gogoproto.nullable) = false]; // allow nullable maybe? 37 | repeated Request requests = 18 [(gogoproto.nullable) = false]; // allow nullable maybe? 38 | optional string schema = 19 [(gogoproto.nullable) = false]; // allow nullable maybe? 39 | repeated uint32 tag_name = 20; 40 | repeated uint32 tag_value = 21; 41 | } 42 | -------------------------------------------------------------------------------- /gopinba_test.go: -------------------------------------------------------------------------------- 1 | package gopinba 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/mkevac/gopinba/Pinba" 8 | ) 9 | 10 | func inStringSlice(haystack []string, needle string) int { 11 | for i, s := range haystack { 12 | if s == needle { 13 | return i 14 | } 15 | } 16 | return -1 17 | } 18 | 19 | func inUint32Slice(haystack []uint32, needle uint32) int { 20 | for i, s := range haystack { 21 | if s == needle { 22 | return i 23 | } 24 | } 25 | return -1 26 | } 27 | 28 | func TestMergeTags(t *testing.T) { 29 | var ( 30 | pbreq Pinba.Request 31 | tags = map[string]string{ 32 | "marko": "kevac", 33 | "margo": "kevac", 34 | "lazo": "kevac", 35 | } 36 | ) 37 | 38 | mergeTags(&pbreq, tags) 39 | 40 | if len(pbreq.Dictionary) != 4 { 41 | t.Fatalf("dictionary length unexpected (expected 4, actual %v (%v))", len(pbreq.Dictionary), pbreq.Dictionary) 42 | } 43 | 44 | if len(pbreq.TagName) != 3 { 45 | t.Fatalf("TagName length unexpected (expected 3, actual %v (%v))", len(pbreq.TagName), pbreq.TagName) 46 | } 47 | 48 | if len(pbreq.TagValue) != 3 { 49 | t.Fatalf("TagValue length unexpected (expected 3, actual %v (%v))", len(pbreq.TagValue), pbreq.TagValue) 50 | } 51 | 52 | for k, v := range tags { 53 | ki := inStringSlice(pbreq.Dictionary, k) 54 | if ki == -1 { 55 | t.Fatalf("%v not found in %v", k, pbreq.Dictionary) 56 | } 57 | 58 | if -1 == inUint32Slice(pbreq.TagName, uint32(ki)) { 59 | t.Fatalf("%v not found in %v", ki, pbreq.TagName) 60 | } 61 | 62 | vi := inStringSlice(pbreq.Dictionary, v) 63 | if vi == -1 { 64 | t.Fatalf("%v not found in %v", v, pbreq.Dictionary) 65 | } 66 | 67 | if -1 == inUint32Slice(pbreq.TagValue, uint32(vi)) { 68 | t.Fatalf("%v not found in %v", vi, pbreq.TagValue) 69 | } 70 | } 71 | } 72 | 73 | func TestMergeTimerTags(t *testing.T) { 74 | var ( 75 | pbreq Pinba.Request 76 | tags1 = map[string]string{ 77 | "marko1": "kevac1", 78 | "margo1": "kevac1", 79 | "lazo1": "kevac1", 80 | } 81 | tags2 = map[string]string{ 82 | "marko2": "kevac2", 83 | "margo2": "kevac2", 84 | "lazo2": "kevac2", 85 | } 86 | ) 87 | 88 | mergeTimerTags(&pbreq, tags1) 89 | mergeTimerTags(&pbreq, tags2) 90 | 91 | if len(pbreq.Dictionary) != 8 { 92 | t.Fatalf("dictionary length unexpected (expected 8, actual %v)", len(pbreq.Dictionary)) 93 | } 94 | 95 | if len(pbreq.TimerTagName) != 6 { 96 | t.Fatalf("TimerTagName length unexpected (expected 6, actual %v)", len(pbreq.TimerTagName)) 97 | } 98 | 99 | if len(pbreq.TimerTagValue) != 6 { 100 | t.Fatalf("TimerTagValue length unexpected (expected 6, actual %v)", len(pbreq.TimerTagValue)) 101 | } 102 | 103 | if len(pbreq.TimerTagCount) != 2 { 104 | t.Fatalf("TimerTagCount length unexpected (expected 2, actual %v)", len(pbreq.TimerTagCount)) 105 | } 106 | 107 | for _, tags := range []map[string]string{tags1, tags2} { 108 | for k, v := range tags { 109 | ki := inStringSlice(pbreq.Dictionary, k) 110 | if ki == -1 { 111 | t.Fatalf("%v not found in %v", k, pbreq.Dictionary) 112 | } 113 | 114 | if -1 == inUint32Slice(pbreq.TimerTagName, uint32(ki)) { 115 | t.Fatalf("%v not found in %v", ki, pbreq.TimerTagName) 116 | } 117 | 118 | vi := inStringSlice(pbreq.Dictionary, v) 119 | if vi == -1 { 120 | t.Fatalf("%v not found in %v", v, pbreq.Dictionary) 121 | } 122 | 123 | if -1 == inUint32Slice(pbreq.TimerTagValue, uint32(vi)) { 124 | t.Fatalf("%v not found in %v", vi, pbreq.TimerTagValue) 125 | } 126 | } 127 | } 128 | 129 | } 130 | 131 | func TestRequest(t *testing.T) { 132 | pc, err := NewClient("10.0.0.1:30002") 133 | if err != nil { 134 | t.Errorf("NewClient() returned error: %v", err) 135 | } 136 | 137 | req := Request{} 138 | 139 | for i := 0; i < 5; i++ { 140 | 141 | req.Hostname = "hostname" 142 | req.ServerName = "servername" 143 | req.ScriptName = "scriptname" 144 | req.RequestCount = 1 145 | req.RequestTime = 145987 * time.Microsecond 146 | req.DocumentSize = 1024 147 | 148 | err = pc.SendRequest(&req) 149 | if err != nil { 150 | t.Errorf("SendRequest() returned error: %v", err) 151 | } 152 | } 153 | } 154 | 155 | func BenchmarkSimple(b *testing.B) { 156 | pc, err := NewClient(":6666") 157 | if err != nil { 158 | b.Fatalf("NewClient() returned error: %v", err) 159 | } 160 | 161 | for i := 0; i < b.N; i++ { 162 | req := Request{} 163 | 164 | req.Hostname = "hostname" 165 | req.ServerName = "servername" 166 | req.ScriptName = "scriptname" 167 | req.RequestCount = 1 168 | req.RequestTime = 145987 * time.Microsecond 169 | req.DocumentSize = 1024 170 | 171 | err = pc.SendRequest(&req) 172 | if err != nil { 173 | b.Errorf("SendRequest() returned error: %v", err) 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /gopinba.go: -------------------------------------------------------------------------------- 1 | package gopinba 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "sync" 7 | "time" 8 | 9 | "github.com/mkevac/gopinba/Pinba" 10 | ) 11 | 12 | type Client struct { 13 | initialized bool 14 | address string 15 | conn net.Conn 16 | } 17 | 18 | type Timer struct { 19 | Tags map[string]string 20 | 21 | // private stuff for simpler api 22 | stopped bool 23 | started time.Time 24 | duration time.Duration 25 | } 26 | 27 | type Request struct { 28 | Hostname string 29 | ServerName string 30 | ScriptName string 31 | Schema string 32 | RequestCount uint32 33 | RequestTime time.Duration 34 | DocumentSize uint32 35 | MemoryPeak uint32 36 | Utime float32 37 | Stime float32 38 | timers []Timer 39 | Status uint32 40 | Tags map[string]string 41 | lk sync.Mutex 42 | } 43 | 44 | func NewClient(address string) (*Client, error) { 45 | pc := &Client{address: address} 46 | conn, err := net.Dial("udp", address) 47 | if err != nil { 48 | return nil, err 49 | } 50 | 51 | pc.conn = conn 52 | pc.initialized = true 53 | 54 | return pc, nil 55 | } 56 | 57 | func iN(haystack []string, needle string) (int, bool) { 58 | for i, s := range haystack { 59 | if s == needle { 60 | return i, true 61 | } 62 | } 63 | return -1, false 64 | } 65 | 66 | func mergeTags(req *Pinba.Request, tags map[string]string) { 67 | for k, v := range tags { 68 | { 69 | pos, exists := iN(req.Dictionary, k) 70 | if !exists { 71 | req.Dictionary = append(req.Dictionary, k) 72 | pos = len(req.Dictionary) - 1 73 | } 74 | 75 | req.TagName = append(req.TagName, uint32(pos)) 76 | } 77 | 78 | { 79 | pos, exists := iN(req.Dictionary, v) 80 | if !exists { 81 | req.Dictionary = append(req.Dictionary, v) 82 | pos = len(req.Dictionary) - 1 83 | } 84 | 85 | req.TagValue = append(req.TagValue, uint32(pos)) 86 | } 87 | } 88 | } 89 | 90 | func mergeTimerTags(req *Pinba.Request, tags map[string]string) { 91 | req.TimerTagCount = append(req.TimerTagCount, uint32(len(tags))) 92 | 93 | for k, v := range tags { 94 | { 95 | pos, exists := iN(req.Dictionary, k) 96 | if !exists { 97 | req.Dictionary = append(req.Dictionary, k) 98 | pos = len(req.Dictionary) - 1 99 | } 100 | 101 | req.TimerTagName = append(req.TimerTagName, uint32(pos)) 102 | } 103 | 104 | { 105 | pos, exists := iN(req.Dictionary, v) 106 | if !exists { 107 | req.Dictionary = append(req.Dictionary, v) 108 | pos = len(req.Dictionary) - 1 109 | } 110 | 111 | req.TimerTagValue = append(req.TimerTagValue, uint32(pos)) 112 | } 113 | } 114 | } 115 | 116 | func preallocateArrays(req *Pinba.Request, timers []Timer) { 117 | 118 | // calculate (max) final lengths for all arrays 119 | nTimers := 0 120 | nTags := 0 121 | for _, timer := range timers { 122 | nTimers++ 123 | nTags += len(timer.Tags) 124 | } 125 | 126 | // construct arrays capable of holding all possible values to reduce allocations 127 | req.TimerHitCount = make([]uint32, 0, nTimers) // number of hits for each timer 128 | req.TimerValue = make([]float32, 0, nTimers) // timer value for each timer 129 | req.Dictionary = make([]string, 0, nTags) // all strings used in timer tag names/values 130 | req.TimerTagCount = make([]uint32, 0, nTimers) // number of tags for each timer 131 | req.TimerTagName = make([]uint32, 0, nTags) // flat array of all tag names (as offsets into dictionary) laid out sequentially for all timers 132 | req.TimerTagValue = make([]uint32, 0, nTags) // flat array of all tag values (as offsets into dictionary) laid out sequentially for all timers 133 | } 134 | 135 | func (pc *Client) SendRequest(request *Request) error { 136 | 137 | if !pc.initialized { 138 | return fmt.Errorf("Client not initialized") 139 | } 140 | 141 | pbreq := Pinba.Request{ 142 | Hostname: request.Hostname, 143 | ServerName: request.ServerName, 144 | ScriptName: request.ScriptName, 145 | RequestCount: request.RequestCount, 146 | RequestTime: float32(request.RequestTime.Seconds()), 147 | DocumentSize: request.DocumentSize, 148 | MemoryPeak: request.MemoryPeak, 149 | RuUtime: request.Utime, 150 | RuStime: request.Stime, 151 | Status: request.Status, 152 | Schema: request.Schema, 153 | } 154 | 155 | preallocateArrays(&pbreq, request.timers) 156 | 157 | pbreq.TagValue = make([]uint32, 0, len(request.Tags)) 158 | pbreq.TagName = make([]uint32, 0, len(request.Tags)) 159 | 160 | mergeTags(&pbreq, request.Tags) 161 | 162 | for _, timer := range request.timers { 163 | pbreq.TimerHitCount = append(pbreq.TimerHitCount, 1) 164 | pbreq.TimerValue = append(pbreq.TimerValue, float32(timer.duration.Seconds())) 165 | mergeTimerTags(&pbreq, timer.Tags) 166 | } 167 | 168 | buf := make([]byte, pbreq.Size()) 169 | 170 | n, err := pbreq.MarshalTo(buf) 171 | if err != nil { 172 | return err 173 | } 174 | 175 | _, err = pc.conn.Write(buf[:n]) 176 | if err != nil { 177 | return err 178 | } 179 | 180 | return nil 181 | } 182 | 183 | func (req *Request) AddTimer(timer *Timer) { 184 | req.lk.Lock() 185 | defer req.lk.Unlock() 186 | 187 | req.timers = append(req.timers, *timer) 188 | } 189 | 190 | // this is exactly the same as AddTimer 191 | // exists only to have api naming similar to pinba php extension 192 | func (req *Request) TimerAdd(timer *Timer) { 193 | timer.Stop() 194 | req.AddTimer(timer) 195 | } 196 | 197 | func TimerStart(tags map[string]string) *Timer { 198 | return &Timer{ 199 | duration: 0, 200 | Tags: tags, 201 | stopped: false, 202 | started: now(), 203 | } 204 | } 205 | 206 | func NewTimer(tags map[string]string, duration time.Duration) *Timer { 207 | return &Timer{ 208 | duration: duration, 209 | Tags: tags, 210 | stopped: true, 211 | started: now().Add(-duration), 212 | } 213 | } 214 | 215 | func (t *Timer) Stop() { 216 | if !t.stopped { 217 | t.stopped = true 218 | t.duration = now().Sub(t.started) 219 | } 220 | } 221 | 222 | func (t *Timer) GetDuration() time.Duration { 223 | return t.duration 224 | } 225 | -------------------------------------------------------------------------------- /Pinba/pinba.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. 2 | // source: pinba.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package Pinba is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | pinba.proto 10 | 11 | It has these top-level messages: 12 | Request 13 | */ 14 | package Pinba 15 | 16 | import proto "github.com/gogo/protobuf/proto" 17 | import fmt "fmt" 18 | import math "math" 19 | import _ "github.com/gogo/protobuf/gogoproto" 20 | 21 | import unsafe "unsafe" 22 | 23 | import io "io" 24 | import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" 25 | 26 | // Reference imports to suppress errors if they are not otherwise used. 27 | var _ = proto.Marshal 28 | var _ = fmt.Errorf 29 | var _ = math.Inf 30 | 31 | type Request struct { 32 | Hostname string `protobuf:"bytes,1,req,name=hostname" json:"hostname"` 33 | ServerName string `protobuf:"bytes,2,req,name=server_name" json:"server_name"` 34 | ScriptName string `protobuf:"bytes,3,req,name=script_name" json:"script_name"` 35 | RequestCount uint32 `protobuf:"varint,4,req,name=request_count" json:"request_count"` 36 | DocumentSize uint32 `protobuf:"varint,5,req,name=document_size" json:"document_size"` 37 | MemoryPeak uint32 `protobuf:"varint,6,req,name=memory_peak" json:"memory_peak"` 38 | RequestTime float32 `protobuf:"fixed32,7,req,name=request_time" json:"request_time"` 39 | RuUtime float32 `protobuf:"fixed32,8,req,name=ru_utime" json:"ru_utime"` 40 | RuStime float32 `protobuf:"fixed32,9,req,name=ru_stime" json:"ru_stime"` 41 | TimerHitCount []uint32 `protobuf:"varint,10,rep,name=timer_hit_count" json:"timer_hit_count,omitempty"` 42 | TimerValue []float32 `protobuf:"fixed32,11,rep,name=timer_value" json:"timer_value,omitempty"` 43 | TimerTagCount []uint32 `protobuf:"varint,12,rep,name=timer_tag_count" json:"timer_tag_count,omitempty"` 44 | TimerTagName []uint32 `protobuf:"varint,13,rep,name=timer_tag_name" json:"timer_tag_name,omitempty"` 45 | TimerTagValue []uint32 `protobuf:"varint,14,rep,name=timer_tag_value" json:"timer_tag_value,omitempty"` 46 | Dictionary []string `protobuf:"bytes,15,rep,name=dictionary" json:"dictionary,omitempty"` 47 | Status uint32 `protobuf:"varint,16,opt,name=status" json:"status"` 48 | MemoryFootprint uint32 `protobuf:"varint,17,opt,name=memory_footprint" json:"memory_footprint"` 49 | Requests []Request `protobuf:"bytes,18,rep,name=requests" json:"requests"` 50 | Schema string `protobuf:"bytes,19,opt,name=schema" json:"schema"` 51 | TagName []uint32 `protobuf:"varint,20,rep,name=tag_name" json:"tag_name,omitempty"` 52 | TagValue []uint32 `protobuf:"varint,21,rep,name=tag_value" json:"tag_value,omitempty"` 53 | XXX_unrecognized []byte `json:"-"` 54 | } 55 | 56 | func (m *Request) Reset() { *m = Request{} } 57 | func (m *Request) String() string { return proto.CompactTextString(m) } 58 | func (*Request) ProtoMessage() {} 59 | 60 | func (m *Request) GetHostname() string { 61 | if m != nil { 62 | return m.Hostname 63 | } 64 | return "" 65 | } 66 | 67 | func (m *Request) GetServerName() string { 68 | if m != nil { 69 | return m.ServerName 70 | } 71 | return "" 72 | } 73 | 74 | func (m *Request) GetScriptName() string { 75 | if m != nil { 76 | return m.ScriptName 77 | } 78 | return "" 79 | } 80 | 81 | func (m *Request) GetRequestCount() uint32 { 82 | if m != nil { 83 | return m.RequestCount 84 | } 85 | return 0 86 | } 87 | 88 | func (m *Request) GetDocumentSize() uint32 { 89 | if m != nil { 90 | return m.DocumentSize 91 | } 92 | return 0 93 | } 94 | 95 | func (m *Request) GetMemoryPeak() uint32 { 96 | if m != nil { 97 | return m.MemoryPeak 98 | } 99 | return 0 100 | } 101 | 102 | func (m *Request) GetRequestTime() float32 { 103 | if m != nil { 104 | return m.RequestTime 105 | } 106 | return 0 107 | } 108 | 109 | func (m *Request) GetRuUtime() float32 { 110 | if m != nil { 111 | return m.RuUtime 112 | } 113 | return 0 114 | } 115 | 116 | func (m *Request) GetRuStime() float32 { 117 | if m != nil { 118 | return m.RuStime 119 | } 120 | return 0 121 | } 122 | 123 | func (m *Request) GetTimerHitCount() []uint32 { 124 | if m != nil { 125 | return m.TimerHitCount 126 | } 127 | return nil 128 | } 129 | 130 | func (m *Request) GetTimerValue() []float32 { 131 | if m != nil { 132 | return m.TimerValue 133 | } 134 | return nil 135 | } 136 | 137 | func (m *Request) GetTimerTagCount() []uint32 { 138 | if m != nil { 139 | return m.TimerTagCount 140 | } 141 | return nil 142 | } 143 | 144 | func (m *Request) GetTimerTagName() []uint32 { 145 | if m != nil { 146 | return m.TimerTagName 147 | } 148 | return nil 149 | } 150 | 151 | func (m *Request) GetTimerTagValue() []uint32 { 152 | if m != nil { 153 | return m.TimerTagValue 154 | } 155 | return nil 156 | } 157 | 158 | func (m *Request) GetDictionary() []string { 159 | if m != nil { 160 | return m.Dictionary 161 | } 162 | return nil 163 | } 164 | 165 | func (m *Request) GetStatus() uint32 { 166 | if m != nil { 167 | return m.Status 168 | } 169 | return 0 170 | } 171 | 172 | func (m *Request) GetMemoryFootprint() uint32 { 173 | if m != nil { 174 | return m.MemoryFootprint 175 | } 176 | return 0 177 | } 178 | 179 | func (m *Request) GetRequests() []Request { 180 | if m != nil { 181 | return m.Requests 182 | } 183 | return nil 184 | } 185 | 186 | func (m *Request) GetSchema() string { 187 | if m != nil { 188 | return m.Schema 189 | } 190 | return "" 191 | } 192 | 193 | func (m *Request) GetTagName() []uint32 { 194 | if m != nil { 195 | return m.TagName 196 | } 197 | return nil 198 | } 199 | 200 | func (m *Request) GetTagValue() []uint32 { 201 | if m != nil { 202 | return m.TagValue 203 | } 204 | return nil 205 | } 206 | 207 | func init() { 208 | proto.RegisterType((*Request)(nil), "Pinba.Request") 209 | } 210 | func (m *Request) Size() (n int) { 211 | var l int 212 | _ = l 213 | l = len(m.Hostname) 214 | n += 1 + l + sovPinba(uint64(l)) 215 | l = len(m.ServerName) 216 | n += 1 + l + sovPinba(uint64(l)) 217 | l = len(m.ScriptName) 218 | n += 1 + l + sovPinba(uint64(l)) 219 | n += 1 + sovPinba(uint64(m.RequestCount)) 220 | n += 1 + sovPinba(uint64(m.DocumentSize)) 221 | n += 1 + sovPinba(uint64(m.MemoryPeak)) 222 | n += 5 223 | n += 5 224 | n += 5 225 | if len(m.TimerHitCount) > 0 { 226 | for _, e := range m.TimerHitCount { 227 | n += 1 + sovPinba(uint64(e)) 228 | } 229 | } 230 | if len(m.TimerValue) > 0 { 231 | n += 5 * len(m.TimerValue) 232 | } 233 | if len(m.TimerTagCount) > 0 { 234 | for _, e := range m.TimerTagCount { 235 | n += 1 + sovPinba(uint64(e)) 236 | } 237 | } 238 | if len(m.TimerTagName) > 0 { 239 | for _, e := range m.TimerTagName { 240 | n += 1 + sovPinba(uint64(e)) 241 | } 242 | } 243 | if len(m.TimerTagValue) > 0 { 244 | for _, e := range m.TimerTagValue { 245 | n += 1 + sovPinba(uint64(e)) 246 | } 247 | } 248 | if len(m.Dictionary) > 0 { 249 | for _, s := range m.Dictionary { 250 | l = len(s) 251 | n += 1 + l + sovPinba(uint64(l)) 252 | } 253 | } 254 | n += 2 + sovPinba(uint64(m.Status)) 255 | n += 2 + sovPinba(uint64(m.MemoryFootprint)) 256 | if len(m.Requests) > 0 { 257 | for _, e := range m.Requests { 258 | l = e.Size() 259 | n += 2 + l + sovPinba(uint64(l)) 260 | } 261 | } 262 | l = len(m.Schema) 263 | n += 2 + l + sovPinba(uint64(l)) 264 | if len(m.TagName) > 0 { 265 | for _, e := range m.TagName { 266 | n += 2 + sovPinba(uint64(e)) 267 | } 268 | } 269 | if len(m.TagValue) > 0 { 270 | for _, e := range m.TagValue { 271 | n += 2 + sovPinba(uint64(e)) 272 | } 273 | } 274 | if m.XXX_unrecognized != nil { 275 | n += len(m.XXX_unrecognized) 276 | } 277 | return n 278 | } 279 | 280 | func sovPinba(x uint64) (n int) { 281 | for { 282 | n++ 283 | x >>= 7 284 | if x == 0 { 285 | break 286 | } 287 | } 288 | return n 289 | } 290 | func sozPinba(x uint64) (n int) { 291 | return sovPinba(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 292 | } 293 | func (m *Request) Marshal() (data []byte, err error) { 294 | size := m.Size() 295 | data = make([]byte, size) 296 | n, err := m.MarshalTo(data) 297 | if err != nil { 298 | return nil, err 299 | } 300 | return data[:n], nil 301 | } 302 | 303 | func (m *Request) MarshalTo(data []byte) (int, error) { 304 | var i int 305 | _ = i 306 | var l int 307 | _ = l 308 | data[i] = 0xa 309 | i++ 310 | i = encodeVarintPinba(data, i, uint64(len(m.Hostname))) 311 | i += copy(data[i:], m.Hostname) 312 | data[i] = 0x12 313 | i++ 314 | i = encodeVarintPinba(data, i, uint64(len(m.ServerName))) 315 | i += copy(data[i:], m.ServerName) 316 | data[i] = 0x1a 317 | i++ 318 | i = encodeVarintPinba(data, i, uint64(len(m.ScriptName))) 319 | i += copy(data[i:], m.ScriptName) 320 | data[i] = 0x20 321 | i++ 322 | i = encodeVarintPinba(data, i, uint64(m.RequestCount)) 323 | data[i] = 0x28 324 | i++ 325 | i = encodeVarintPinba(data, i, uint64(m.DocumentSize)) 326 | data[i] = 0x30 327 | i++ 328 | i = encodeVarintPinba(data, i, uint64(m.MemoryPeak)) 329 | data[i] = 0x3d 330 | i++ 331 | *(*float32)(unsafe.Pointer(&data[i])) = m.RequestTime 332 | i += 4 333 | data[i] = 0x45 334 | i++ 335 | *(*float32)(unsafe.Pointer(&data[i])) = m.RuUtime 336 | i += 4 337 | data[i] = 0x4d 338 | i++ 339 | *(*float32)(unsafe.Pointer(&data[i])) = m.RuStime 340 | i += 4 341 | if len(m.TimerHitCount) > 0 { 342 | for _, num := range m.TimerHitCount { 343 | data[i] = 0x50 344 | i++ 345 | i = encodeVarintPinba(data, i, uint64(num)) 346 | } 347 | } 348 | if len(m.TimerValue) > 0 { 349 | for _, num := range m.TimerValue { 350 | data[i] = 0x5d 351 | i++ 352 | *(*float32)(unsafe.Pointer(&data[i])) = num 353 | i += 4 354 | } 355 | } 356 | if len(m.TimerTagCount) > 0 { 357 | for _, num := range m.TimerTagCount { 358 | data[i] = 0x60 359 | i++ 360 | i = encodeVarintPinba(data, i, uint64(num)) 361 | } 362 | } 363 | if len(m.TimerTagName) > 0 { 364 | for _, num := range m.TimerTagName { 365 | data[i] = 0x68 366 | i++ 367 | i = encodeVarintPinba(data, i, uint64(num)) 368 | } 369 | } 370 | if len(m.TimerTagValue) > 0 { 371 | for _, num := range m.TimerTagValue { 372 | data[i] = 0x70 373 | i++ 374 | i = encodeVarintPinba(data, i, uint64(num)) 375 | } 376 | } 377 | if len(m.Dictionary) > 0 { 378 | for _, s := range m.Dictionary { 379 | data[i] = 0x7a 380 | i++ 381 | l = len(s) 382 | for l >= 1<<7 { 383 | data[i] = uint8(uint64(l)&0x7f | 0x80) 384 | l >>= 7 385 | i++ 386 | } 387 | data[i] = uint8(l) 388 | i++ 389 | i += copy(data[i:], s) 390 | } 391 | } 392 | data[i] = 0x80 393 | i++ 394 | data[i] = 0x1 395 | i++ 396 | i = encodeVarintPinba(data, i, uint64(m.Status)) 397 | data[i] = 0x88 398 | i++ 399 | data[i] = 0x1 400 | i++ 401 | i = encodeVarintPinba(data, i, uint64(m.MemoryFootprint)) 402 | if len(m.Requests) > 0 { 403 | for _, msg := range m.Requests { 404 | data[i] = 0x92 405 | i++ 406 | data[i] = 0x1 407 | i++ 408 | i = encodeVarintPinba(data, i, uint64(msg.Size())) 409 | n, err := msg.MarshalTo(data[i:]) 410 | if err != nil { 411 | return 0, err 412 | } 413 | i += n 414 | } 415 | } 416 | data[i] = 0x9a 417 | i++ 418 | data[i] = 0x1 419 | i++ 420 | i = encodeVarintPinba(data, i, uint64(len(m.Schema))) 421 | i += copy(data[i:], m.Schema) 422 | if len(m.TagName) > 0 { 423 | for _, num := range m.TagName { 424 | data[i] = 0xa0 425 | i++ 426 | data[i] = 0x1 427 | i++ 428 | i = encodeVarintPinba(data, i, uint64(num)) 429 | } 430 | } 431 | if len(m.TagValue) > 0 { 432 | for _, num := range m.TagValue { 433 | data[i] = 0xa8 434 | i++ 435 | data[i] = 0x1 436 | i++ 437 | i = encodeVarintPinba(data, i, uint64(num)) 438 | } 439 | } 440 | if m.XXX_unrecognized != nil { 441 | i += copy(data[i:], m.XXX_unrecognized) 442 | } 443 | return i, nil 444 | } 445 | 446 | func encodeFixed64Pinba(data []byte, offset int, v uint64) int { 447 | data[offset] = uint8(v) 448 | data[offset+1] = uint8(v >> 8) 449 | data[offset+2] = uint8(v >> 16) 450 | data[offset+3] = uint8(v >> 24) 451 | data[offset+4] = uint8(v >> 32) 452 | data[offset+5] = uint8(v >> 40) 453 | data[offset+6] = uint8(v >> 48) 454 | data[offset+7] = uint8(v >> 56) 455 | return offset + 8 456 | } 457 | func encodeFixed32Pinba(data []byte, offset int, v uint32) int { 458 | data[offset] = uint8(v) 459 | data[offset+1] = uint8(v >> 8) 460 | data[offset+2] = uint8(v >> 16) 461 | data[offset+3] = uint8(v >> 24) 462 | return offset + 4 463 | } 464 | func encodeVarintPinba(data []byte, offset int, v uint64) int { 465 | for v >= 1<<7 { 466 | data[offset] = uint8(v&0x7f | 0x80) 467 | v >>= 7 468 | offset++ 469 | } 470 | data[offset] = uint8(v) 471 | return offset + 1 472 | } 473 | func (m *Request) Unmarshal(data []byte) error { 474 | var hasFields [1]uint64 475 | l := len(data) 476 | iNdEx := 0 477 | for iNdEx < l { 478 | preIndex := iNdEx 479 | var wire uint64 480 | for shift := uint(0); ; shift += 7 { 481 | if shift >= 64 { 482 | return ErrIntOverflowPinbaUnsafe 483 | } 484 | if iNdEx >= l { 485 | return io.ErrUnexpectedEOF 486 | } 487 | b := data[iNdEx] 488 | iNdEx++ 489 | wire |= (uint64(b) & 0x7F) << shift 490 | if b < 0x80 { 491 | break 492 | } 493 | } 494 | fieldNum := int32(wire >> 3) 495 | wireType := int(wire & 0x7) 496 | if wireType == 4 { 497 | return fmt.Errorf("proto: Request: wiretype end group for non-group") 498 | } 499 | if fieldNum <= 0 { 500 | return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) 501 | } 502 | switch fieldNum { 503 | case 1: 504 | if wireType != 2 { 505 | return fmt.Errorf("proto: wrong wireType = %d for field Hostname", wireType) 506 | } 507 | var stringLen uint64 508 | for shift := uint(0); ; shift += 7 { 509 | if shift >= 64 { 510 | return ErrIntOverflowPinbaUnsafe 511 | } 512 | if iNdEx >= l { 513 | return io.ErrUnexpectedEOF 514 | } 515 | b := data[iNdEx] 516 | iNdEx++ 517 | stringLen |= (uint64(b) & 0x7F) << shift 518 | if b < 0x80 { 519 | break 520 | } 521 | } 522 | intStringLen := int(stringLen) 523 | if intStringLen < 0 { 524 | return ErrInvalidLengthPinbaUnsafe 525 | } 526 | postIndex := iNdEx + intStringLen 527 | if postIndex > l { 528 | return io.ErrUnexpectedEOF 529 | } 530 | m.Hostname = string(data[iNdEx:postIndex]) 531 | iNdEx = postIndex 532 | hasFields[0] |= uint64(0x00000001) 533 | case 2: 534 | if wireType != 2 { 535 | return fmt.Errorf("proto: wrong wireType = %d for field ServerName", wireType) 536 | } 537 | var stringLen uint64 538 | for shift := uint(0); ; shift += 7 { 539 | if shift >= 64 { 540 | return ErrIntOverflowPinbaUnsafe 541 | } 542 | if iNdEx >= l { 543 | return io.ErrUnexpectedEOF 544 | } 545 | b := data[iNdEx] 546 | iNdEx++ 547 | stringLen |= (uint64(b) & 0x7F) << shift 548 | if b < 0x80 { 549 | break 550 | } 551 | } 552 | intStringLen := int(stringLen) 553 | if intStringLen < 0 { 554 | return ErrInvalidLengthPinbaUnsafe 555 | } 556 | postIndex := iNdEx + intStringLen 557 | if postIndex > l { 558 | return io.ErrUnexpectedEOF 559 | } 560 | m.ServerName = string(data[iNdEx:postIndex]) 561 | iNdEx = postIndex 562 | hasFields[0] |= uint64(0x00000002) 563 | case 3: 564 | if wireType != 2 { 565 | return fmt.Errorf("proto: wrong wireType = %d for field ScriptName", wireType) 566 | } 567 | var stringLen uint64 568 | for shift := uint(0); ; shift += 7 { 569 | if shift >= 64 { 570 | return ErrIntOverflowPinbaUnsafe 571 | } 572 | if iNdEx >= l { 573 | return io.ErrUnexpectedEOF 574 | } 575 | b := data[iNdEx] 576 | iNdEx++ 577 | stringLen |= (uint64(b) & 0x7F) << shift 578 | if b < 0x80 { 579 | break 580 | } 581 | } 582 | intStringLen := int(stringLen) 583 | if intStringLen < 0 { 584 | return ErrInvalidLengthPinbaUnsafe 585 | } 586 | postIndex := iNdEx + intStringLen 587 | if postIndex > l { 588 | return io.ErrUnexpectedEOF 589 | } 590 | m.ScriptName = string(data[iNdEx:postIndex]) 591 | iNdEx = postIndex 592 | hasFields[0] |= uint64(0x00000004) 593 | case 4: 594 | if wireType != 0 { 595 | return fmt.Errorf("proto: wrong wireType = %d for field RequestCount", wireType) 596 | } 597 | m.RequestCount = 0 598 | for shift := uint(0); ; shift += 7 { 599 | if shift >= 64 { 600 | return ErrIntOverflowPinbaUnsafe 601 | } 602 | if iNdEx >= l { 603 | return io.ErrUnexpectedEOF 604 | } 605 | b := data[iNdEx] 606 | iNdEx++ 607 | m.RequestCount |= (uint32(b) & 0x7F) << shift 608 | if b < 0x80 { 609 | break 610 | } 611 | } 612 | hasFields[0] |= uint64(0x00000008) 613 | case 5: 614 | if wireType != 0 { 615 | return fmt.Errorf("proto: wrong wireType = %d for field DocumentSize", wireType) 616 | } 617 | m.DocumentSize = 0 618 | for shift := uint(0); ; shift += 7 { 619 | if shift >= 64 { 620 | return ErrIntOverflowPinbaUnsafe 621 | } 622 | if iNdEx >= l { 623 | return io.ErrUnexpectedEOF 624 | } 625 | b := data[iNdEx] 626 | iNdEx++ 627 | m.DocumentSize |= (uint32(b) & 0x7F) << shift 628 | if b < 0x80 { 629 | break 630 | } 631 | } 632 | hasFields[0] |= uint64(0x00000010) 633 | case 6: 634 | if wireType != 0 { 635 | return fmt.Errorf("proto: wrong wireType = %d for field MemoryPeak", wireType) 636 | } 637 | m.MemoryPeak = 0 638 | for shift := uint(0); ; shift += 7 { 639 | if shift >= 64 { 640 | return ErrIntOverflowPinbaUnsafe 641 | } 642 | if iNdEx >= l { 643 | return io.ErrUnexpectedEOF 644 | } 645 | b := data[iNdEx] 646 | iNdEx++ 647 | m.MemoryPeak |= (uint32(b) & 0x7F) << shift 648 | if b < 0x80 { 649 | break 650 | } 651 | } 652 | hasFields[0] |= uint64(0x00000020) 653 | case 7: 654 | if wireType != 5 { 655 | return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) 656 | } 657 | if iNdEx+4 > l { 658 | return io.ErrUnexpectedEOF 659 | } 660 | m.RequestTime = *(*float32)(unsafe.Pointer(&data[iNdEx])) 661 | iNdEx += 4 662 | hasFields[0] |= uint64(0x00000040) 663 | case 8: 664 | if wireType != 5 { 665 | return fmt.Errorf("proto: wrong wireType = %d for field RuUtime", wireType) 666 | } 667 | if iNdEx+4 > l { 668 | return io.ErrUnexpectedEOF 669 | } 670 | m.RuUtime = *(*float32)(unsafe.Pointer(&data[iNdEx])) 671 | iNdEx += 4 672 | hasFields[0] |= uint64(0x00000080) 673 | case 9: 674 | if wireType != 5 { 675 | return fmt.Errorf("proto: wrong wireType = %d for field RuStime", wireType) 676 | } 677 | if iNdEx+4 > l { 678 | return io.ErrUnexpectedEOF 679 | } 680 | m.RuStime = *(*float32)(unsafe.Pointer(&data[iNdEx])) 681 | iNdEx += 4 682 | hasFields[0] |= uint64(0x00000100) 683 | case 10: 684 | if wireType != 0 { 685 | return fmt.Errorf("proto: wrong wireType = %d for field TimerHitCount", wireType) 686 | } 687 | var v uint32 688 | for shift := uint(0); ; shift += 7 { 689 | if shift >= 64 { 690 | return ErrIntOverflowPinbaUnsafe 691 | } 692 | if iNdEx >= l { 693 | return io.ErrUnexpectedEOF 694 | } 695 | b := data[iNdEx] 696 | iNdEx++ 697 | v |= (uint32(b) & 0x7F) << shift 698 | if b < 0x80 { 699 | break 700 | } 701 | } 702 | m.TimerHitCount = append(m.TimerHitCount, v) 703 | case 11: 704 | if wireType != 5 { 705 | return fmt.Errorf("proto: wrong wireType = %d for field TimerValue", wireType) 706 | } 707 | var v float32 708 | if iNdEx+4 > l { 709 | return io.ErrUnexpectedEOF 710 | } 711 | v = *(*float32)(unsafe.Pointer(&data[iNdEx])) 712 | iNdEx += 4 713 | m.TimerValue = append(m.TimerValue, v) 714 | case 12: 715 | if wireType != 0 { 716 | return fmt.Errorf("proto: wrong wireType = %d for field TimerTagCount", wireType) 717 | } 718 | var v uint32 719 | for shift := uint(0); ; shift += 7 { 720 | if shift >= 64 { 721 | return ErrIntOverflowPinbaUnsafe 722 | } 723 | if iNdEx >= l { 724 | return io.ErrUnexpectedEOF 725 | } 726 | b := data[iNdEx] 727 | iNdEx++ 728 | v |= (uint32(b) & 0x7F) << shift 729 | if b < 0x80 { 730 | break 731 | } 732 | } 733 | m.TimerTagCount = append(m.TimerTagCount, v) 734 | case 13: 735 | if wireType != 0 { 736 | return fmt.Errorf("proto: wrong wireType = %d for field TimerTagName", wireType) 737 | } 738 | var v uint32 739 | for shift := uint(0); ; shift += 7 { 740 | if shift >= 64 { 741 | return ErrIntOverflowPinbaUnsafe 742 | } 743 | if iNdEx >= l { 744 | return io.ErrUnexpectedEOF 745 | } 746 | b := data[iNdEx] 747 | iNdEx++ 748 | v |= (uint32(b) & 0x7F) << shift 749 | if b < 0x80 { 750 | break 751 | } 752 | } 753 | m.TimerTagName = append(m.TimerTagName, v) 754 | case 14: 755 | if wireType != 0 { 756 | return fmt.Errorf("proto: wrong wireType = %d for field TimerTagValue", wireType) 757 | } 758 | var v uint32 759 | for shift := uint(0); ; shift += 7 { 760 | if shift >= 64 { 761 | return ErrIntOverflowPinbaUnsafe 762 | } 763 | if iNdEx >= l { 764 | return io.ErrUnexpectedEOF 765 | } 766 | b := data[iNdEx] 767 | iNdEx++ 768 | v |= (uint32(b) & 0x7F) << shift 769 | if b < 0x80 { 770 | break 771 | } 772 | } 773 | m.TimerTagValue = append(m.TimerTagValue, v) 774 | case 15: 775 | if wireType != 2 { 776 | return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) 777 | } 778 | var stringLen uint64 779 | for shift := uint(0); ; shift += 7 { 780 | if shift >= 64 { 781 | return ErrIntOverflowPinbaUnsafe 782 | } 783 | if iNdEx >= l { 784 | return io.ErrUnexpectedEOF 785 | } 786 | b := data[iNdEx] 787 | iNdEx++ 788 | stringLen |= (uint64(b) & 0x7F) << shift 789 | if b < 0x80 { 790 | break 791 | } 792 | } 793 | intStringLen := int(stringLen) 794 | if intStringLen < 0 { 795 | return ErrInvalidLengthPinbaUnsafe 796 | } 797 | postIndex := iNdEx + intStringLen 798 | if postIndex > l { 799 | return io.ErrUnexpectedEOF 800 | } 801 | m.Dictionary = append(m.Dictionary, string(data[iNdEx:postIndex])) 802 | iNdEx = postIndex 803 | case 16: 804 | if wireType != 0 { 805 | return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) 806 | } 807 | m.Status = 0 808 | for shift := uint(0); ; shift += 7 { 809 | if shift >= 64 { 810 | return ErrIntOverflowPinbaUnsafe 811 | } 812 | if iNdEx >= l { 813 | return io.ErrUnexpectedEOF 814 | } 815 | b := data[iNdEx] 816 | iNdEx++ 817 | m.Status |= (uint32(b) & 0x7F) << shift 818 | if b < 0x80 { 819 | break 820 | } 821 | } 822 | case 17: 823 | if wireType != 0 { 824 | return fmt.Errorf("proto: wrong wireType = %d for field MemoryFootprint", wireType) 825 | } 826 | m.MemoryFootprint = 0 827 | for shift := uint(0); ; shift += 7 { 828 | if shift >= 64 { 829 | return ErrIntOverflowPinbaUnsafe 830 | } 831 | if iNdEx >= l { 832 | return io.ErrUnexpectedEOF 833 | } 834 | b := data[iNdEx] 835 | iNdEx++ 836 | m.MemoryFootprint |= (uint32(b) & 0x7F) << shift 837 | if b < 0x80 { 838 | break 839 | } 840 | } 841 | case 18: 842 | if wireType != 2 { 843 | return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) 844 | } 845 | var msglen int 846 | for shift := uint(0); ; shift += 7 { 847 | if shift >= 64 { 848 | return ErrIntOverflowPinbaUnsafe 849 | } 850 | if iNdEx >= l { 851 | return io.ErrUnexpectedEOF 852 | } 853 | b := data[iNdEx] 854 | iNdEx++ 855 | msglen |= (int(b) & 0x7F) << shift 856 | if b < 0x80 { 857 | break 858 | } 859 | } 860 | if msglen < 0 { 861 | return ErrInvalidLengthPinbaUnsafe 862 | } 863 | postIndex := iNdEx + msglen 864 | if postIndex > l { 865 | return io.ErrUnexpectedEOF 866 | } 867 | m.Requests = append(m.Requests, Request{}) 868 | if err := m.Requests[len(m.Requests)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { 869 | return err 870 | } 871 | iNdEx = postIndex 872 | case 19: 873 | if wireType != 2 { 874 | return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) 875 | } 876 | var stringLen uint64 877 | for shift := uint(0); ; shift += 7 { 878 | if shift >= 64 { 879 | return ErrIntOverflowPinbaUnsafe 880 | } 881 | if iNdEx >= l { 882 | return io.ErrUnexpectedEOF 883 | } 884 | b := data[iNdEx] 885 | iNdEx++ 886 | stringLen |= (uint64(b) & 0x7F) << shift 887 | if b < 0x80 { 888 | break 889 | } 890 | } 891 | intStringLen := int(stringLen) 892 | if intStringLen < 0 { 893 | return ErrInvalidLengthPinbaUnsafe 894 | } 895 | postIndex := iNdEx + intStringLen 896 | if postIndex > l { 897 | return io.ErrUnexpectedEOF 898 | } 899 | m.Schema = string(data[iNdEx:postIndex]) 900 | iNdEx = postIndex 901 | case 20: 902 | if wireType != 0 { 903 | return fmt.Errorf("proto: wrong wireType = %d for field TagName", wireType) 904 | } 905 | var v uint32 906 | for shift := uint(0); ; shift += 7 { 907 | if shift >= 64 { 908 | return ErrIntOverflowPinbaUnsafe 909 | } 910 | if iNdEx >= l { 911 | return io.ErrUnexpectedEOF 912 | } 913 | b := data[iNdEx] 914 | iNdEx++ 915 | v |= (uint32(b) & 0x7F) << shift 916 | if b < 0x80 { 917 | break 918 | } 919 | } 920 | m.TagName = append(m.TagName, v) 921 | case 21: 922 | if wireType != 0 { 923 | return fmt.Errorf("proto: wrong wireType = %d for field TagValue", wireType) 924 | } 925 | var v uint32 926 | for shift := uint(0); ; shift += 7 { 927 | if shift >= 64 { 928 | return ErrIntOverflowPinbaUnsafe 929 | } 930 | if iNdEx >= l { 931 | return io.ErrUnexpectedEOF 932 | } 933 | b := data[iNdEx] 934 | iNdEx++ 935 | v |= (uint32(b) & 0x7F) << shift 936 | if b < 0x80 { 937 | break 938 | } 939 | } 940 | m.TagValue = append(m.TagValue, v) 941 | default: 942 | iNdEx = preIndex 943 | skippy, err := skipPinbaUnsafe(data[iNdEx:]) 944 | if err != nil { 945 | return err 946 | } 947 | if skippy < 0 { 948 | return ErrInvalidLengthPinbaUnsafe 949 | } 950 | if (iNdEx + skippy) > l { 951 | return io.ErrUnexpectedEOF 952 | } 953 | m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) 954 | iNdEx += skippy 955 | } 956 | } 957 | if hasFields[0]&uint64(0x00000001) == 0 { 958 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("hostname") 959 | } 960 | if hasFields[0]&uint64(0x00000002) == 0 { 961 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("server_name") 962 | } 963 | if hasFields[0]&uint64(0x00000004) == 0 { 964 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("script_name") 965 | } 966 | if hasFields[0]&uint64(0x00000008) == 0 { 967 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("request_count") 968 | } 969 | if hasFields[0]&uint64(0x00000010) == 0 { 970 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("document_size") 971 | } 972 | if hasFields[0]&uint64(0x00000020) == 0 { 973 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("memory_peak") 974 | } 975 | if hasFields[0]&uint64(0x00000040) == 0 { 976 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("request_time") 977 | } 978 | if hasFields[0]&uint64(0x00000080) == 0 { 979 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("ru_utime") 980 | } 981 | if hasFields[0]&uint64(0x00000100) == 0 { 982 | return github_com_gogo_protobuf_proto.NewRequiredNotSetError("ru_stime") 983 | } 984 | 985 | if iNdEx > l { 986 | return io.ErrUnexpectedEOF 987 | } 988 | return nil 989 | } 990 | func skipPinbaUnsafe(data []byte) (n int, err error) { 991 | l := len(data) 992 | iNdEx := 0 993 | for iNdEx < l { 994 | var wire uint64 995 | for shift := uint(0); ; shift += 7 { 996 | if shift >= 64 { 997 | return 0, ErrIntOverflowPinbaUnsafe 998 | } 999 | if iNdEx >= l { 1000 | return 0, io.ErrUnexpectedEOF 1001 | } 1002 | b := data[iNdEx] 1003 | iNdEx++ 1004 | wire |= (uint64(b) & 0x7F) << shift 1005 | if b < 0x80 { 1006 | break 1007 | } 1008 | } 1009 | wireType := int(wire & 0x7) 1010 | switch wireType { 1011 | case 0: 1012 | for shift := uint(0); ; shift += 7 { 1013 | if shift >= 64 { 1014 | return 0, ErrIntOverflowPinbaUnsafe 1015 | } 1016 | if iNdEx >= l { 1017 | return 0, io.ErrUnexpectedEOF 1018 | } 1019 | iNdEx++ 1020 | if data[iNdEx-1] < 0x80 { 1021 | break 1022 | } 1023 | } 1024 | return iNdEx, nil 1025 | case 1: 1026 | iNdEx += 8 1027 | return iNdEx, nil 1028 | case 2: 1029 | var length int 1030 | for shift := uint(0); ; shift += 7 { 1031 | if shift >= 64 { 1032 | return 0, ErrIntOverflowPinbaUnsafe 1033 | } 1034 | if iNdEx >= l { 1035 | return 0, io.ErrUnexpectedEOF 1036 | } 1037 | b := data[iNdEx] 1038 | iNdEx++ 1039 | length |= (int(b) & 0x7F) << shift 1040 | if b < 0x80 { 1041 | break 1042 | } 1043 | } 1044 | iNdEx += length 1045 | if length < 0 { 1046 | return 0, ErrInvalidLengthPinbaUnsafe 1047 | } 1048 | return iNdEx, nil 1049 | case 3: 1050 | for { 1051 | var innerWire uint64 1052 | var start int = iNdEx 1053 | for shift := uint(0); ; shift += 7 { 1054 | if shift >= 64 { 1055 | return 0, ErrIntOverflowPinbaUnsafe 1056 | } 1057 | if iNdEx >= l { 1058 | return 0, io.ErrUnexpectedEOF 1059 | } 1060 | b := data[iNdEx] 1061 | iNdEx++ 1062 | innerWire |= (uint64(b) & 0x7F) << shift 1063 | if b < 0x80 { 1064 | break 1065 | } 1066 | } 1067 | innerWireType := int(innerWire & 0x7) 1068 | if innerWireType == 4 { 1069 | break 1070 | } 1071 | next, err := skipPinbaUnsafe(data[start:]) 1072 | if err != nil { 1073 | return 0, err 1074 | } 1075 | iNdEx = start + next 1076 | } 1077 | return iNdEx, nil 1078 | case 4: 1079 | return iNdEx, nil 1080 | case 5: 1081 | iNdEx += 4 1082 | return iNdEx, nil 1083 | default: 1084 | return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 1085 | } 1086 | } 1087 | panic("unreachable") 1088 | } 1089 | 1090 | var ( 1091 | ErrInvalidLengthPinbaUnsafe = fmt.Errorf("proto: negative length found during unmarshaling") 1092 | ErrIntOverflowPinbaUnsafe = fmt.Errorf("proto: integer overflow") 1093 | ) 1094 | --------------------------------------------------------------------------------