diff --git a/go.mod b/go.mod index acd1199831..eff89854f2 100644 --- a/go.mod +++ b/go.mod @@ -577,7 +577,7 @@ require ( github.com/hodgesds/perf-utils v0.7.0 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/iancoleman/strcase v0.3.0 // indirect - github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 // indirect + github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -861,6 +861,18 @@ require ( go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.7.0 // indirect ) +require ( + github.com/aperturerobotics/protobuf-go-lite v0.8.0 + github.com/extism/go-pdk v1.1.0 + github.com/extism/go-sdk v1.6.1 +) + +require ( + github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a // indirect + github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 // indirect + github.com/tetratelabs/wazero v1.8.1-0.20240916092830-1353ca24fef0 // indirect +) + // NOTE: replace directives below must always be *temporary*. // // Adding a replace directive to change a module to a fork of a module will diff --git a/go.sum b/go.sum index 850c4de59d..8c18cc401a 100644 --- a/go.sum +++ b/go.sum @@ -1028,6 +1028,8 @@ github.com/apache/thrift v0.21.0 h1:tdPmh/ptjE1IJnhbhrcl2++TauVjy242rkV/UzJChnE= github.com/apache/thrift v0.21.0/go.mod h1:W1H8aR/QRtYNvrPeFXBtobyRkd0/YVhTc6i07XIAgDw= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/aperturerobotics/protobuf-go-lite v0.8.0 h1:SoiTAVArmOrNTX31e6CC5Bem6HuOElg3YYNhp4AAPQc= +github.com/aperturerobotics/protobuf-go-lite v0.8.0/go.mod h1:y49wVEezRHg78uQ2OzLLZbtTTWuox+ChmaTuh6FLJW8= github.com/aristanetworks/glog v0.0.0-20191112221043-67e8567f59f3/go.mod h1:KASm+qXFKs/xjSoWn30NrWBBvdTTQq+UjkhjEJHfSFA= github.com/aristanetworks/goarista v0.0.0-20190325233358-a123909ec740/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -1379,6 +1381,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a h1:UwSIFv5g5lIvbGgtf3tVwC7Ky9rmMFBp0RMs+6f6YqE= +github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a/go.mod h1:C8DzXehI4zAbrdlbtOByKX6pfivJTBiV9Jjqv56Yd9Q= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA= @@ -1453,6 +1457,10 @@ github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0 github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/expr-lang/expr v1.16.9 h1:WUAzmR0JNI9JCiF0/ewwHB1gmcGw5wW7nWt8gc6PpCI= github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= +github.com/extism/go-pdk v1.1.0 h1:K2On6XOERxrYdsgu0uLzCxeu/FYRHE8jId/hdEVSYoY= +github.com/extism/go-pdk v1.1.0/go.mod h1:Gz+LIU/YCKnKXhgge8yo5Yu1F/lbv7KtKFkiCSzW/P4= +github.com/extism/go-sdk v1.6.1 h1:gkbkG5KzYKrv8mLggw5ojg/JulXfEbLIRVhbw9Ot7S0= +github.com/extism/go-sdk v1.6.1/go.mod h1:yRolc4PvIUQ9J/BBB3QZ5EY1MtXAN2jqBGDGR3Sk54M= github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb h1:IT4JYU7k4ikYg1SCxNI1/Tieq/NFvh6dzLdgi7eu0tM= github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb/go.mod h1:bH6Xx7IW64qjjJq8M2u4dxNaBiDfKK+z/3eGDpXEQhc= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= @@ -2108,8 +2116,8 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE= -github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= +github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca h1:T54Ema1DU8ngI+aef9ZhAhNGQhcRTrWxVeG07F+c/Rw= +github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:hk4LPqXIY/c9XzRbe7dA6qQxaT6Axcbny0L/G5a4owQ= github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP3LJkGTzKqRlpvCIFas3ncU02v8zzWDW+g0FY= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -3126,6 +3134,10 @@ github.com/tencentcloud/tencentcloud-sdk-go v1.0.162/go.mod h1:asUz5BPXxgoPGaRgZ github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= +github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 h1:ZF+QBjOI+tILZjBaFj3HgFonKXUcwgJ4djLb6i42S3Q= +github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk= +github.com/tetratelabs/wazero v1.8.1-0.20240916092830-1353ca24fef0 h1:NCRnJ+X6eZt3awiReoHCcDuC6Wf+CgWk6p4IDkIuxTo= +github.com/tetratelabs/wazero v1.8.1-0.20240916092830-1353ca24fef0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs= github.com/tg123/go-htpasswd v1.2.2 h1:tmNccDsQ+wYsoRfiONzIhDm5OkVHQzN3w4FOBAlN6BY= github.com/tg123/go-htpasswd v1.2.2/go.mod h1:FcIrK0J+6zptgVwK1JDlqyajW/1B4PtuJ/FLWl7nx8A= github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= diff --git a/internal/component/compute/process/examples/go/restrict/main.go b/internal/component/compute/process/examples/go/restrict/main.go new file mode 100644 index 0000000000..3b9284e5c9 --- /dev/null +++ b/internal/component/compute/process/examples/go/restrict/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "github.com/extism/go-pdk" + "slices" + "strings" +) + +//export process +func process() int32 { + in := pdk.Input() + pt, err := parsePassthrough(in) + if err != nil { + pdk.SetError(err) + return 1 + } + allowed := pt.Config["allowed_services"] + allowedServices := strings.Split(allowed, ",") + // If allowed is empty then allow all. + if len(allowedServices) == 0 { + pdk.Output(in) + return 0 + } + // Could practice to pass along things unchanged unless + // you explicitly don't want them to. + outPT := &Passthrough{ + Prommetrics: make([]*PrometheusMetric, 0), + Metrics: pt.Metrics, + Logs: pt.Logs, + Traces: pt.Traces, + } + for _, metric := range pt.Prommetrics { + // Check for the service label + var serviceValue string + for _, lbl := range metric.Labels { + if lbl.Name == "service" { + serviceValue = lbl.Value + break + } + } + + if serviceValue == "" { + continue + } + if slices.Contains(allowedServices, serviceValue) { + outPT.Prommetrics = append(outPT.Prommetrics, metric) + } + } + bb, err := outPT.MarshalVT() + if err != nil { + pdk.SetError(err) + return 1 + } + pdk.Output(bb) + return 0 +} + +func parsePassthrough(bb []byte) (*Passthrough, error) { + pt := &Passthrough{} + err := pt.UnmarshalVT(bb) + return pt, err +} + +// this has to exist to compile with tinygo +func main() {} diff --git a/internal/component/compute/process/examples/go/restrict/main.wasm b/internal/component/compute/process/examples/go/restrict/main.wasm new file mode 100755 index 0000000000..0c48d5c7bc Binary files /dev/null and b/internal/component/compute/process/examples/go/restrict/main.wasm differ diff --git a/internal/component/compute/process/examples/go/restrict/passthrough.pb.go b/internal/component/compute/process/examples/go/restrict/passthrough.pb.go new file mode 100644 index 0000000000..9c443ff9d9 --- /dev/null +++ b/internal/component/compute/process/examples/go/restrict/passthrough.pb.go @@ -0,0 +1,1197 @@ +// Code generated by protoc-gen-go-lite. DO NOT EDIT. +// protoc-gen-go-lite version: v0.8.0 +// source: passthrough.proto + +package main + +import ( + binary "encoding/binary" + fmt "fmt" + protobuf_go_lite "github.com/aperturerobotics/protobuf-go-lite" + io "io" + math "math" +) + +type Passthrough struct { + unknownFields []byte + Metrics [][]byte `protobuf:"bytes,1,rep,name=metrics,proto3" json:"metrics,omitempty"` + Traces [][]byte `protobuf:"bytes,2,rep,name=traces,proto3" json:"traces,omitempty"` + Logs [][]byte `protobuf:"bytes,3,rep,name=logs,proto3" json:"logs,omitempty"` + Config map[string]string `protobuf:"bytes,4,rep,name=config,proto3" json:"config,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Prommetrics []*PrometheusMetric `protobuf:"bytes,5,rep,name=prommetrics,proto3" json:"prommetrics,omitempty"` +} + +func (x *Passthrough) Reset() { + *x = Passthrough{} +} + +func (*Passthrough) ProtoMessage() {} + +func (x *Passthrough) GetMetrics() [][]byte { + if x != nil { + return x.Metrics + } + return nil +} + +func (x *Passthrough) GetTraces() [][]byte { + if x != nil { + return x.Traces + } + return nil +} + +func (x *Passthrough) GetLogs() [][]byte { + if x != nil { + return x.Logs + } + return nil +} + +func (x *Passthrough) GetConfig() map[string]string { + if x != nil { + return x.Config + } + return nil +} + +func (x *Passthrough) GetPrommetrics() []*PrometheusMetric { + if x != nil { + return x.Prommetrics + } + return nil +} + +type PrometheusMetric struct { + unknownFields []byte + Labels []*Label `protobuf:"bytes,1,rep,name=Labels,proto3" json:"Labels,omitempty"` + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + Timestampms int64 `protobuf:"varint,3,opt,name=timestampms,proto3" json:"timestampms,omitempty"` +} + +func (x *PrometheusMetric) Reset() { + *x = PrometheusMetric{} +} + +func (*PrometheusMetric) ProtoMessage() {} + +func (x *PrometheusMetric) GetLabels() []*Label { + if x != nil { + return x.Labels + } + return nil +} + +func (x *PrometheusMetric) GetValue() float64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *PrometheusMetric) GetTimestampms() int64 { + if x != nil { + return x.Timestampms + } + return 0 +} + +type Label struct { + unknownFields []byte + Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` +} + +func (x *Label) Reset() { + *x = Label{} +} + +func (*Label) ProtoMessage() {} + +func (x *Label) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Label) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type Passthrough_ConfigEntry struct { + unknownFields []byte + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *Passthrough_ConfigEntry) Reset() { + *x = Passthrough_ConfigEntry{} +} + +func (*Passthrough_ConfigEntry) ProtoMessage() {} + +func (x *Passthrough_ConfigEntry) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Passthrough_ConfigEntry) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (m *Passthrough) CloneVT() *Passthrough { + if m == nil { + return (*Passthrough)(nil) + } + r := new(Passthrough) + if rhs := m.Metrics; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Metrics = tmpContainer + } + if rhs := m.Traces; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Traces = tmpContainer + } + if rhs := m.Logs; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Logs = tmpContainer + } + if rhs := m.Config; rhs != nil { + tmpContainer := make(map[string]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Config = tmpContainer + } + if rhs := m.Prommetrics; rhs != nil { + tmpContainer := make([]*PrometheusMetric, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Prommetrics = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Passthrough) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (m *PrometheusMetric) CloneVT() *PrometheusMetric { + if m == nil { + return (*PrometheusMetric)(nil) + } + r := new(PrometheusMetric) + r.Value = m.Value + r.Timestampms = m.Timestampms + if rhs := m.Labels; rhs != nil { + tmpContainer := make([]*Label, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Labels = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *PrometheusMetric) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (m *Label) CloneVT() *Label { + if m == nil { + return (*Label)(nil) + } + r := new(Label) + r.Name = m.Name + r.Value = m.Value + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Label) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (this *Passthrough) EqualVT(that *Passthrough) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Metrics) != len(that.Metrics) { + return false + } + for i, vx := range this.Metrics { + vy := that.Metrics[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Traces) != len(that.Traces) { + return false + } + for i, vx := range this.Traces { + vy := that.Traces[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Logs) != len(that.Logs) { + return false + } + for i, vx := range this.Logs { + vy := that.Logs[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Config) != len(that.Config) { + return false + } + for i, vx := range this.Config { + vy, ok := that.Config[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + if len(this.Prommetrics) != len(that.Prommetrics) { + return false + } + for i, vx := range this.Prommetrics { + vy := that.Prommetrics[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &PrometheusMetric{} + } + if q == nil { + q = &PrometheusMetric{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Passthrough) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*Passthrough) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *PrometheusMetric) EqualVT(that *PrometheusMetric) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Labels) != len(that.Labels) { + return false + } + for i, vx := range this.Labels { + vy := that.Labels[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Label{} + } + if q == nil { + q = &Label{} + } + if !p.EqualVT(q) { + return false + } + } + } + if this.Value != that.Value { + return false + } + if this.Timestampms != that.Timestampms { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *PrometheusMetric) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*PrometheusMetric) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Label) EqualVT(that *Label) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.Value != that.Value { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Label) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*Label) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *Passthrough) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Passthrough) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Passthrough) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Prommetrics) > 0 { + for iNdEx := len(m.Prommetrics) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Prommetrics[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Config) > 0 { + for k := range m.Config { + v := m.Config[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Logs) > 0 { + for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Logs[iNdEx]) + copy(dAtA[i:], m.Logs[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Logs[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Traces) > 0 { + for iNdEx := len(m.Traces) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Traces[iNdEx]) + copy(dAtA[i:], m.Traces[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Traces[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Metrics) > 0 { + for iNdEx := len(m.Metrics) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Metrics[iNdEx]) + copy(dAtA[i:], m.Metrics[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Metrics[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PrometheusMetric) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrometheusMetric) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *PrometheusMetric) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Timestampms != 0 { + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(m.Timestampms)) + i-- + dAtA[i] = 0x18 + } + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x11 + } + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Labels[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Label) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Label) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Label) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Passthrough) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Metrics) > 0 { + for _, b := range m.Metrics { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Traces) > 0 { + for _, b := range m.Traces { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Logs) > 0 { + for _, b := range m.Logs { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Config) > 0 { + for k, v := range m.Config { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protobuf_go_lite.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protobuf_go_lite.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protobuf_go_lite.SizeOfVarint(uint64(mapEntrySize)) + } + } + if len(m.Prommetrics) > 0 { + for _, e := range m.Prommetrics { + l = e.SizeVT() + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *PrometheusMetric) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Labels) > 0 { + for _, e := range m.Labels { + l = e.SizeVT() + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if m.Value != 0 { + n += 9 + } + if m.Timestampms != 0 { + n += 1 + protobuf_go_lite.SizeOfVarint(uint64(m.Timestampms)) + } + n += len(m.unknownFields) + return n +} + +func (m *Label) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Passthrough) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Passthrough: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Passthrough: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metrics = append(m.Metrics, make([]byte, postIndex-iNdEx)) + copy(m.Metrics[len(m.Metrics)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Traces", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Traces = append(m.Traces, make([]byte, postIndex-iNdEx)) + copy(m.Traces[len(m.Traces)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logs = append(m.Logs, make([]byte, postIndex-iNdEx)) + copy(m.Logs[len(m.Logs)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Config[mapkey] = mapvalue + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prommetrics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prommetrics = append(m.Prommetrics, &PrometheusMetric{}) + if err := m.Prommetrics[len(m.Prommetrics)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrometheusMetric) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrometheusMetric: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrometheusMetric: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Labels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Labels = append(m.Labels, &Label{}) + if err := m.Labels[len(m.Labels)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestampms", wireType) + } + m.Timestampms = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestampms |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Label) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Label: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Label: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/internal/component/compute/process/passthrough.pb.go b/internal/component/compute/process/passthrough.pb.go new file mode 100644 index 0000000000..cab440db5c --- /dev/null +++ b/internal/component/compute/process/passthrough.pb.go @@ -0,0 +1,1197 @@ +// Code generated by protoc-gen-go-lite. DO NOT EDIT. +// protoc-gen-go-lite version: v0.8.0 +// source: passthrough.proto + +package process + +import ( + binary "encoding/binary" + fmt "fmt" + protobuf_go_lite "github.com/aperturerobotics/protobuf-go-lite" + io "io" + math "math" +) + +type Passthrough struct { + unknownFields []byte + Metrics [][]byte `protobuf:"bytes,1,rep,name=metrics,proto3" json:"metrics,omitempty"` + Traces [][]byte `protobuf:"bytes,2,rep,name=traces,proto3" json:"traces,omitempty"` + Logs [][]byte `protobuf:"bytes,3,rep,name=logs,proto3" json:"logs,omitempty"` + Config map[string]string `protobuf:"bytes,4,rep,name=config,proto3" json:"config,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Prommetrics []*PrometheusMetric `protobuf:"bytes,5,rep,name=prommetrics,proto3" json:"prommetrics,omitempty"` +} + +func (x *Passthrough) Reset() { + *x = Passthrough{} +} + +func (*Passthrough) ProtoMessage() {} + +func (x *Passthrough) GetMetrics() [][]byte { + if x != nil { + return x.Metrics + } + return nil +} + +func (x *Passthrough) GetTraces() [][]byte { + if x != nil { + return x.Traces + } + return nil +} + +func (x *Passthrough) GetLogs() [][]byte { + if x != nil { + return x.Logs + } + return nil +} + +func (x *Passthrough) GetConfig() map[string]string { + if x != nil { + return x.Config + } + return nil +} + +func (x *Passthrough) GetPrommetrics() []*PrometheusMetric { + if x != nil { + return x.Prommetrics + } + return nil +} + +type PrometheusMetric struct { + unknownFields []byte + Labels []*Label `protobuf:"bytes,1,rep,name=Labels,proto3" json:"Labels,omitempty"` + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + Timestampms int64 `protobuf:"varint,3,opt,name=timestampms,proto3" json:"timestampms,omitempty"` +} + +func (x *PrometheusMetric) Reset() { + *x = PrometheusMetric{} +} + +func (*PrometheusMetric) ProtoMessage() {} + +func (x *PrometheusMetric) GetLabels() []*Label { + if x != nil { + return x.Labels + } + return nil +} + +func (x *PrometheusMetric) GetValue() float64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *PrometheusMetric) GetTimestampms() int64 { + if x != nil { + return x.Timestampms + } + return 0 +} + +type Label struct { + unknownFields []byte + Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` +} + +func (x *Label) Reset() { + *x = Label{} +} + +func (*Label) ProtoMessage() {} + +func (x *Label) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Label) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type Passthrough_ConfigEntry struct { + unknownFields []byte + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *Passthrough_ConfigEntry) Reset() { + *x = Passthrough_ConfigEntry{} +} + +func (*Passthrough_ConfigEntry) ProtoMessage() {} + +func (x *Passthrough_ConfigEntry) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Passthrough_ConfigEntry) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (m *Passthrough) CloneVT() *Passthrough { + if m == nil { + return (*Passthrough)(nil) + } + r := new(Passthrough) + if rhs := m.Metrics; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Metrics = tmpContainer + } + if rhs := m.Traces; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Traces = tmpContainer + } + if rhs := m.Logs; rhs != nil { + tmpContainer := make([][]byte, len(rhs)) + for k, v := range rhs { + tmpBytes := make([]byte, len(v)) + copy(tmpBytes, v) + tmpContainer[k] = tmpBytes + } + r.Logs = tmpContainer + } + if rhs := m.Config; rhs != nil { + tmpContainer := make(map[string]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Config = tmpContainer + } + if rhs := m.Prommetrics; rhs != nil { + tmpContainer := make([]*PrometheusMetric, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Prommetrics = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Passthrough) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (m *PrometheusMetric) CloneVT() *PrometheusMetric { + if m == nil { + return (*PrometheusMetric)(nil) + } + r := new(PrometheusMetric) + r.Value = m.Value + r.Timestampms = m.Timestampms + if rhs := m.Labels; rhs != nil { + tmpContainer := make([]*Label, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Labels = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *PrometheusMetric) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (m *Label) CloneVT() *Label { + if m == nil { + return (*Label)(nil) + } + r := new(Label) + r.Name = m.Name + r.Value = m.Value + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Label) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() +} + +func (this *Passthrough) EqualVT(that *Passthrough) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Metrics) != len(that.Metrics) { + return false + } + for i, vx := range this.Metrics { + vy := that.Metrics[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Traces) != len(that.Traces) { + return false + } + for i, vx := range this.Traces { + vy := that.Traces[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Logs) != len(that.Logs) { + return false + } + for i, vx := range this.Logs { + vy := that.Logs[i] + if string(vx) != string(vy) { + return false + } + } + if len(this.Config) != len(that.Config) { + return false + } + for i, vx := range this.Config { + vy, ok := that.Config[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + if len(this.Prommetrics) != len(that.Prommetrics) { + return false + } + for i, vx := range this.Prommetrics { + vy := that.Prommetrics[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &PrometheusMetric{} + } + if q == nil { + q = &PrometheusMetric{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Passthrough) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*Passthrough) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *PrometheusMetric) EqualVT(that *PrometheusMetric) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Labels) != len(that.Labels) { + return false + } + for i, vx := range this.Labels { + vy := that.Labels[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Label{} + } + if q == nil { + q = &Label{} + } + if !p.EqualVT(q) { + return false + } + } + } + if this.Value != that.Value { + return false + } + if this.Timestampms != that.Timestampms { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *PrometheusMetric) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*PrometheusMetric) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Label) EqualVT(that *Label) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.Value != that.Value { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Label) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*Label) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *Passthrough) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Passthrough) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Passthrough) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Prommetrics) > 0 { + for iNdEx := len(m.Prommetrics) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Prommetrics[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Config) > 0 { + for k := range m.Config { + v := m.Config[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Logs) > 0 { + for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Logs[iNdEx]) + copy(dAtA[i:], m.Logs[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Logs[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Traces) > 0 { + for iNdEx := len(m.Traces) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Traces[iNdEx]) + copy(dAtA[i:], m.Traces[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Traces[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Metrics) > 0 { + for iNdEx := len(m.Metrics) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Metrics[iNdEx]) + copy(dAtA[i:], m.Metrics[iNdEx]) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Metrics[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PrometheusMetric) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrometheusMetric) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *PrometheusMetric) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Timestampms != 0 { + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(m.Timestampms)) + i-- + dAtA[i] = 0x18 + } + if m.Value != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x11 + } + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Labels[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Label) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Label) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Label) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Passthrough) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Metrics) > 0 { + for _, b := range m.Metrics { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Traces) > 0 { + for _, b := range m.Traces { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Logs) > 0 { + for _, b := range m.Logs { + l = len(b) + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if len(m.Config) > 0 { + for k, v := range m.Config { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protobuf_go_lite.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protobuf_go_lite.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protobuf_go_lite.SizeOfVarint(uint64(mapEntrySize)) + } + } + if len(m.Prommetrics) > 0 { + for _, e := range m.Prommetrics { + l = e.SizeVT() + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *PrometheusMetric) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Labels) > 0 { + for _, e := range m.Labels { + l = e.SizeVT() + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + } + if m.Value != 0 { + n += 9 + } + if m.Timestampms != 0 { + n += 1 + protobuf_go_lite.SizeOfVarint(uint64(m.Timestampms)) + } + n += len(m.unknownFields) + return n +} + +func (m *Label) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Passthrough) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Passthrough: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Passthrough: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metrics = append(m.Metrics, make([]byte, postIndex-iNdEx)) + copy(m.Metrics[len(m.Metrics)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Traces", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Traces = append(m.Traces, make([]byte, postIndex-iNdEx)) + copy(m.Traces[len(m.Traces)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logs = append(m.Logs, make([]byte, postIndex-iNdEx)) + copy(m.Logs[len(m.Logs)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Config[mapkey] = mapvalue + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prommetrics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prommetrics = append(m.Prommetrics, &PrometheusMetric{}) + if err := m.Prommetrics[len(m.Prommetrics)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrometheusMetric) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrometheusMetric: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrometheusMetric: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Labels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Labels = append(m.Labels, &Label{}) + if err := m.Labels[len(m.Labels)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestampms", wireType) + } + m.Timestampms = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestampms |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Label) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Label: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Label: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/internal/component/compute/process/process.go b/internal/component/compute/process/process.go new file mode 100644 index 0000000000..e82279c018 --- /dev/null +++ b/internal/component/compute/process/process.go @@ -0,0 +1,126 @@ +package process + +import ( + "context" + "maps" + "slices" + "sync" + + "github.com/grafana/alloy/internal/component" + "github.com/grafana/alloy/internal/component/common/loki" + "github.com/grafana/alloy/internal/component/prometheus" + "github.com/grafana/alloy/internal/featuregate" + "github.com/prometheus/prometheus/model/labels" + "github.com/prometheus/prometheus/storage" +) + +func init() { + component.Register(component.Registration{ + Name: "compute.process", + Stability: featuregate.StabilityExperimental, + Args: Arguments{}, + Exports: Exports{}, + + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { + return New(opts, args.(Arguments)) + }, + }) +} + +type Component struct { + mut sync.RWMutex + wasm *WasmPlugin + loki loki.LogsReceiver + args Arguments + opts component.Options +} + +func New(opts component.Options, args Arguments) (*Component, error) { + wp, err := NewPlugin(args.Wasm, args.Config, context.TODO()) + if err != nil { + return nil, err + } + + c := &Component{ + wasm: wp, + opts: opts, + args: args, + } + c.opts.OnStateChange(Exports{ + PrometheusReceiver: c, + LokiReceiver: c.loki, + }) + return c, nil +} + +func (c *Component) Run(ctx context.Context) error { + <-ctx.Done() + return nil +} + +func (c *Component) Update(args component.Arguments) error { + c.mut.Lock() + defer c.mut.Unlock() + + if slices.Equal(c.args.Wasm, args.(Arguments).Wasm) && maps.Equal(c.args.Config, args.(Arguments).Config) { + return nil + } + c.args = args.(Arguments) + + return nil +} + +func (c *Component) Appender(ctx context.Context) prometheus.BulkAppender { + return &bulkAppender{ + ctx: ctx, + wasm: c.wasm, + next: c.args.PrometheusForwardTo, + } +} + +type bulkAppender struct { + ctx context.Context + wasm *WasmPlugin + next storage.Appender +} + +func (b *bulkAppender) Append(metadata map[string]string, metrics []prometheus.PromMetric) error { + pt := &Passthrough{ + // TODO reduce the number of random objects that + // represent the same thing. + Prommetrics: make([]*PrometheusMetric, len(metrics)), + } + for i, m := range metrics { + labels := make([]*Label, len(m.Labels)) + for j, l := range m.Labels { + labels[j] = &Label{ + Name: l.Name, + Value: l.Value, + } + } + pt.Prommetrics[i] = &PrometheusMetric{ + Value: m.Value, + Timestampms: m.TS, + Labels: labels, + } + } + outpt, err := b.wasm.Process(pt) + if err != nil { + return err + } + for _, m := range outpt.Prommetrics { + labelsBack := make(labels.Labels, len(m.Labels)) + for i, l := range m.Labels { + labelsBack[i] = labels.Label{ + Name: l.Name, + Value: l.Value, + } + } + // We explicitly dont care about errors from append + _, _ = b.next.Append(0, labelsBack, m.Timestampms, m.Value) + } + // We explicitly dont care about errors from commit + _ = b.next.Commit() + return nil + +} diff --git a/internal/component/compute/process/process_test.go b/internal/component/compute/process/process_test.go new file mode 100644 index 0000000000..d10b4c5520 --- /dev/null +++ b/internal/component/compute/process/process_test.go @@ -0,0 +1,108 @@ +package process + +import ( + "context" + "github.com/prometheus/prometheus/model/exemplar" + "github.com/prometheus/prometheus/model/metadata" + "os" + "path/filepath" + "sync/atomic" + "testing" + "time" + + "github.com/grafana/alloy/internal/component" + "github.com/grafana/alloy/internal/component/prometheus" + "github.com/prometheus/prometheus/model/histogram" + "github.com/prometheus/prometheus/model/labels" + "github.com/prometheus/prometheus/storage" + "github.com/stretchr/testify/require" +) + +func TestProcess(t *testing.T) { + bb, err := os.ReadFile(filepath.Join(".", "examples", "go", "restrict", "main.wasm")) + require.NoError(t, err) + ta := &testAppendable{ts: t} + c, err := New(component.Options{ + OnStateChange: func(e component.Exports) { + + }, + }, Arguments{ + Wasm: bb, + Config: map[string]string{ + "allowed_services": "cool,not_here", + }, + PrometheusForwardTo: ta, + }) + require.NoError(t, err) + ctx := context.Background() + ctx, cancel := context.WithTimeout(ctx, 10*time.Second) + defer cancel() + go c.Run(ctx) + bulk := c.Appender(ctx) + metrics := make([]prometheus.PromMetric, 0) + for i := 0; i < 1000; i++ { + metrics = append(metrics, prometheus.PromMetric{ + Value: 1, + TS: 1, + Labels: labels.FromStrings("service", "cool"), + }) + } + for i := 0; i < 10; i++ { + metrics = append(metrics, prometheus.PromMetric{ + Value: 1, + TS: 1, + Labels: labels.FromStrings("service", "warm"), + }) + } + + err = bulk.Append(nil, metrics) + require.NoError(t, err) + // There should only be 1_000 since we dont want any warm services to make it through + require.Eventually(t, func() bool { + return ta.count.Load() == 1000 + }, 5*time.Second, 100*time.Millisecond) +} + +type testAppendable struct { + count atomic.Int32 + ts *testing.T +} + +func (ta *testAppendable) Commit() error { + return nil +} + +func (ta *testAppendable) Rollback() error { + //TODO implement me + panic("implement me") +} + +func (ta *testAppendable) Append(ref storage.SeriesRef, l labels.Labels, t int64, v float64) (storage.SeriesRef, error) { + require.True(ta.ts, l.Get("service") == "cool") + ta.count.Add(1) + return ref, nil +} + +func (ta *testAppendable) AppendExemplar(ref storage.SeriesRef, l labels.Labels, e exemplar.Exemplar) (storage.SeriesRef, error) { + //TODO implement me + panic("implement me") +} + +func (ta *testAppendable) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram, fh *histogram.FloatHistogram) (storage.SeriesRef, error) { + //TODO implement me + panic("implement me") +} + +func (ta *testAppendable) UpdateMetadata(ref storage.SeriesRef, l labels.Labels, m metadata.Metadata) (storage.SeriesRef, error) { + //TODO implement me + panic("implement me") +} + +func (ta *testAppendable) AppendCTZeroSample(ref storage.SeriesRef, l labels.Labels, t, ct int64) (storage.SeriesRef, error) { + //TODO implement me + panic("implement me") +} + +func (ta *testAppendable) Appender(_ context.Context) storage.Appender { + return ta +} diff --git a/internal/component/compute/process/types.go b/internal/component/compute/process/types.go new file mode 100644 index 0000000000..3408c47f0d --- /dev/null +++ b/internal/component/compute/process/types.go @@ -0,0 +1,19 @@ +package process + +import ( + "github.com/grafana/alloy/internal/component/common/loki" + "github.com/grafana/alloy/internal/component/prometheus" + "github.com/prometheus/prometheus/storage" +) + +type Arguments struct { + Wasm []byte `alloy:"wasm,attr"` + Config map[string]string `alloy:"config,attr,optional"` + LokiForwardTo []loki.LogsReceiver `alloy:"loki_forward_to,attr,optional"` + PrometheusForwardTo storage.Appender `alloy:"prometheus_forward_to,attr,optional"` +} + +type Exports struct { + PrometheusReceiver prometheus.BulkAppendable `alloy:"prometheus_receiver,attr"` + LokiReceiver loki.LogsReceiver `alloy:"loki_receiver,attr"` +} diff --git a/internal/component/compute/process/wasm.go b/internal/component/compute/process/wasm.go new file mode 100644 index 0000000000..6e41f20b8b --- /dev/null +++ b/internal/component/compute/process/wasm.go @@ -0,0 +1,70 @@ +package process + +import ( + "context" + "fmt" + "sync" + "time" + + extism "github.com/extism/go-sdk" +) + +type WasmPlugin struct { + mut sync.Mutex + plugin *extism.Plugin + config map[string]string +} + +func NewPlugin(wasm []byte, wasmConfig map[string]string, ctx context.Context) (*WasmPlugin, error) { + manifest := extism.Manifest{ + Wasm: []extism.Wasm{ + extism.WasmData{ + Data: wasm, + }, + }, + } + + config := extism.PluginConfig{ + EnableWasi: true, + } + plugin, err := extism.NewPlugin(ctx, manifest, config, []extism.HostFunction{}) + if err != nil { + return nil, err + } + return &WasmPlugin{ + plugin: plugin, + config: wasmConfig, + }, nil +} + +func (wp *WasmPlugin) UpdateConfig(config map[string]string) { + wp.mut.Lock() + defer wp.mut.Unlock() + + wp.config = config +} + +func (wp *WasmPlugin) Process(pt *Passthrough) (*Passthrough, error) { + // Only one process can be happening at a time. + wp.mut.Lock() + defer wp.mut.Unlock() + + pt.Config = wp.config + bb, err := pt.MarshalVT() + if err != nil { + return nil, err + } + ctx := context.Background() + ctx, cncl := context.WithTimeout(ctx, 2*time.Second) + defer cncl() + code, out, err := wp.plugin.CallWithContext(ctx, "process", bb) + if err != nil { + return nil, err + } + if code != 0 { + return nil, fmt.Errorf("plugin returned non-zero code: %d", code) + } + returnPT := &Passthrough{} + err = returnPT.UnmarshalVT(out) + return returnPT, err +} diff --git a/internal/component/prometheus/appendable.go b/internal/component/prometheus/appendable.go new file mode 100644 index 0000000000..8f945b6387 --- /dev/null +++ b/internal/component/prometheus/appendable.go @@ -0,0 +1,24 @@ +package prometheus + +import ( + "context" + + "github.com/prometheus/prometheus/model/labels" +) + +type BulkAppendable interface { + // Appender returns a new appender for the storage. The implementation + // can choose whether or not to use the context, for deadlines or to check + // for errors. + Appender(ctx context.Context) BulkAppender +} + +type PromMetric struct { + Value float64 + TS int64 + Labels labels.Labels +} + +type BulkAppender interface { + Append(metadata map[string]string, metrics []PromMetric) error +}