From c72247a0d22a07ef01de3508b6e9cef9ca9ae688 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Sun, 13 Aug 2023 17:25:25 +0800 Subject: [PATCH] Change duration to from Duration to uint64 For our use case, we will always be able to encode durations as nanoseconds since the start time. This avoids a protobuf message, which adds to the number of bytes encoded and adds a level of pointer indirection, and more importantly, another heap allocation. --- codec/fullevent_test.go | 9 +-- .../modeldecoder/modeldecoderutil/metrics.go | 5 +- .../internal/modeldecoder/rumv3/decoder.go | 9 +-- .../internal/modeldecoder/v2/decoder.go | 11 +-- .../modeldecoder/v2/metricset_test.go | 9 +-- .../internal/modeldecoder/v2/span_test.go | 2 +- .../modeldecoder/v2/transaction_test.go | 5 +- input/otlp/traces.go | 3 +- input/otlp/traces_test.go | 4 +- model/modeljson/apmevent.pb.json_test.go | 9 +-- model/modeljson/event.pb.json.go | 2 +- model/modeljson/event.pb.json_test.go | 5 +- model/modeljson/internal/event.go | 2 +- model/modeljson/internal/marshal_fastjson.go | 2 +- model/modeljson/span.pb.json.go | 4 +- model/modeljson/span.pb.json_test.go | 5 +- model/modeljson/transaction.pb.json.go | 4 +- model/modeljson/transaction.pb.json_test.go | 3 +- model/modelpb/event.pb.go | 67 ++++++++--------- model/modelpb/event_vtproto.pb.go | 74 +++---------------- model/modelpb/metricset.pb.go | 71 +++++++++--------- model/modelpb/metricset_vtproto.pb.go | 74 +++---------------- model/proto/event.proto | 6 +- model/proto/metricset.proto | 6 +- 24 files changed, 128 insertions(+), 263 deletions(-) diff --git a/codec/fullevent_test.go b/codec/fullevent_test.go index fc5574ad..87439446 100644 --- a/codec/fullevent_test.go +++ b/codec/fullevent_test.go @@ -22,7 +22,6 @@ import ( "time" "github.com/elastic/apm-data/model/modelpb" - "google.golang.org/protobuf/types/known/durationpb" ) func fullEvent(t *testing.B) *modelpb.APMEvent { @@ -52,7 +51,7 @@ func fullEvent(t *testing.B) *modelpb.APMEvent { Resource: "destination_resource", ResponseTime: &modelpb.AggregatedDuration{ Count: 3, - Sum: durationpb.New(4 * time.Second), + Sum: uint64(4 * time.Second), }, }, Db: &modelpb.DB{ @@ -106,7 +105,7 @@ func fullEvent(t *testing.B) *modelpb.APMEvent { }, SelfTime: &modelpb.AggregatedDuration{ Count: 6, - Sum: durationpb.New(7 * time.Second), + Sum: uint64(7 * time.Second), }, RepresentativeCount: 8, }, @@ -177,7 +176,7 @@ func fullEvent(t *testing.B) *modelpb.APMEvent { Outcome: "outcome", Duration: &modelpb.AggregatedDuration{ Count: 4, - Sum: durationpb.New(5 * time.Second), + Sum: uint64(5 * time.Second), }, }, }, @@ -464,7 +463,7 @@ func fullEvent(t *testing.B) *modelpb.APMEvent { Count: 1, Sum: 2, }, - Duration: durationpb.New(3 * time.Second), + Duration: uint64(3 * time.Second), Severity: 4, }, } diff --git a/input/elasticapm/internal/modeldecoder/modeldecoderutil/metrics.go b/input/elasticapm/internal/modeldecoder/modeldecoderutil/metrics.go index a0f55111..bfb0e445 100644 --- a/input/elasticapm/internal/modeldecoder/modeldecoderutil/metrics.go +++ b/input/elasticapm/internal/modeldecoder/modeldecoderutil/metrics.go @@ -18,10 +18,7 @@ package modeldecoderutil import ( - "time" - "github.com/elastic/apm-data/model/modelpb" - "google.golang.org/protobuf/types/known/durationpb" ) // SetInternalMetrics extracts well-known internal metrics from event.Metricset.Samples, @@ -53,7 +50,7 @@ func SetInternalMetrics(event *modelpb.APMEvent) bool { if event.Span.SelfTime == nil { event.Span.SelfTime = &modelpb.AggregatedDuration{} } - event.Span.SelfTime.Sum = durationpb.New(time.Duration(v.Value * 1000)) + event.Span.SelfTime.Sum = uint64(v.Value * 1000) haveMetrics = true } } diff --git a/input/elasticapm/internal/modeldecoder/rumv3/decoder.go b/input/elasticapm/internal/modeldecoder/rumv3/decoder.go index 1c748ca3..947b4420 100644 --- a/input/elasticapm/internal/modeldecoder/rumv3/decoder.go +++ b/input/elasticapm/internal/modeldecoder/rumv3/decoder.go @@ -31,7 +31,6 @@ import ( "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder/modeldecoderutil" "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder/nullable" "github.com/elastic/apm-data/model/modelpb" - "google.golang.org/protobuf/types/known/durationpb" ) var ( @@ -410,7 +409,7 @@ func mapToTransactionMetricsetModel(from *transactionMetricset, event *modelpb.A } if value := from.Samples.SpanSelfTimeSum.Value; value.IsSet() { event.Span.SelfTime = populateNil(event.Span.SelfTime) - event.Span.SelfTime.Sum = durationpb.New(time.Duration(value.Val * 1000)) + event.Span.SelfTime.Sum = uint64(value.Val * 1000) ok = true } } @@ -589,8 +588,7 @@ func mapToSpanModel(from *span, event *modelpb.APMEvent) { } if from.Duration.IsSet() { event.Event = populateNil(event.Event) - duration := time.Duration(from.Duration.Val * float64(time.Millisecond)) - event.Event.Duration = durationpb.New(duration) + event.Event.Duration = uint64(from.Duration.Val * float64(time.Millisecond)) } if from.ID.IsSet() { out.Id = from.ID.Val @@ -725,8 +723,7 @@ func mapToTransactionModel(from *transaction, event *modelpb.APMEvent) { } if from.Duration.IsSet() { event.Event = populateNil(event.Event) - duration := time.Duration(from.Duration.Val * float64(time.Millisecond)) - event.Event.Duration = durationpb.New(duration) + event.Event.Duration = uint64(from.Duration.Val * float64(time.Millisecond)) } if from.ID.IsSet() { out.Id = from.ID.Val diff --git a/input/elasticapm/internal/modeldecoder/v2/decoder.go b/input/elasticapm/internal/modeldecoder/v2/decoder.go index 7e9796ba..bb4be90f 100644 --- a/input/elasticapm/internal/modeldecoder/v2/decoder.go +++ b/input/elasticapm/internal/modeldecoder/v2/decoder.go @@ -36,7 +36,6 @@ import ( "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder/nullable" "github.com/elastic/apm-data/input/otlp" "github.com/elastic/apm-data/model/modelpb" - "google.golang.org/protobuf/types/known/durationpb" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" @@ -325,7 +324,7 @@ func mapToDroppedSpansModel(from []transactionDroppedSpanStats, tx *modelpb.Tran to.Duration.Count = uint64(f.Duration.Count.Val) sum := f.Duration.Sum if sum.IsSet() { - to.Duration.Sum = durationpb.New(time.Duration(sum.Us.Val) * time.Microsecond) + to.Duration.Sum = uint64(time.Duration(sum.Us.Val) * time.Microsecond) } } if f.ServiceTargetType.IsSet() { @@ -1130,8 +1129,7 @@ func mapToSpanModel(from *span, event *modelpb.APMEvent) { } if from.Duration.IsSet() { event.Event = populateNil(event.Event) - duration := time.Duration(from.Duration.Val * float64(time.Millisecond)) - event.Event.Duration = durationpb.New(duration) + event.Event.Duration = uint64(from.Duration.Val * float64(time.Millisecond)) } if from.ID.IsSet() { out.Id = from.ID.Val @@ -1183,7 +1181,7 @@ func mapToSpanModel(from *span, event *modelpb.APMEvent) { // event.Timestamp should have been initialized to the time the // payload was received; offset that by "start" milliseconds for // RUM. - event.Timestamp += uint64(time.Duration(float64(time.Millisecond) * from.Start.Val).Nanoseconds()) + event.Timestamp += uint64(float64(time.Millisecond) * from.Start.Val) } if from.TraceID.IsSet() { event.Trace = &modelpb.Trace{ @@ -1331,9 +1329,8 @@ func mapToTransactionModel(from *transaction, event *modelpb.APMEvent) { } } if from.Duration.IsSet() { - duration := time.Duration(from.Duration.Val * float64(time.Millisecond)) event.Event = populateNil(event.Event) - event.Event.Duration = durationpb.New(duration) + event.Event.Duration = uint64(from.Duration.Val * float64(time.Millisecond)) } if from.ID.IsSet() { out.Id = from.ID.Val diff --git a/input/elasticapm/internal/modeldecoder/v2/metricset_test.go b/input/elasticapm/internal/modeldecoder/v2/metricset_test.go index bb257287..aefdd8b9 100644 --- a/input/elasticapm/internal/modeldecoder/v2/metricset_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/metricset_test.go @@ -27,7 +27,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/protobuf/testing/protocmp" - "google.golang.org/protobuf/types/known/durationpb" "github.com/elastic/apm-data/input/elasticapm/internal/decoder" "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder" @@ -268,7 +267,7 @@ func TestDecodeMetricsetInternal(t *testing.T) { Subtype: "span_subtype", SelfTime: &modelpb.AggregatedDuration{ Count: 123, - Sum: durationpb.New(456 * time.Microsecond), + Sum: uint64(456 * time.Microsecond), }, }, }}, batch, protocmp.Transform())) @@ -325,7 +324,7 @@ func TestDecodeMetricsetServiceName(t *testing.T) { Subtype: "span_subtype", SelfTime: &modelpb.AggregatedDuration{ Count: 123, - Sum: durationpb.New(456 * time.Microsecond), + Sum: uint64(456 * time.Microsecond), }, }, }}, batch, protocmp.Transform())) @@ -384,7 +383,7 @@ func TestDecodeMetricsetServiceNameAndVersion(t *testing.T) { Subtype: "span_subtype", SelfTime: &modelpb.AggregatedDuration{ Count: 123, - Sum: durationpb.New(456 * time.Microsecond), + Sum: uint64(456 * time.Microsecond), }, }, }}, batch, protocmp.Transform())) @@ -442,7 +441,7 @@ func TestDecodeMetricsetServiceVersion(t *testing.T) { Subtype: "span_subtype", SelfTime: &modelpb.AggregatedDuration{ Count: 123, - Sum: durationpb.New(456 * time.Microsecond), + Sum: uint64(456 * time.Microsecond), }, }, }}, batch, protocmp.Transform())) diff --git a/input/elasticapm/internal/modeldecoder/v2/span_test.go b/input/elasticapm/internal/modeldecoder/v2/span_test.go index 7ad54fbf..82ed6852 100644 --- a/input/elasticapm/internal/modeldecoder/v2/span_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/span_test.go @@ -59,7 +59,7 @@ func TestDecodeNestedSpan(t *testing.T) { require.Len(t, batch, 1) require.NotNil(t, batch[0].Span) assert.Equal(t, eventBase.Timestamp+uint64((143*time.Millisecond).Nanoseconds()), batch[0].Timestamp) - assert.Equal(t, 100*time.Millisecond, batch[0].Event.Duration.AsDuration()) + assert.Equal(t, uint64(100*time.Millisecond), batch[0].Event.Duration) assert.Equal(t, "parent-123", batch[0].ParentId, protocmp.Transform()) assert.Equal(t, &modelpb.Trace{Id: "trace-ab"}, batch[0].Trace, protocmp.Transform()) assert.Empty(t, cmp.Diff(&modelpb.Span{ diff --git a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go index 8747e2b2..03899501 100644 --- a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go @@ -31,7 +31,6 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/protobuf/testing/protocmp" - "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/structpb" "github.com/elastic/apm-data/input/elasticapm/internal/decoder" @@ -201,7 +200,7 @@ func TestDecodeMapToTransactionModel(t *testing.T) { Outcome: "success", Duration: &modelpb.AggregatedDuration{ Count: 2, - Sum: durationpb.New(time.Duration(durationSumUs) * time.Microsecond), + Sum: uint64(time.Duration(durationSumUs) * time.Microsecond), }, }, { @@ -209,7 +208,7 @@ func TestDecodeMapToTransactionModel(t *testing.T) { Outcome: "unknown", Duration: &modelpb.AggregatedDuration{ Count: 10, - Sum: durationpb.New(time.Duration(durationSumUs) * time.Microsecond), + Sum: uint64(time.Duration(durationSumUs) * time.Microsecond), }, }, }, diff --git a/input/otlp/traces.go b/input/otlp/traces.go index 23beef7e..f034ba9a 100644 --- a/input/otlp/traces.go +++ b/input/otlp/traces.go @@ -51,7 +51,6 @@ import ( "go.uber.org/zap" "google.golang.org/grpc/codes" "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/durationpb" "github.com/elastic/apm-data/model/modelpb" ) @@ -160,7 +159,7 @@ func (c *Consumer) convertSpan( } } event.Event = populateNil(event.Event) - event.Event.Duration = durationpb.New(duration) + event.Event.Duration = uint64(duration) event.Event.Outcome = spanStatusOutcome(otelSpan.Status()) if parentID != "" { event.ParentId = parentID diff --git a/input/otlp/traces_test.go b/input/otlp/traces_test.go index 6e0fdb9b..555e6c4b 100644 --- a/input/otlp/traces_test.go +++ b/input/otlp/traces_test.go @@ -820,8 +820,8 @@ func TestConsumeTracesExportTimestamp(t *testing.T) { assert.Equal(t, uint64((exceptionOffset - transactionOffset).Nanoseconds()), (*batch)[2].Timestamp-(*batch)[0].Timestamp) // Durations should be unaffected. - assert.Equal(t, transactionDuration, (*batch)[0].GetEvent().GetDuration().AsDuration()) - assert.Equal(t, spanDuration, (*batch)[1].GetEvent().GetDuration().AsDuration()) + assert.Equal(t, transactionDuration, time.Duration((*batch)[0].GetEvent().GetDuration())) + assert.Equal(t, spanDuration, time.Duration((*batch)[1].GetEvent().GetDuration())) for _, b := range *batch { // telemetry.sdk.elastic_export_timestamp should not be sent as a label. diff --git a/model/modeljson/apmevent.pb.json_test.go b/model/modeljson/apmevent.pb.json_test.go index 1b9cfe4f..de8eecb4 100644 --- a/model/modeljson/apmevent.pb.json_test.go +++ b/model/modeljson/apmevent.pb.json_test.go @@ -24,7 +24,6 @@ import ( "github.com/elastic/apm-data/model/modelpb" "github.com/stretchr/testify/require" "go.elastic.co/fastjson" - durationpb "google.golang.org/protobuf/types/known/durationpb" ) func TestFullEvent(t *testing.T) { @@ -73,7 +72,7 @@ func fullEvent(t testing.TB) *modelpb.APMEvent { Resource: "destination_resource", ResponseTime: &modelpb.AggregatedDuration{ Count: 3, - Sum: durationpb.New(4 * time.Second), + Sum: uint64(4 * time.Second), }, }, Db: &modelpb.DB{ @@ -127,7 +126,7 @@ func fullEvent(t testing.TB) *modelpb.APMEvent { }, SelfTime: &modelpb.AggregatedDuration{ Count: 6, - Sum: durationpb.New(7 * time.Second), + Sum: uint64(7 * time.Second), }, RepresentativeCount: 8, }, @@ -198,7 +197,7 @@ func fullEvent(t testing.TB) *modelpb.APMEvent { Outcome: "outcome", Duration: &modelpb.AggregatedDuration{ Count: 4, - Sum: durationpb.New(5 * time.Second), + Sum: uint64(5 * time.Second), }, }, }, @@ -485,7 +484,7 @@ func fullEvent(t testing.TB) *modelpb.APMEvent { Count: 1, Sum: 2, }, - Duration: durationpb.New(3 * time.Second), + Duration: uint64(3 * time.Second), Severity: 4, }, } diff --git a/model/modeljson/event.pb.json.go b/model/modeljson/event.pb.json.go index 236820b6..1d0a9ec6 100644 --- a/model/modeljson/event.pb.json.go +++ b/model/modeljson/event.pb.json.go @@ -30,7 +30,7 @@ func EventModelJSON(e *modelpb.Event, out *modeljson.Event) { Kind: e.Kind, Category: e.Category, Type: e.Type, - Duration: int64(e.Duration.AsDuration().Nanoseconds()), + Duration: e.Duration, Severity: e.Severity, } if e.SuccessCount != nil { diff --git a/model/modeljson/event.pb.json_test.go b/model/modeljson/event.pb.json_test.go index 6e9f21ce..d1e329c0 100644 --- a/model/modeljson/event.pb.json_test.go +++ b/model/modeljson/event.pb.json_test.go @@ -25,7 +25,6 @@ import ( "github.com/elastic/apm-data/model/modelpb" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -56,7 +55,7 @@ func TestEventToModelJSON(t *testing.T) { Count: 1, Sum: 2, }, - Duration: durationpb.New(3 * time.Second), + Duration: uint64(3 * time.Second), Severity: 4, Received: modelpb.FromTime(now), }, @@ -71,7 +70,7 @@ func TestEventToModelJSON(t *testing.T) { Count: 1, Sum: 2, }, - Duration: int64(3 * time.Second), + Duration: uint64(3 * time.Second), Severity: 4, Received: modeljson.Time(now), }, diff --git a/model/modeljson/internal/event.go b/model/modeljson/internal/event.go index 4bce6d12..da94fb29 100644 --- a/model/modeljson/internal/event.go +++ b/model/modeljson/internal/event.go @@ -26,6 +26,6 @@ type Event struct { Received Time `json:"received,omitempty"` Type string `json:"type,omitempty"` SuccessCount SummaryMetric `json:"success_count,omitempty"` - Duration int64 `json:"duration,omitempty"` + Duration uint64 `json:"duration,omitempty"` Severity uint64 `json:"severity,omitempty"` } diff --git a/model/modeljson/internal/marshal_fastjson.go b/model/modeljson/internal/marshal_fastjson.go index 11fe585c..3f486524 100644 --- a/model/modeljson/internal/marshal_fastjson.go +++ b/model/modeljson/internal/marshal_fastjson.go @@ -1055,7 +1055,7 @@ func (v *Event) MarshalFastJSON(w *fastjson.Writer) error { } else { w.RawString(prefix) } - w.Int64(v.Duration) + w.Uint64(v.Duration) } if v.Kind != "" { const prefix = ",\"kind\":" diff --git a/model/modeljson/span.pb.json.go b/model/modeljson/span.pb.json.go index f66871f2..29492a1c 100644 --- a/model/modeljson/span.pb.json.go +++ b/model/modeljson/span.pb.json.go @@ -63,7 +63,7 @@ func SpanModelJSON(e *modelpb.Span, out *modeljson.Span) { if e.SelfTime != nil { out.SelfTime = modeljson.AggregatedDuration{ Count: e.SelfTime.Count, - Sum: e.SelfTime.Sum.AsDuration(), + Sum: time.Duration(e.SelfTime.Sum), } } if e.Db != nil { @@ -89,7 +89,7 @@ func SpanModelJSON(e *modelpb.Span, out *modeljson.Span) { if e.DestinationService.ResponseTime != nil { out.Destination.Service.ResponseTime = modeljson.AggregatedDuration{ Count: e.DestinationService.ResponseTime.Count, - Sum: e.DestinationService.ResponseTime.Sum.AsDuration(), + Sum: time.Duration(e.DestinationService.ResponseTime.Sum), } } } diff --git a/model/modeljson/span.pb.json_test.go b/model/modeljson/span.pb.json_test.go index 96939783..9a738fe5 100644 --- a/model/modeljson/span.pb.json_test.go +++ b/model/modeljson/span.pb.json_test.go @@ -25,7 +25,6 @@ import ( "github.com/elastic/apm-data/model/modelpb" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/types/known/durationpb" ) func TestSpanToModelJSON(t *testing.T) { @@ -72,7 +71,7 @@ func TestSpanToModelJSON(t *testing.T) { Resource: "destination_resource", ResponseTime: &modelpb.AggregatedDuration{ Count: 3, - Sum: durationpb.New(4 * time.Second), + Sum: uint64(4 * time.Second), }, }, Db: &modelpb.DB{ @@ -98,7 +97,7 @@ func TestSpanToModelJSON(t *testing.T) { }, SelfTime: &modelpb.AggregatedDuration{ Count: 6, - Sum: durationpb.New(7 * time.Second), + Sum: uint64(7 * time.Second), }, RepresentativeCount: 8, }, diff --git a/model/modeljson/transaction.pb.json.go b/model/modeljson/transaction.pb.json.go index f280229a..23d4f232 100644 --- a/model/modeljson/transaction.pb.json.go +++ b/model/modeljson/transaction.pb.json.go @@ -18,6 +18,8 @@ package modeljson import ( + "time" + modeljson "github.com/elastic/apm-data/model/modeljson/internal" "github.com/elastic/apm-data/model/modelpb" ) @@ -74,7 +76,7 @@ func TransactionModelJSON(e *modelpb.Transaction, out *modeljson.Transaction, me if dss.Duration != nil { dssJson.Duration = modeljson.AggregatedDuration{ Count: dss.Duration.Count, - Sum: dss.Duration.Sum.AsDuration(), + Sum: time.Duration(dss.Duration.Sum), } } diff --git a/model/modeljson/transaction.pb.json_test.go b/model/modeljson/transaction.pb.json_test.go index a0b1007a..c0781c65 100644 --- a/model/modeljson/transaction.pb.json_test.go +++ b/model/modeljson/transaction.pb.json_test.go @@ -25,7 +25,6 @@ import ( "github.com/elastic/apm-data/model/modelpb" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/types/known/durationpb" ) func TestTransactionToModelJSON(t *testing.T) { @@ -99,7 +98,7 @@ func TestTransactionToModelJSON(t *testing.T) { Outcome: "outcome", Duration: &modelpb.AggregatedDuration{ Count: 4, - Sum: durationpb.New(5 * time.Second), + Sum: uint64(5 * time.Second), }, }, }, diff --git a/model/modelpb/event.pb.go b/model/modelpb/event.pb.go index 75b48cd8..63d47676 100644 --- a/model/modelpb/event.pb.go +++ b/model/modelpb/event.pb.go @@ -29,7 +29,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -44,15 +43,16 @@ type Event struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Outcome string `protobuf:"bytes,1,opt,name=outcome,proto3" json:"outcome,omitempty"` - Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` - Dataset string `protobuf:"bytes,3,opt,name=dataset,proto3" json:"dataset,omitempty"` - Kind string `protobuf:"bytes,4,opt,name=kind,proto3" json:"kind,omitempty"` - Category string `protobuf:"bytes,5,opt,name=category,proto3" json:"category,omitempty"` - Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` - SuccessCount *SummaryMetric `protobuf:"bytes,7,opt,name=success_count,json=successCount,proto3" json:"success_count,omitempty"` - Duration *durationpb.Duration `protobuf:"bytes,8,opt,name=duration,proto3" json:"duration,omitempty"` - Severity uint64 `protobuf:"varint,9,opt,name=severity,proto3" json:"severity,omitempty"` + Outcome string `protobuf:"bytes,1,opt,name=outcome,proto3" json:"outcome,omitempty"` + Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` + Dataset string `protobuf:"bytes,3,opt,name=dataset,proto3" json:"dataset,omitempty"` + Kind string `protobuf:"bytes,4,opt,name=kind,proto3" json:"kind,omitempty"` + Category string `protobuf:"bytes,5,opt,name=category,proto3" json:"category,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` + SuccessCount *SummaryMetric `protobuf:"bytes,7,opt,name=success_count,json=successCount,proto3" json:"success_count,omitempty"` + // nanoseconds + Duration uint64 `protobuf:"varint,8,opt,name=duration,proto3" json:"duration,omitempty"` + Severity uint64 `protobuf:"varint,9,opt,name=severity,proto3" json:"severity,omitempty"` // nanoseconds since epoch Received uint64 `protobuf:"varint,10,opt,name=received,proto3" json:"received,omitempty"` } @@ -138,11 +138,11 @@ func (x *Event) GetSuccessCount() *SummaryMetric { return nil } -func (x *Event) GetDuration() *durationpb.Duration { +func (x *Event) GetDuration() uint64 { if x != nil { return x.Duration } - return nil + return 0 } func (x *Event) GetSeverity() uint64 { @@ -163,10 +163,8 @@ var File_event_proto protoreflect.FileDescriptor var file_event_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x65, - 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x1a, 0x1e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xca, + 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x1a, 0x0f, 0x6d, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, 0x02, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, @@ -180,17 +178,16 @@ var file_event_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x0c, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x35, 0x0a, 0x08, - 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x2b, 0x5a, 0x29, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, - 0x63, 0x2f, 0x61, 0x70, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, - 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, + 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, + 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, + 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, + 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x61, 0x70, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -207,18 +204,16 @@ func file_event_proto_rawDescGZIP() []byte { var file_event_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_event_proto_goTypes = []interface{}{ - (*Event)(nil), // 0: elastic.apm.v1.Event - (*SummaryMetric)(nil), // 1: elastic.apm.v1.SummaryMetric - (*durationpb.Duration)(nil), // 2: google.protobuf.Duration + (*Event)(nil), // 0: elastic.apm.v1.Event + (*SummaryMetric)(nil), // 1: elastic.apm.v1.SummaryMetric } var file_event_proto_depIdxs = []int32{ 1, // 0: elastic.apm.v1.Event.success_count:type_name -> elastic.apm.v1.SummaryMetric - 2, // 1: elastic.apm.v1.Event.duration:type_name -> google.protobuf.Duration - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_event_proto_init() } diff --git a/model/modelpb/event_vtproto.pb.go b/model/modelpb/event_vtproto.pb.go index 682c65ee..67a0c905 100644 --- a/model/modelpb/event_vtproto.pb.go +++ b/model/modelpb/event_vtproto.pb.go @@ -28,7 +28,6 @@ import ( proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -50,16 +49,10 @@ func (m *Event) CloneVT() *Event { Category: m.Category, Type: m.Type, SuccessCount: m.SuccessCount.CloneVT(), + Duration: m.Duration, Severity: m.Severity, Received: m.Received, } - if rhs := m.Duration; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *durationpb.Duration }); ok { - r.Duration = vtpb.CloneVT() - } else { - r.Duration = proto.Clone(rhs).(*durationpb.Duration) - } - } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -111,27 +104,10 @@ func (m *Event) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0x48 } - if m.Duration != nil { - if vtmsg, ok := interface{}(m.Duration).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.Duration) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) - } + if m.Duration != 0 { + i = encodeVarint(dAtA, i, uint64(m.Duration)) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x40 } if m.SuccessCount != nil { size, err := m.SuccessCount.MarshalToSizedBufferVT(dAtA[:i]) @@ -241,15 +217,8 @@ func (m *Event) SizeVT() (n int) { l = m.SuccessCount.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.Duration != nil { - if size, ok := interface{}(m.Duration).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.Duration) - } - n += 1 + l + sov(uint64(l)) + if m.Duration != 0 { + n += 1 + sov(uint64(m.Duration)) } if m.Severity != 0 { n += 1 + sov(uint64(m.Severity)) @@ -519,10 +488,10 @@ func (m *Event) UnmarshalVT(dAtA []byte) error { } iNdEx = postIndex case 8: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) } - var msglen int + m.Duration = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -532,36 +501,11 @@ func (m *Event) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Duration |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Duration == nil { - m.Duration = &durationpb.Duration{} - } - if unmarshal, ok := interface{}(m.Duration).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Duration); err != nil { - return err - } - } - iNdEx = postIndex case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Severity", wireType) diff --git a/model/modelpb/metricset.pb.go b/model/modelpb/metricset.pb.go index e33fb7ef..d631fa1f 100644 --- a/model/modelpb/metricset.pb.go +++ b/model/modelpb/metricset.pb.go @@ -29,7 +29,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -367,8 +366,9 @@ type AggregatedDuration struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` - Sum *durationpb.Duration `protobuf:"bytes,2,opt,name=sum,proto3" json:"sum,omitempty"` + Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + // nanoseconds + Sum uint64 `protobuf:"varint,2,opt,name=sum,proto3" json:"sum,omitempty"` } func (x *AggregatedDuration) Reset() { @@ -410,11 +410,11 @@ func (x *AggregatedDuration) GetCount() uint64 { return 0 } -func (x *AggregatedDuration) GetSum() *durationpb.Duration { +func (x *AggregatedDuration) GetSum() uint64 { if x != nil { return x.Sum } - return nil + return 0 } var File_metricset_proto protoreflect.FileDescriptor @@ -422,9 +422,7 @@ var File_metricset_proto protoreflect.FileDescriptor var file_metricset_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x76, - 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x12, + 0x31, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, @@ -456,24 +454,23 @@ var file_metricset_proto_rawDesc = []byte{ 0x61, 0x72, 0x79, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x73, 0x75, - 0x6d, 0x22, 0x57, 0x0a, 0x12, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x44, + 0x6d, 0x22, 0x3c, 0x0a, 0x12, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, - 0x03, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x2a, 0x8d, 0x01, 0x0a, 0x0a, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x17, 0x4d, 0x45, 0x54, - 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x41, 0x55, 0x47, 0x45, 0x10, 0x01, 0x12, 0x17, 0x0a, - 0x13, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10, - 0x03, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, 0x10, 0x04, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, - 0x2f, 0x61, 0x70, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, - 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, + 0x03, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x2a, + 0x8d, 0x01, 0x0a, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, + 0x0a, 0x17, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4d, + 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x41, 0x55, 0x47, 0x45, + 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4d, + 0x45, 0x54, 0x52, 0x49, 0x43, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, + 0x47, 0x52, 0x41, 0x4d, 0x10, 0x03, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, 0x10, 0x04, 0x42, + 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, + 0x61, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x61, 0x70, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, + 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -491,25 +488,23 @@ func file_metricset_proto_rawDescGZIP() []byte { var file_metricset_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_metricset_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_metricset_proto_goTypes = []interface{}{ - (MetricType)(0), // 0: elastic.apm.v1.MetricType - (*Metricset)(nil), // 1: elastic.apm.v1.Metricset - (*MetricsetSample)(nil), // 2: elastic.apm.v1.MetricsetSample - (*Histogram)(nil), // 3: elastic.apm.v1.Histogram - (*SummaryMetric)(nil), // 4: elastic.apm.v1.SummaryMetric - (*AggregatedDuration)(nil), // 5: elastic.apm.v1.AggregatedDuration - (*durationpb.Duration)(nil), // 6: google.protobuf.Duration + (MetricType)(0), // 0: elastic.apm.v1.MetricType + (*Metricset)(nil), // 1: elastic.apm.v1.Metricset + (*MetricsetSample)(nil), // 2: elastic.apm.v1.MetricsetSample + (*Histogram)(nil), // 3: elastic.apm.v1.Histogram + (*SummaryMetric)(nil), // 4: elastic.apm.v1.SummaryMetric + (*AggregatedDuration)(nil), // 5: elastic.apm.v1.AggregatedDuration } var file_metricset_proto_depIdxs = []int32{ 2, // 0: elastic.apm.v1.Metricset.samples:type_name -> elastic.apm.v1.MetricsetSample 0, // 1: elastic.apm.v1.MetricsetSample.type:type_name -> elastic.apm.v1.MetricType 3, // 2: elastic.apm.v1.MetricsetSample.histogram:type_name -> elastic.apm.v1.Histogram 4, // 3: elastic.apm.v1.MetricsetSample.summary:type_name -> elastic.apm.v1.SummaryMetric - 6, // 4: elastic.apm.v1.AggregatedDuration.sum:type_name -> google.protobuf.Duration - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_metricset_proto_init() } diff --git a/model/modelpb/metricset_vtproto.pb.go b/model/modelpb/metricset_vtproto.pb.go index 9c0e9815..faf3f864 100644 --- a/model/modelpb/metricset_vtproto.pb.go +++ b/model/modelpb/metricset_vtproto.pb.go @@ -30,7 +30,6 @@ import ( proto "google.golang.org/protobuf/proto" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -141,13 +140,7 @@ func (m *AggregatedDuration) CloneVT() *AggregatedDuration { } r := &AggregatedDuration{ Count: m.Count, - } - if rhs := m.Sum; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *durationpb.Duration }); ok { - r.Sum = vtpb.CloneVT() - } else { - r.Sum = proto.Clone(rhs).(*durationpb.Duration) - } + Sum: m.Sum, } if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) @@ -439,27 +432,10 @@ func (m *AggregatedDuration) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if m.Sum != nil { - if vtmsg, ok := interface{}(m.Sum).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.Sum) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = encodeVarint(dAtA, i, uint64(len(encoded))) - } + if m.Sum != 0 { + i = encodeVarint(dAtA, i, uint64(m.Sum)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if m.Count != 0 { i = encodeVarint(dAtA, i, uint64(m.Count)) @@ -676,15 +652,8 @@ func (m *AggregatedDuration) SizeVT() (n int) { if m.Count != 0 { n += 1 + sov(uint64(m.Count)) } - if m.Sum != nil { - if size, ok := interface{}(m.Sum).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.Sum) - } - n += 1 + l + sov(uint64(l)) + if m.Sum != 0 { + n += 1 + sov(uint64(m.Sum)) } n += len(m.unknownFields) return n @@ -1393,10 +1362,10 @@ func (m *AggregatedDuration) UnmarshalVT(dAtA []byte) error { } } case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) } - var msglen int + m.Sum = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1406,36 +1375,11 @@ func (m *AggregatedDuration) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Sum |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Sum == nil { - m.Sum = &durationpb.Duration{} - } - if unmarshal, ok := interface{}(m.Sum).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Sum); err != nil { - return err - } - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/model/proto/event.proto b/model/proto/event.proto index 63bea939..90b07cf9 100644 --- a/model/proto/event.proto +++ b/model/proto/event.proto @@ -19,7 +19,6 @@ syntax = "proto3"; package elastic.apm.v1; -import "google/protobuf/duration.proto"; import "metricset.proto"; option go_package = "github.com/elastic/apm-data/model/modelpb"; @@ -34,7 +33,10 @@ message Event { string type = 6; SummaryMetric success_count = 7; - google.protobuf.Duration duration = 8; + + // nanoseconds + uint64 duration = 8; + uint64 severity = 9; // nanoseconds since epoch diff --git a/model/proto/metricset.proto b/model/proto/metricset.proto index 60429982..cd316801 100644 --- a/model/proto/metricset.proto +++ b/model/proto/metricset.proto @@ -19,8 +19,6 @@ syntax = "proto3"; package elastic.apm.v1; -import "google/protobuf/duration.proto"; - option go_package = "github.com/elastic/apm-data/model/modelpb"; message Metricset { @@ -59,5 +57,7 @@ message SummaryMetric { message AggregatedDuration { uint64 count = 1; - google.protobuf.Duration sum = 2; + + // nanoseconds + uint64 sum = 2; }