Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate stat.pb.go file #15101

Closed
bonavadeur opened this issue Apr 6, 2024 · 2 comments
Closed

How to generate stat.pb.go file #15101

bonavadeur opened this issue Apr 6, 2024 · 2 comments
Labels
kind/question Further information is requested

Comments

@bonavadeur
Copy link

Hi all, I am faling in love with Knative Serving by modifying your code, every day, for my personal purpose. I am confusing in generating pkg/autoscaler/metrics/stat.pb.go file. Now I want to add some other field to Stat proto struct, so regenerating stat.pb.go is neccessary. Arcording to comment in this file, it was generated by protoc-gen-gogo. I tried to use protoc-gen-gogo to regenerate .pb.go file, but the file I received look like not same as original .pb.go file, it miss some methods like Marshal(), Unmarshal(), Size().

The command I used to regenerate .pb.go file:

protoc -I=./ --gogo_out=./ ./stat.proto

and here is the result:

// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: pkg/autoscaler/metrics/stat.proto

package metrics

import (
	fmt "fmt"
	proto "github.com/gogo/protobuf/proto"
	math "math"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package

// Stat defines a single measurement at a point in time.
type Stat struct {
	// The unique identity of this pod.  Used to count how many pods
	// are contributing to the metrics.
	PodName string `protobuf:"bytes,1,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"`
	// Average number of requests currently being handled by this pod.
	AverageConcurrentRequests float64 `protobuf:"fixed64,2,opt,name=average_concurrent_requests,json=averageConcurrentRequests,proto3" json:"average_concurrent_requests,omitempty"`
	// Part of AverageConcurrentRequests, for requests going through a proxy.
	AverageProxiedConcurrentRequests float64 `protobuf:"fixed64,3,opt,name=average_proxied_concurrent_requests,json=averageProxiedConcurrentRequests,proto3" json:"average_proxied_concurrent_requests,omitempty"`
	// Number of requests received since last Stat (approximately requests per second).
	RequestCount float64 `protobuf:"fixed64,4,opt,name=request_count,json=requestCount,proto3" json:"request_count,omitempty"`
	// Part of RequestCount, for requests going through a proxy.
	ProxiedRequestCount float64 `protobuf:"fixed64,5,opt,name=proxied_request_count,json=proxiedRequestCount,proto3" json:"proxied_request_count,omitempty"`
	// Process uptime in seconds.
	ProcessUptime float64 `protobuf:"fixed64,6,opt,name=process_uptime,json=processUptime,proto3" json:"process_uptime,omitempty"`
	// Time/date that the stat was generated in seconds since
	// 1970-01-01 00:00:00.000 UTC.
	Timestamp            int64    `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *Stat) Reset()         { *m = Stat{} }
func (m *Stat) String() string { return proto.CompactTextString(m) }
func (*Stat) ProtoMessage()    {}
func (*Stat) Descriptor() ([]byte, []int) {
	return fileDescriptor_01fabdc1b78bd68b, []int{0}
}
func (m *Stat) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Stat.Unmarshal(m, b)
}
func (m *Stat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Stat.Marshal(b, m, deterministic)
}
func (m *Stat) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Stat.Merge(m, src)
}
func (m *Stat) XXX_Size() int {
	return xxx_messageInfo_Stat.Size(m)
}
func (m *Stat) XXX_DiscardUnknown() {
	xxx_messageInfo_Stat.DiscardUnknown(m)
}

var xxx_messageInfo_Stat proto.InternalMessageInfo

func (m *Stat) GetPodName() string {
	if m != nil {
		return m.PodName
	}
	return ""
}

func (m *Stat) GetAverageConcurrentRequests() float64 {
	if m != nil {
		return m.AverageConcurrentRequests
	}
	return 0
}

func (m *Stat) GetAverageProxiedConcurrentRequests() float64 {
	if m != nil {
		return m.AverageProxiedConcurrentRequests
	}
	return 0
}

func (m *Stat) GetRequestCount() float64 {
	if m != nil {
		return m.RequestCount
	}
	return 0
}

func (m *Stat) GetProxiedRequestCount() float64 {
	if m != nil {
		return m.ProxiedRequestCount
	}
	return 0
}

func (m *Stat) GetProcessUptime() float64 {
	if m != nil {
		return m.ProcessUptime
	}
	return 0
}

func (m *Stat) GetTimestamp() int64 {
	if m != nil {
		return m.Timestamp
	}
	return 0
}

// WireStatMessage is a copy of the StatMessage Golang type, exploding the fields of
// `types.NamespacedName` to make it compatible with protobufs.
type WireStatMessage struct {
	// Namespace is the namespace of the entity the stat belongs to.
	Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// Name is the name of the entity the stat belongs to.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Stat are the actual metrics being sent.
	Stat                 *Stat    `protobuf:"bytes,3,opt,name=stat,proto3" json:"stat,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *WireStatMessage) Reset()         { *m = WireStatMessage{} }
func (m *WireStatMessage) String() string { return proto.CompactTextString(m) }
func (*WireStatMessage) ProtoMessage()    {}
func (*WireStatMessage) Descriptor() ([]byte, []int) {
	return fileDescriptor_01fabdc1b78bd68b, []int{1}
}
func (m *WireStatMessage) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_WireStatMessage.Unmarshal(m, b)
}
func (m *WireStatMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_WireStatMessage.Marshal(b, m, deterministic)
}
func (m *WireStatMessage) XXX_Merge(src proto.Message) {
	xxx_messageInfo_WireStatMessage.Merge(m, src)
}
func (m *WireStatMessage) XXX_Size() int {
	return xxx_messageInfo_WireStatMessage.Size(m)
}
func (m *WireStatMessage) XXX_DiscardUnknown() {
	xxx_messageInfo_WireStatMessage.DiscardUnknown(m)
}

var xxx_messageInfo_WireStatMessage proto.InternalMessageInfo

func (m *WireStatMessage) GetNamespace() string {
	if m != nil {
		return m.Namespace
	}
	return ""
}

func (m *WireStatMessage) GetName() string {
	if m != nil {
		return m.Name
	}
	return ""
}

func (m *WireStatMessage) GetStat() *Stat {
	if m != nil {
		return m.Stat
	}
	return nil
}

// WireStatMessages is a wrapper to send multiple WireStatMessages at once.
type WireStatMessages struct {
	// Messages is a list of WireStatMessages.
	Messages             []*WireStatMessage `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
	XXX_NoUnkeyedLiteral struct{}           `json:"-"`
	XXX_unrecognized     []byte             `json:"-"`
	XXX_sizecache        int32              `json:"-"`
}

func (m *WireStatMessages) Reset()         { *m = WireStatMessages{} }
func (m *WireStatMessages) String() string { return proto.CompactTextString(m) }
func (*WireStatMessages) ProtoMessage()    {}
func (*WireStatMessages) Descriptor() ([]byte, []int) {
	return fileDescriptor_01fabdc1b78bd68b, []int{2}
}
func (m *WireStatMessages) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_WireStatMessages.Unmarshal(m, b)
}
func (m *WireStatMessages) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_WireStatMessages.Marshal(b, m, deterministic)
}
func (m *WireStatMessages) XXX_Merge(src proto.Message) {
	xxx_messageInfo_WireStatMessages.Merge(m, src)
}
func (m *WireStatMessages) XXX_Size() int {
	return xxx_messageInfo_WireStatMessages.Size(m)
}
func (m *WireStatMessages) XXX_DiscardUnknown() {
	xxx_messageInfo_WireStatMessages.DiscardUnknown(m)
}

var xxx_messageInfo_WireStatMessages proto.InternalMessageInfo

func (m *WireStatMessages) GetMessages() []*WireStatMessage {
	if m != nil {
		return m.Messages
	}
	return nil
}

func init() {
	proto.RegisterType((*Stat)(nil), "metrics.Stat")
	proto.RegisterType((*WireStatMessage)(nil), "metrics.WireStatMessage")
	proto.RegisterType((*WireStatMessages)(nil), "metrics.WireStatMessages")
}

func init() { proto.RegisterFile("stat.proto", fileDescriptor_01fabdc1b78bd68b) }

var fileDescriptor_01fabdc1b78bd68b = []byte{
	// 313 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x3f, 0x4f, 0xc3, 0x30,
	0x10, 0xc5, 0x95, 0x36, 0xf4, 0xcf, 0x95, 0x02, 0x32, 0x42, 0x72, 0x05, 0x43, 0x68, 0x85, 0x94,
	0xa9, 0x43, 0x61, 0x66, 0xe9, 0xc2, 0x52, 0x84, 0x8c, 0x10, 0x63, 0x64, 0xd2, 0xa3, 0xca, 0xe0,
	0xd8, 0xd8, 0x0e, 0xe2, 0x53, 0xf2, 0x99, 0x90, 0x0f, 0x37, 0x85, 0xaa, 0x53, 0xac, 0x77, 0xbf,
	0xf7, 0x4e, 0x7a, 0x17, 0x00, 0xe7, 0xa5, 0x9f, 0x1b, 0xab, 0xbd, 0x66, 0x7d, 0x85, 0xde, 0x56,
	0xa5, 0x9b, 0x7e, 0x77, 0x20, 0x7d, 0xf6, 0xd2, 0xb3, 0x09, 0x0c, 0x8c, 0x5e, 0x17, 0xb5, 0x54,
	0xc8, 0x93, 0x2c, 0xc9, 0x87, 0xa2, 0x6f, 0xf4, 0xfa, 0x51, 0x2a, 0x64, 0xf7, 0x70, 0x29, 0x3f,
	0xd1, 0xca, 0x0d, 0x16, 0xa5, 0xae, 0xcb, 0xc6, 0x5a, 0xac, 0x7d, 0x61, 0xf1, 0xa3, 0x41, 0xe7,
	0x1d, 0xef, 0x64, 0x49, 0x9e, 0x88, 0x49, 0x44, 0x96, 0x2d, 0x21, 0x22, 0xc0, 0x56, 0x30, 0xdb,
	0xfa, 0x8d, 0xd5, 0x5f, 0x15, 0xae, 0x0f, 0xe6, 0x74, 0x29, 0x27, 0x8b, 0xe8, 0xd3, 0x2f, 0x79,
	0x20, 0x6e, 0x06, 0xe3, 0xe8, 0x29, 0x4a, 0xdd, 0xd4, 0x9e, 0xa7, 0x64, 0x3c, 0x8e, 0xe2, 0x32,
	0x68, 0x6c, 0x01, 0x17, 0xdb, 0x5d, 0xff, 0xe1, 0x23, 0x82, 0xcf, 0xe3, 0x50, 0xfc, 0xf5, 0xdc,
	0xc0, 0x89, 0xb1, 0xba, 0x44, 0xe7, 0x8a, 0xc6, 0xf8, 0x4a, 0x21, 0xef, 0x11, 0x3c, 0x8e, 0xea,
	0x0b, 0x89, 0xec, 0x0a, 0x86, 0xe1, 0xeb, 0xbc, 0x54, 0x86, 0xf7, 0xb3, 0x24, 0xef, 0x8a, 0x9d,
	0x30, 0x7d, 0x87, 0xd3, 0xd7, 0xca, 0x62, 0xe8, 0x74, 0x85, 0xce, 0xc9, 0x0d, 0x19, 0x42, 0xad,
	0xce, 0xc8, 0x72, 0xdb, 0xed, 0x4e, 0x60, 0x0c, 0x52, 0x2a, 0xbd, 0x43, 0x03, 0x7a, 0xb3, 0x6b,
	0x48, 0xc3, 0xb1, 0xa8, 0x92, 0xd1, 0x62, 0x3c, 0x8f, 0xd7, 0x9a, 0x87, 0x54, 0x41, 0xa3, 0xe9,
	0x03, 0x9c, 0xed, 0xed, 0x71, 0xec, 0x0e, 0x06, 0x2a, 0xbe, 0x79, 0x92, 0x75, 0xf3, 0xd1, 0x82,
	0xb7, 0xd6, 0x3d, 0x58, 0xb4, 0xe4, 0x5b, 0x8f, 0x7e, 0x89, 0xdb, 0x9f, 0x00, 0x00, 0x00, 0xff,
	0xff, 0x9c, 0x0e, 0x15, 0x1b, 0x20, 0x02, 0x00, 0x00,
}

Can you show me the correct way to generate it?
Thanks so much! ありがとうございます

@bonavadeur bonavadeur added the kind/question Further information is requested label Apr 6, 2024
@skonto
Copy link
Contributor

skonto commented May 16, 2024

Hi @bonavadeur! The way to generate it is via: ./hack/update-codegen.sh --generate-protobufs. Check the code in that script https://github.com/knative/serving/blob/main/hack/update-codegen.sh#L47.
Probably we need to revise that because protoc-gen-gogo has been deprecated long ago (see https://github.com/gogo/protobuf). cc @dprotaso @ReToCode
Right now to install the deprecated binaries you need to run:

go install github.com/gogo/protobuf/protoc-gen-gogo@v1.3.2
go install github.com/gogo/protobuf/protoc-gen-gogofaster@v1.3.2

See here too: https://github.com/knative/test-infra/blob/main/images/prow-tests/Dockerfile#L203.

@dprotaso
Copy link
Member

Closing this out as the question has been answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants