From f64f96032c6556e21a9a2317e80a7b752f49a579 Mon Sep 17 00:00:00 2001 From: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com> Date: Thu, 16 Jul 2020 18:37:29 -0400 Subject: [PATCH] Update OTLP to latest version (#1384) - Removed the draft logsproto and now using the logs Protobufs from official OTLP repo. The rest of the changes are forced by this. - Added InstrumentationLibraryLogs and change the type of LogRecord.Body to AnyValue. - Updated fileexporter and logexporter to use the new log data type. --- Makefile | 18 +- cmd/pdatagen/internal/common_structs.go | 5 + cmd/pdatagen/internal/log_structs.go | 57 +- consumer/pdata/common.go | 20 + consumer/pdata/common_test.go | 10 + consumer/pdata/generated_log.go | 295 +++++- consumer/pdata/generated_log_test.go | 232 ++++- consumer/pdata/log.go | 8 +- exporter/fileexporter/file_exporter.go | 11 +- exporter/fileexporter/file_exporter_test.go | 68 +- exporter/loggingexporter/logging_exporter.go | 44 +- exporter/otlpexporter/otlp.go | 12 +- exporter/otlpexporter/otlp_test.go | 16 +- internal/data/log.go | 24 +- internal/data/log_test.go | 32 +- internal/data/logsproto/logs/v1/logs.proto | 140 --- internal/data/opentelemetry-proto | 2 +- .../collector/logs/v1/logs_service.pb.go | 555 +++++++++++ .../collector/logs/v1/logs_service.pb.gw.go | 163 ++++ .../logs/v1/logs.pb.go | 919 ++++++++---------- internal/data/testdata/log.go | 137 ++- internal/data/testdata/log_test.go | 12 +- 22 files changed, 1859 insertions(+), 921 deletions(-) delete mode 100644 internal/data/logsproto/logs/v1/logs.proto create mode 100644 internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.go create mode 100644 internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.gw.go diff --git a/Makefile b/Makefile index 0a98fa349139..5386e2068481 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ ALL_SRC := $(shell find . -name '*.go' \ -not -path '*/third_party/*' \ -not -path '*/internal/data/opentelemetry-proto/*' \ -not -path '*/internal/data/opentelemetry-proto-gen/*' \ - -not -path '*/internal/data/logsproto/*' \ -not -path './.circleci/scripts/reportgenerator/*' \ -type f | sort) @@ -126,7 +125,7 @@ lint: lint-static-check .PHONY: impi impi: - @$(IMPI) --local go.opentelemetry.io/collector --scheme stdThirdPartyLocal --skip internal/data/opentelemetry-proto --skip internal/data/logsproto ./... + @$(IMPI) --local go.opentelemetry.io/collector --scheme stdThirdPartyLocal --skip internal/data/opentelemetry-proto ./... .PHONY: fmt fmt: @@ -219,12 +218,6 @@ OPENTELEMETRY_PROTO_SRC_DIR=internal/data/opentelemetry-proto # Find all .proto files. OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto)) -# The source directory for experimental Log ProtoBufs. -LOGS_PROTO_SRC_DIR=internal/data/logsproto - -# Find Log .proto files. -LOGS_PROTO_FILES := $(subst $(LOGS_PROTO_SRC_DIR)/,,$(wildcard $(LOGS_PROTO_SRC_DIR)/*/v1/*.proto $(LOGS_PROTO_SRC_DIR)/collector/*/v1/*.proto)) - # Target directory to write generated files to. PROTO_TARGET_GEN_DIR=internal/data/opentelemetry-proto-gen @@ -260,20 +253,13 @@ genproto_sub: @echo Modify them in the intermediate directory. $(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,sed 's+github.com/open-telemetry/opentelemetry-proto/gen/go/+go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/+g' $(OPENTELEMETRY_PROTO_SRC_DIR)/$(file) > $(PROTO_INTERMEDIATE_DIR)/$(file))) - @echo Generate Go code from Logs .proto files in intermediate directory. - $(foreach file,$(LOGS_PROTO_FILES),$(call exec-command,cd $(LOGS_PROTO_SRC_DIR) && protoc --gogofaster_out=plugins=grpc:./ -I./ -I$(PWD)/$(PROTO_INTERMEDIATE_DIR) $(file))) - - @echo Move generated code to target directory. - mkdir -p $(PROTO_TARGET_GEN_DIR) - cp -R $(LOGS_PROTO_SRC_DIR)/$(PROTO_PACKAGE)/* $(PROTO_TARGET_GEN_DIR)/ - rm -rf $(LOGS_PROTO_SRC_DIR)/go.opentelemetry.io - @echo Generate Go code from .proto files in intermediate directory. $(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,cd $(PROTO_INTERMEDIATE_DIR) && protoc --gogofaster_out=plugins=grpc:./ -I./ $(file))) @echo Generate gRPC gateway code. cd $(PROTO_INTERMEDIATE_DIR) && protoc --grpc-gateway_out=logtostderr=true,grpc_api_configuration=opentelemetry/proto/collector/trace/v1/trace_service_http.yaml:./ opentelemetry/proto/collector/trace/v1/trace_service.proto cd $(PROTO_INTERMEDIATE_DIR) && protoc --grpc-gateway_out=logtostderr=true,grpc_api_configuration=opentelemetry/proto/collector/metrics/v1/metrics_service_http.yaml:./ opentelemetry/proto/collector/metrics/v1/metrics_service.proto + cd $(PROTO_INTERMEDIATE_DIR) && protoc --grpc-gateway_out=logtostderr=true,grpc_api_configuration=opentelemetry/proto/collector/logs/v1/logs_service_http.yaml:./ opentelemetry/proto/collector/logs/v1/logs_service.proto @echo Move generated code to target directory. mkdir -p $(PROTO_TARGET_GEN_DIR) diff --git a/cmd/pdatagen/internal/common_structs.go b/cmd/pdatagen/internal/common_structs.go index 88b5dc61a366..1f16f9d10a3a 100644 --- a/cmd/pdatagen/internal/common_structs.go +++ b/cmd/pdatagen/internal/common_structs.go @@ -109,3 +109,8 @@ var nameField = &primitiveField{ defaultVal: `""`, testVal: `"test_name"`, } + +var anyValue = &messageStruct{ + structName: "AttributeValue", + originFullName: "otlpcommon.AnyValue", +} diff --git a/cmd/pdatagen/internal/log_structs.go b/cmd/pdatagen/internal/log_structs.go index d40830ad0a1a..8ffa46a28a79 100644 --- a/cmd/pdatagen/internal/log_structs.go +++ b/cmd/pdatagen/internal/log_structs.go @@ -17,18 +17,20 @@ package internal var logFile = &File{ Name: "log", imports: []string{ - `logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"`, + `otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"`, }, testImports: []string{ `"testing"`, ``, `"github.com/stretchr/testify/assert"`, ``, - `logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"`, + `otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"`, }, structs: []baseStruct{ resourceLogsSlice, resourceLogs, + instrumentationLibraryLogsSlice, + instrumentationLibraryLogs, logSlice, logRecord, }, @@ -42,9 +44,28 @@ var resourceLogsSlice = &sliceStruct{ var resourceLogs = &messageStruct{ structName: "ResourceLogs", description: "// ResourceLogs is a collection of logs from a Resource.", - originFullName: "logsproto.ResourceLogs", + originFullName: "otlplogs.ResourceLogs", fields: []baseField{ resourceField, + &sliceField{ + fieldMame: "InstrumentationLibraryLogs", + originFieldName: "InstrumentationLibraryLogs", + returnSlice: instrumentationLibraryLogsSlice, + }, + }, +} + +var instrumentationLibraryLogsSlice = &sliceStruct{ + structName: "InstrumentationLibraryLogsSlice", + element: instrumentationLibraryLogs, +} + +var instrumentationLibraryLogs = &messageStruct{ + structName: "InstrumentationLibraryLogs", + description: "// InstrumentationLibraryLogs is a collection of logs from a LibraryInstrumentation.", + originFullName: "otlplogs.InstrumentationLibraryLogs", + fields: []baseField{ + instrumentationLibraryField, &sliceField{ fieldMame: "Logs", originFieldName: "Logs", @@ -61,11 +82,11 @@ var logSlice = &sliceStruct{ var logRecord = &messageStruct{ structName: "LogRecord", description: "// LogRecord are experimental implementation of OpenTelemetry Log Data Model.\n", - originFullName: "logsproto.LogRecord", + originFullName: "otlplogs.LogRecord", fields: []baseField{ &primitiveTypedField{ fieldMame: "Timestamp", - originFieldName: "TimestampUnixNano", + originFieldName: "TimeUnixNano", returnType: "TimestampUnixNano", rawType: "uint64", defaultVal: "TimestampUnixNano(0)", @@ -91,26 +112,26 @@ var logRecord = &messageStruct{ &primitiveTypedField{ fieldMame: "SeverityNumber", originFieldName: "SeverityNumber", - returnType: "logsproto.SeverityNumber", - rawType: "logsproto.SeverityNumber", - defaultVal: `logsproto.SeverityNumber_UNDEFINED_SEVERITY_NUMBER`, - testVal: `logsproto.SeverityNumber_INFO`, + returnType: "otlplogs.SeverityNumber", + rawType: "otlplogs.SeverityNumber", + defaultVal: `otlplogs.SeverityNumber_UNDEFINED_SEVERITY_NUMBER`, + testVal: `otlplogs.SeverityNumber_INFO`, }, &primitiveField{ - fieldMame: "ShortName", - originFieldName: "ShortName", + fieldMame: "Name", + originFieldName: "Name", returnType: "string", defaultVal: `""`, testVal: `"test_name"`, }, - &primitiveField{ - fieldMame: "Body", - originFieldName: "Body", - returnType: "string", - defaultVal: `""`, - testVal: `"test log message"`, - }, + bodyField, attributes, droppedAttributesCount, }, } + +var bodyField = &messageField{ + fieldName: "Body", + originFieldName: "Body", + returnMessage: anyValue, +} diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 91cb0f571be0..399dd320b8f1 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -90,6 +90,10 @@ type AttributeValue struct { orig **otlpcommon.AnyValue } +func newAttributeValue(orig **otlpcommon.AnyValue) AttributeValue { + return AttributeValue{orig} +} + // NewAttributeValueNull creates a new AttributeValue with a null value. func NewAttributeValueNull() AttributeValue { orig := &otlpcommon.AnyValue{} @@ -141,6 +145,15 @@ func NewAttributeValueSlice(len int) []AttributeValue { return wrappers } +func (a AttributeValue) InitEmpty() { + *a.orig = &otlpcommon.AnyValue{} +} + +// IsNil returns true if the underlying data are nil. +func (a AttributeValue) IsNil() bool { + return *a.orig == nil +} + // Type returns the type of the value for this AttributeValue. // Calling this function on zero-initialized AttributeValue will cause a panic. func (a AttributeValue) Type() AttributeValueType { @@ -296,6 +309,13 @@ func (a AttributeValue) copyTo(dest *otlpcommon.AnyValue) { } } +func (a AttributeValue) CopyTo(dest AttributeValue) { + if *a.orig != nil && dest.IsNil() { + dest.InitEmpty() + } + a.copyTo(*dest.orig) +} + // Equal checks for equality, it returns true if the objects are equal otherwise false. func (a AttributeValue) Equal(av AttributeValue) bool { if (*a.orig) == nil || (*a.orig).Value == nil { diff --git a/consumer/pdata/common_test.go b/consumer/pdata/common_test.go index 790963db75fc..d1718992d955 100644 --- a/consumer/pdata/common_test.go +++ b/consumer/pdata/common_test.go @@ -1061,6 +1061,16 @@ func BenchmarkStringMap_RangeOverMap(b *testing.B) { } } +func fillTestAttributeValue(dest AttributeValue) { + dest.SetStringVal("v") +} + +func generateTestAttributeValue() AttributeValue { + av := NewAttributeValueNull() + fillTestAttributeValue(av) + return av +} + func generateTestStringMap() StringMap { sm := NewStringMap() fillTestStringMap(sm) diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index 53aabe9f8c57..9416d2300a3d 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -18,7 +18,7 @@ package pdata import ( - logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) // ResourceLogsSlice logically represents a slice of ResourceLogs. @@ -29,19 +29,19 @@ import ( // Must use NewResourceLogsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceLogsSlice struct { - // orig points to the slice logsproto.ResourceLogs field contained somewhere else. + // orig points to the slice otlplogs.ResourceLogs field contained somewhere else. // We use pointer-to-slice to be able to modify it in functions like Resize. - orig *[]*logsproto.ResourceLogs + orig *[]*otlplogs.ResourceLogs } -func newResourceLogsSlice(orig *[]*logsproto.ResourceLogs) ResourceLogsSlice { +func newResourceLogsSlice(orig *[]*otlplogs.ResourceLogs) ResourceLogsSlice { return ResourceLogsSlice{orig} } // NewResourceLogsSlice creates a ResourceLogsSlice with 0 elements. // Can use "Resize" to initialize with a given length. func NewResourceLogsSlice() ResourceLogsSlice { - orig := []*logsproto.ResourceLogs(nil) + orig := []*otlplogs.ResourceLogs(nil) return ResourceLogsSlice{&orig} } @@ -85,7 +85,7 @@ func (es ResourceLogsSlice) MoveAndAppendTo(dest ResourceLogsSlice) { func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { newLen := es.Len() if newLen == 0 { - *dest.orig = []*logsproto.ResourceLogs(nil) + *dest.orig = []*otlplogs.ResourceLogs(nil) return } oldLen := dest.Len() @@ -96,8 +96,8 @@ func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { } return } - origs := make([]logsproto.ResourceLogs, newLen) - wrappers := make([]*logsproto.ResourceLogs, newLen) + origs := make([]otlplogs.ResourceLogs, newLen) + wrappers := make([]*otlplogs.ResourceLogs, newLen) for i, el := range *es.orig { wrappers[i] = &origs[i] newResourceLogs(&el).CopyTo(newResourceLogs(&wrappers[i])) @@ -119,7 +119,7 @@ func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { // } func (es ResourceLogsSlice) Resize(newLen int) { if newLen == 0 { - (*es.orig) = []*logsproto.ResourceLogs(nil) + (*es.orig) = []*otlplogs.ResourceLogs(nil) return } oldLen := len(*es.orig) @@ -128,7 +128,7 @@ func (es ResourceLogsSlice) Resize(newLen int) { return } // TODO: Benchmark and optimize this logic. - extraOrigs := make([]logsproto.ResourceLogs, newLen-oldLen) + extraOrigs := make([]otlplogs.ResourceLogs, newLen-oldLen) oldOrig := (*es.orig) for i := range extraOrigs { oldOrig = append(oldOrig, &extraOrigs[i]) @@ -152,12 +152,12 @@ func (es ResourceLogsSlice) Append(e *ResourceLogs) { // Must use NewResourceLogs function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceLogs struct { - // orig points to the pointer logsproto.ResourceLogs field contained somewhere else. + // orig points to the pointer otlplogs.ResourceLogs field contained somewhere else. // We use pointer-to-pointer to be able to modify it in InitEmpty func. - orig **logsproto.ResourceLogs + orig **otlplogs.ResourceLogs } -func newResourceLogs(orig **logsproto.ResourceLogs) ResourceLogs { +func newResourceLogs(orig **otlplogs.ResourceLogs) ResourceLogs { return ResourceLogs{orig} } @@ -166,13 +166,13 @@ func newResourceLogs(orig **logsproto.ResourceLogs) ResourceLogs { // // This must be used only in testing code since no "Set" method available. func NewResourceLogs() ResourceLogs { - orig := (*logsproto.ResourceLogs)(nil) + orig := (*otlplogs.ResourceLogs)(nil) return newResourceLogs(&orig) } // InitEmpty overwrites the current value with empty. func (ms ResourceLogs) InitEmpty() { - *ms.orig = &logsproto.ResourceLogs{} + *ms.orig = &otlplogs.ResourceLogs{} } // IsNil returns true if the underlying data are nil. @@ -192,11 +192,11 @@ func (ms ResourceLogs) Resource() Resource { return newResource(&(*ms.orig).Resource) } -// Logs returns the Logs associated with this ResourceLogs. +// InstrumentationLibraryLogs returns the InstrumentationLibraryLogs associated with this ResourceLogs. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms ResourceLogs) Logs() LogSlice { - return newLogSlice(&(*ms.orig).Logs) +func (ms ResourceLogs) InstrumentationLibraryLogs() InstrumentationLibraryLogsSlice { + return newInstrumentationLibraryLogsSlice(&(*ms.orig).InstrumentationLibraryLogs) } // CopyTo copies all properties from the current struct to the dest. @@ -209,6 +209,197 @@ func (ms ResourceLogs) CopyTo(dest ResourceLogs) { dest.InitEmpty() } ms.Resource().CopyTo(dest.Resource()) + ms.InstrumentationLibraryLogs().CopyTo(dest.InstrumentationLibraryLogs()) +} + +// InstrumentationLibraryLogsSlice logically represents a slice of InstrumentationLibraryLogs. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewInstrumentationLibraryLogsSlice function to create new instances. +// Important: zero-initialized instance is not valid for use. +type InstrumentationLibraryLogsSlice struct { + // orig points to the slice otlplogs.InstrumentationLibraryLogs field contained somewhere else. + // We use pointer-to-slice to be able to modify it in functions like Resize. + orig *[]*otlplogs.InstrumentationLibraryLogs +} + +func newInstrumentationLibraryLogsSlice(orig *[]*otlplogs.InstrumentationLibraryLogs) InstrumentationLibraryLogsSlice { + return InstrumentationLibraryLogsSlice{orig} +} + +// NewInstrumentationLibraryLogsSlice creates a InstrumentationLibraryLogsSlice with 0 elements. +// Can use "Resize" to initialize with a given length. +func NewInstrumentationLibraryLogsSlice() InstrumentationLibraryLogsSlice { + orig := []*otlplogs.InstrumentationLibraryLogs(nil) + return InstrumentationLibraryLogsSlice{&orig} +} + +// Len returns the number of elements in the slice. +// +// Returns "0" for a newly instance created with "NewInstrumentationLibraryLogsSlice()". +func (es InstrumentationLibraryLogsSlice) Len() int { + return len(*es.orig) +} + +// At returns the element at the given index. +// +// This function is used mostly for iterating over all the values in the slice: +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } +func (es InstrumentationLibraryLogsSlice) At(ix int) InstrumentationLibraryLogs { + return newInstrumentationLibraryLogs(&(*es.orig)[ix]) +} + +// MoveAndAppendTo moves all elements from the current slice and appends them to the dest. +// The current slice will be cleared. +func (es InstrumentationLibraryLogsSlice) MoveAndAppendTo(dest InstrumentationLibraryLogsSlice) { + if es.Len() == 0 { + // Just to ensure that we always return a Slice with nil elements. + *es.orig = nil + return + } + if dest.Len() == 0 { + *dest.orig = *es.orig + *es.orig = nil + return + } + *dest.orig = append(*dest.orig, *es.orig...) + *es.orig = nil + return +} + +// CopyTo copies all elements from the current slice to the dest. +func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogsSlice) { + newLen := es.Len() + if newLen == 0 { + *dest.orig = []*otlplogs.InstrumentationLibraryLogs(nil) + return + } + oldLen := dest.Len() + if newLen <= oldLen { + (*dest.orig) = (*dest.orig)[:newLen] + for i, el := range *es.orig { + newInstrumentationLibraryLogs(&el).CopyTo(newInstrumentationLibraryLogs(&(*dest.orig)[i])) + } + return + } + origs := make([]otlplogs.InstrumentationLibraryLogs, newLen) + wrappers := make([]*otlplogs.InstrumentationLibraryLogs, newLen) + for i, el := range *es.orig { + wrappers[i] = &origs[i] + newInstrumentationLibraryLogs(&el).CopyTo(newInstrumentationLibraryLogs(&wrappers[i])) + } + *dest.orig = wrappers +} + +// Resize is an operation that resizes the slice: +// 1. If newLen is 0 then the slice is replaced with a nil slice. +// 2. If the newLen <= len then equivalent with slice[0:newLen]. +// 3. If the newLen > len then (newLen - len) empty elements will be appended to the slice. +// +// Here is how a new InstrumentationLibraryLogsSlice can be initialized: +// es := NewInstrumentationLibraryLogsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } +func (es InstrumentationLibraryLogsSlice) Resize(newLen int) { + if newLen == 0 { + (*es.orig) = []*otlplogs.InstrumentationLibraryLogs(nil) + return + } + oldLen := len(*es.orig) + if newLen <= oldLen { + (*es.orig) = (*es.orig)[:newLen] + return + } + // TODO: Benchmark and optimize this logic. + extraOrigs := make([]otlplogs.InstrumentationLibraryLogs, newLen-oldLen) + oldOrig := (*es.orig) + for i := range extraOrigs { + oldOrig = append(oldOrig, &extraOrigs[i]) + } + (*es.orig) = oldOrig +} + +// Append will increase the length of the InstrumentationLibraryLogsSlice by one and set the +// given InstrumentationLibraryLogs at that new position. The original InstrumentationLibraryLogs +// could still be referenced so do not reuse it after passing it to this +// method. +func (es InstrumentationLibraryLogsSlice) Append(e *InstrumentationLibraryLogs) { + (*es.orig) = append((*es.orig), *e.orig) +} + +// InstrumentationLibraryLogs is a collection of logs from a LibraryInstrumentation. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewInstrumentationLibraryLogs function to create new instances. +// Important: zero-initialized instance is not valid for use. +type InstrumentationLibraryLogs struct { + // orig points to the pointer otlplogs.InstrumentationLibraryLogs field contained somewhere else. + // We use pointer-to-pointer to be able to modify it in InitEmpty func. + orig **otlplogs.InstrumentationLibraryLogs +} + +func newInstrumentationLibraryLogs(orig **otlplogs.InstrumentationLibraryLogs) InstrumentationLibraryLogs { + return InstrumentationLibraryLogs{orig} +} + +// NewInstrumentationLibraryLogs creates a new "nil" InstrumentationLibraryLogs. +// To initialize the struct call "InitEmpty". +// +// This must be used only in testing code since no "Set" method available. +func NewInstrumentationLibraryLogs() InstrumentationLibraryLogs { + orig := (*otlplogs.InstrumentationLibraryLogs)(nil) + return newInstrumentationLibraryLogs(&orig) +} + +// InitEmpty overwrites the current value with empty. +func (ms InstrumentationLibraryLogs) InitEmpty() { + *ms.orig = &otlplogs.InstrumentationLibraryLogs{} +} + +// IsNil returns true if the underlying data are nil. +// +// Important: All other functions will cause a runtime error if this returns "true". +func (ms InstrumentationLibraryLogs) IsNil() bool { + return *ms.orig == nil +} + +// InstrumentationLibrary returns the instrumentationlibrary associated with this InstrumentationLibraryLogs. +// If no instrumentationlibrary available, it creates an empty message and associates it with this InstrumentationLibraryLogs. +// +// Empty initialized InstrumentationLibraryLogs will return "nil" InstrumentationLibrary. +// +// Important: This causes a runtime error if IsNil() returns "true". +func (ms InstrumentationLibraryLogs) InstrumentationLibrary() InstrumentationLibrary { + return newInstrumentationLibrary(&(*ms.orig).InstrumentationLibrary) +} + +// Logs returns the Logs associated with this InstrumentationLibraryLogs. +// +// Important: This causes a runtime error if IsNil() returns "true". +func (ms InstrumentationLibraryLogs) Logs() LogSlice { + return newLogSlice(&(*ms.orig).Logs) +} + +// CopyTo copies all properties from the current struct to the dest. +func (ms InstrumentationLibraryLogs) CopyTo(dest InstrumentationLibraryLogs) { + if ms.IsNil() { + *dest.orig = nil + return + } + if dest.IsNil() { + dest.InitEmpty() + } + ms.InstrumentationLibrary().CopyTo(dest.InstrumentationLibrary()) ms.Logs().CopyTo(dest.Logs()) } @@ -220,19 +411,19 @@ func (ms ResourceLogs) CopyTo(dest ResourceLogs) { // Must use NewLogSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LogSlice struct { - // orig points to the slice logsproto.LogRecord field contained somewhere else. + // orig points to the slice otlplogs.LogRecord field contained somewhere else. // We use pointer-to-slice to be able to modify it in functions like Resize. - orig *[]*logsproto.LogRecord + orig *[]*otlplogs.LogRecord } -func newLogSlice(orig *[]*logsproto.LogRecord) LogSlice { +func newLogSlice(orig *[]*otlplogs.LogRecord) LogSlice { return LogSlice{orig} } // NewLogSlice creates a LogSlice with 0 elements. // Can use "Resize" to initialize with a given length. func NewLogSlice() LogSlice { - orig := []*logsproto.LogRecord(nil) + orig := []*otlplogs.LogRecord(nil) return LogSlice{&orig} } @@ -276,7 +467,7 @@ func (es LogSlice) MoveAndAppendTo(dest LogSlice) { func (es LogSlice) CopyTo(dest LogSlice) { newLen := es.Len() if newLen == 0 { - *dest.orig = []*logsproto.LogRecord(nil) + *dest.orig = []*otlplogs.LogRecord(nil) return } oldLen := dest.Len() @@ -287,8 +478,8 @@ func (es LogSlice) CopyTo(dest LogSlice) { } return } - origs := make([]logsproto.LogRecord, newLen) - wrappers := make([]*logsproto.LogRecord, newLen) + origs := make([]otlplogs.LogRecord, newLen) + wrappers := make([]*otlplogs.LogRecord, newLen) for i, el := range *es.orig { wrappers[i] = &origs[i] newLogRecord(&el).CopyTo(newLogRecord(&wrappers[i])) @@ -310,7 +501,7 @@ func (es LogSlice) CopyTo(dest LogSlice) { // } func (es LogSlice) Resize(newLen int) { if newLen == 0 { - (*es.orig) = []*logsproto.LogRecord(nil) + (*es.orig) = []*otlplogs.LogRecord(nil) return } oldLen := len(*es.orig) @@ -319,7 +510,7 @@ func (es LogSlice) Resize(newLen int) { return } // TODO: Benchmark and optimize this logic. - extraOrigs := make([]logsproto.LogRecord, newLen-oldLen) + extraOrigs := make([]otlplogs.LogRecord, newLen-oldLen) oldOrig := (*es.orig) for i := range extraOrigs { oldOrig = append(oldOrig, &extraOrigs[i]) @@ -344,12 +535,12 @@ func (es LogSlice) Append(e *LogRecord) { // Must use NewLogRecord function to create new instances. // Important: zero-initialized instance is not valid for use. type LogRecord struct { - // orig points to the pointer logsproto.LogRecord field contained somewhere else. + // orig points to the pointer otlplogs.LogRecord field contained somewhere else. // We use pointer-to-pointer to be able to modify it in InitEmpty func. - orig **logsproto.LogRecord + orig **otlplogs.LogRecord } -func newLogRecord(orig **logsproto.LogRecord) LogRecord { +func newLogRecord(orig **otlplogs.LogRecord) LogRecord { return LogRecord{orig} } @@ -358,13 +549,13 @@ func newLogRecord(orig **logsproto.LogRecord) LogRecord { // // This must be used only in testing code since no "Set" method available. func NewLogRecord() LogRecord { - orig := (*logsproto.LogRecord)(nil) + orig := (*otlplogs.LogRecord)(nil) return newLogRecord(&orig) } // InitEmpty overwrites the current value with empty. func (ms LogRecord) InitEmpty() { - *ms.orig = &logsproto.LogRecord{} + *ms.orig = &otlplogs.LogRecord{} } // IsNil returns true if the underlying data are nil. @@ -378,14 +569,14 @@ func (ms LogRecord) IsNil() bool { // // Important: This causes a runtime error if IsNil() returns "true". func (ms LogRecord) Timestamp() TimestampUnixNano { - return TimestampUnixNano((*ms.orig).TimestampUnixNano) + return TimestampUnixNano((*ms.orig).TimeUnixNano) } // SetTimestamp replaces the timestamp associated with this LogRecord. // // Important: This causes a runtime error if IsNil() returns "true". func (ms LogRecord) SetTimestamp(v TimestampUnixNano) { - (*ms.orig).TimestampUnixNano = uint64(v) + (*ms.orig).TimeUnixNano = uint64(v) } // TraceID returns the traceid associated with this LogRecord. @@ -447,43 +638,39 @@ func (ms LogRecord) SetSeverityText(v string) { // SeverityNumber returns the severitynumber associated with this LogRecord. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) SeverityNumber() logsproto.SeverityNumber { - return logsproto.SeverityNumber((*ms.orig).SeverityNumber) +func (ms LogRecord) SeverityNumber() otlplogs.SeverityNumber { + return otlplogs.SeverityNumber((*ms.orig).SeverityNumber) } // SetSeverityNumber replaces the severitynumber associated with this LogRecord. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) SetSeverityNumber(v logsproto.SeverityNumber) { - (*ms.orig).SeverityNumber = logsproto.SeverityNumber(v) +func (ms LogRecord) SetSeverityNumber(v otlplogs.SeverityNumber) { + (*ms.orig).SeverityNumber = otlplogs.SeverityNumber(v) } -// ShortName returns the shortname associated with this LogRecord. +// Name returns the name associated with this LogRecord. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) ShortName() string { - return (*ms.orig).ShortName +func (ms LogRecord) Name() string { + return (*ms.orig).Name } -// SetShortName replaces the shortname associated with this LogRecord. +// SetName replaces the name associated with this LogRecord. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) SetShortName(v string) { - (*ms.orig).ShortName = v +func (ms LogRecord) SetName(v string) { + (*ms.orig).Name = v } // Body returns the body associated with this LogRecord. +// If no body available, it creates an empty message and associates it with this LogRecord. // -// Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) Body() string { - return (*ms.orig).Body -} - -// SetBody replaces the body associated with this LogRecord. +// Empty initialized LogRecord will return "nil" AttributeValue. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms LogRecord) SetBody(v string) { - (*ms.orig).Body = v +func (ms LogRecord) Body() AttributeValue { + return newAttributeValue(&(*ms.orig).Body) } // Attributes returns the Attributes associated with this LogRecord. @@ -522,8 +709,8 @@ func (ms LogRecord) CopyTo(dest LogRecord) { dest.SetFlags(ms.Flags()) dest.SetSeverityText(ms.SeverityText()) dest.SetSeverityNumber(ms.SeverityNumber()) - dest.SetShortName(ms.ShortName()) - dest.SetBody(ms.Body()) + dest.SetName(ms.Name()) + ms.Body().CopyTo(dest.Body()) ms.Attributes().CopyTo(dest.Attributes()) dest.SetDroppedAttributesCount(ms.DroppedAttributesCount()) } diff --git a/consumer/pdata/generated_log_test.go b/consumer/pdata/generated_log_test.go index 5f86167bded2..333e9106e7f0 100644 --- a/consumer/pdata/generated_log_test.go +++ b/consumer/pdata/generated_log_test.go @@ -22,13 +22,13 @@ import ( "github.com/stretchr/testify/assert" - logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) func TestResourceLogsSlice(t *testing.T) { es := NewResourceLogsSlice() assert.EqualValues(t, 0, es.Len()) - es = newResourceLogsSlice(&[]*logsproto.ResourceLogs{}) + es = newResourceLogsSlice(&[]*otlplogs.ResourceLogs{}) assert.EqualValues(t, 0, es.Len()) es.Resize(7) @@ -89,14 +89,14 @@ func TestResourceLogsSlice_Resize(t *testing.T) { emptyVal.InitEmpty() // Test Resize less elements. const resizeSmallLen = 4 - expectedEs := make(map[*logsproto.ResourceLogs]bool, resizeSmallLen) + expectedEs := make(map[*otlplogs.ResourceLogs]bool, resizeSmallLen) for i := 0; i < resizeSmallLen; i++ { expectedEs[*(es.At(i).orig)] = true } assert.EqualValues(t, resizeSmallLen, len(expectedEs)) es.Resize(resizeSmallLen) assert.EqualValues(t, resizeSmallLen, es.Len()) - foundEs := make(map[*logsproto.ResourceLogs]bool, resizeSmallLen) + foundEs := make(map[*otlplogs.ResourceLogs]bool, resizeSmallLen) for i := 0; i < es.Len(); i++ { foundEs[*(es.At(i).orig)] = true } @@ -105,14 +105,14 @@ func TestResourceLogsSlice_Resize(t *testing.T) { // Test Resize more elements. const resizeLargeLen = 7 oldLen := es.Len() - expectedEs = make(map[*logsproto.ResourceLogs]bool, oldLen) + expectedEs = make(map[*otlplogs.ResourceLogs]bool, oldLen) for i := 0; i < oldLen; i++ { expectedEs[*(es.At(i).orig)] = true } assert.EqualValues(t, oldLen, len(expectedEs)) es.Resize(resizeLargeLen) assert.EqualValues(t, resizeLargeLen, es.Len()) - foundEs = make(map[*logsproto.ResourceLogs]bool, oldLen) + foundEs = make(map[*otlplogs.ResourceLogs]bool, oldLen) for i := 0; i < oldLen; i++ { foundEs[*(es.At(i).orig)] = true } @@ -168,9 +168,161 @@ func TestResourceLogs_Resource(t *testing.T) { assert.EqualValues(t, generateTestResource(), ms.Resource()) } -func TestResourceLogs_Logs(t *testing.T) { +func TestResourceLogs_InstrumentationLibraryLogs(t *testing.T) { ms := NewResourceLogs() ms.InitEmpty() + assert.EqualValues(t, NewInstrumentationLibraryLogsSlice(), ms.InstrumentationLibraryLogs()) + fillTestInstrumentationLibraryLogsSlice(ms.InstrumentationLibraryLogs()) + testValInstrumentationLibraryLogs := generateTestInstrumentationLibraryLogsSlice() + assert.EqualValues(t, testValInstrumentationLibraryLogs, ms.InstrumentationLibraryLogs()) +} + +func TestInstrumentationLibraryLogsSlice(t *testing.T) { + es := NewInstrumentationLibraryLogsSlice() + assert.EqualValues(t, 0, es.Len()) + es = newInstrumentationLibraryLogsSlice(&[]*otlplogs.InstrumentationLibraryLogs{}) + assert.EqualValues(t, 0, es.Len()) + + es.Resize(7) + emptyVal := NewInstrumentationLibraryLogs() + emptyVal.InitEmpty() + testVal := generateTestInstrumentationLibraryLogs() + assert.EqualValues(t, 7, es.Len()) + for i := 0; i < es.Len(); i++ { + assert.EqualValues(t, emptyVal, es.At(i)) + fillTestInstrumentationLibraryLogs(es.At(i)) + assert.EqualValues(t, testVal, es.At(i)) + } +} + +func TestInstrumentationLibraryLogsSlice_MoveAndAppendTo(t *testing.T) { + // Test MoveAndAppendTo to empty + expectedSlice := generateTestInstrumentationLibraryLogsSlice() + dest := NewInstrumentationLibraryLogsSlice() + src := generateTestInstrumentationLibraryLogsSlice() + src.MoveAndAppendTo(dest) + assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + assert.EqualValues(t, 0, src.Len()) + assert.EqualValues(t, expectedSlice.Len(), dest.Len()) + + // Test MoveAndAppendTo empty slice + src.MoveAndAppendTo(dest) + assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + assert.EqualValues(t, 0, src.Len()) + assert.EqualValues(t, expectedSlice.Len(), dest.Len()) + + // Test MoveAndAppendTo not empty slice + generateTestInstrumentationLibraryLogsSlice().MoveAndAppendTo(dest) + assert.EqualValues(t, 2*expectedSlice.Len(), dest.Len()) + for i := 0; i < expectedSlice.Len(); i++ { + assert.EqualValues(t, expectedSlice.At(i), dest.At(i)) + assert.EqualValues(t, expectedSlice.At(i), dest.At(i+expectedSlice.Len())) + } +} + +func TestInstrumentationLibraryLogsSlice_CopyTo(t *testing.T) { + dest := NewInstrumentationLibraryLogsSlice() + // Test CopyTo to empty + NewInstrumentationLibraryLogsSlice().CopyTo(dest) + assert.EqualValues(t, NewInstrumentationLibraryLogsSlice(), dest) + + // Test CopyTo larger slice + generateTestInstrumentationLibraryLogsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + + // Test CopyTo same size slice + generateTestInstrumentationLibraryLogsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) +} + +func TestInstrumentationLibraryLogsSlice_Resize(t *testing.T) { + es := generateTestInstrumentationLibraryLogsSlice() + emptyVal := NewInstrumentationLibraryLogs() + emptyVal.InitEmpty() + // Test Resize less elements. + const resizeSmallLen = 4 + expectedEs := make(map[*otlplogs.InstrumentationLibraryLogs]bool, resizeSmallLen) + for i := 0; i < resizeSmallLen; i++ { + expectedEs[*(es.At(i).orig)] = true + } + assert.EqualValues(t, resizeSmallLen, len(expectedEs)) + es.Resize(resizeSmallLen) + assert.EqualValues(t, resizeSmallLen, es.Len()) + foundEs := make(map[*otlplogs.InstrumentationLibraryLogs]bool, resizeSmallLen) + for i := 0; i < es.Len(); i++ { + foundEs[*(es.At(i).orig)] = true + } + assert.EqualValues(t, expectedEs, foundEs) + + // Test Resize more elements. + const resizeLargeLen = 7 + oldLen := es.Len() + expectedEs = make(map[*otlplogs.InstrumentationLibraryLogs]bool, oldLen) + for i := 0; i < oldLen; i++ { + expectedEs[*(es.At(i).orig)] = true + } + assert.EqualValues(t, oldLen, len(expectedEs)) + es.Resize(resizeLargeLen) + assert.EqualValues(t, resizeLargeLen, es.Len()) + foundEs = make(map[*otlplogs.InstrumentationLibraryLogs]bool, oldLen) + for i := 0; i < oldLen; i++ { + foundEs[*(es.At(i).orig)] = true + } + assert.EqualValues(t, expectedEs, foundEs) + for i := oldLen; i < resizeLargeLen; i++ { + assert.EqualValues(t, emptyVal, es.At(i)) + } + + // Test Resize 0 elements. + es.Resize(0) + assert.EqualValues(t, NewInstrumentationLibraryLogsSlice(), es) +} + +func TestInstrumentationLibraryLogsSlice_Append(t *testing.T) { + es := generateTestInstrumentationLibraryLogsSlice() + emptyVal := NewInstrumentationLibraryLogs() + emptyVal.InitEmpty() + + es.Append(&emptyVal) + assert.EqualValues(t, *(es.At(7)).orig, *emptyVal.orig) + + emptyVal2:= NewInstrumentationLibraryLogs() + emptyVal2.InitEmpty() + + es.Append(&emptyVal2) + assert.EqualValues(t, *(es.At(8)).orig, *emptyVal2.orig) + + assert.Equal(t, 9, es.Len()) +} + +func TestInstrumentationLibraryLogs_InitEmpty(t *testing.T) { + ms := NewInstrumentationLibraryLogs() + assert.True(t, ms.IsNil()) + ms.InitEmpty() + assert.False(t, ms.IsNil()) +} + +func TestInstrumentationLibraryLogs_CopyTo(t *testing.T) { + ms := NewInstrumentationLibraryLogs() + NewInstrumentationLibraryLogs().CopyTo(ms) + assert.True(t, ms.IsNil()) + generateTestInstrumentationLibraryLogs().CopyTo(ms) + assert.EqualValues(t, generateTestInstrumentationLibraryLogs(), ms) +} + +func TestInstrumentationLibraryLogs_InstrumentationLibrary(t *testing.T) { + ms := NewInstrumentationLibraryLogs() + ms.InitEmpty() + assert.EqualValues(t, true, ms.InstrumentationLibrary().IsNil()) + ms.InstrumentationLibrary().InitEmpty() + assert.EqualValues(t, false, ms.InstrumentationLibrary().IsNil()) + fillTestInstrumentationLibrary(ms.InstrumentationLibrary()) + assert.EqualValues(t, generateTestInstrumentationLibrary(), ms.InstrumentationLibrary()) +} + +func TestInstrumentationLibraryLogs_Logs(t *testing.T) { + ms := NewInstrumentationLibraryLogs() + ms.InitEmpty() assert.EqualValues(t, NewLogSlice(), ms.Logs()) fillTestLogSlice(ms.Logs()) testValLogs := generateTestLogSlice() @@ -180,7 +332,7 @@ func TestResourceLogs_Logs(t *testing.T) { func TestLogSlice(t *testing.T) { es := NewLogSlice() assert.EqualValues(t, 0, es.Len()) - es = newLogSlice(&[]*logsproto.LogRecord{}) + es = newLogSlice(&[]*otlplogs.LogRecord{}) assert.EqualValues(t, 0, es.Len()) es.Resize(7) @@ -241,14 +393,14 @@ func TestLogSlice_Resize(t *testing.T) { emptyVal.InitEmpty() // Test Resize less elements. const resizeSmallLen = 4 - expectedEs := make(map[*logsproto.LogRecord]bool, resizeSmallLen) + expectedEs := make(map[*otlplogs.LogRecord]bool, resizeSmallLen) for i := 0; i < resizeSmallLen; i++ { expectedEs[*(es.At(i).orig)] = true } assert.EqualValues(t, resizeSmallLen, len(expectedEs)) es.Resize(resizeSmallLen) assert.EqualValues(t, resizeSmallLen, es.Len()) - foundEs := make(map[*logsproto.LogRecord]bool, resizeSmallLen) + foundEs := make(map[*otlplogs.LogRecord]bool, resizeSmallLen) for i := 0; i < es.Len(); i++ { foundEs[*(es.At(i).orig)] = true } @@ -257,14 +409,14 @@ func TestLogSlice_Resize(t *testing.T) { // Test Resize more elements. const resizeLargeLen = 7 oldLen := es.Len() - expectedEs = make(map[*logsproto.LogRecord]bool, oldLen) + expectedEs = make(map[*otlplogs.LogRecord]bool, oldLen) for i := 0; i < oldLen; i++ { expectedEs[*(es.At(i).orig)] = true } assert.EqualValues(t, oldLen, len(expectedEs)) es.Resize(resizeLargeLen) assert.EqualValues(t, resizeLargeLen, es.Len()) - foundEs = make(map[*logsproto.LogRecord]bool, oldLen) + foundEs = make(map[*otlplogs.LogRecord]bool, oldLen) for i := 0; i < oldLen; i++ { foundEs[*(es.At(i).orig)] = true } @@ -358,28 +510,29 @@ func TestLogRecord_SeverityText(t *testing.T) { func TestLogRecord_SeverityNumber(t *testing.T) { ms := NewLogRecord() ms.InitEmpty() - assert.EqualValues(t, logsproto.SeverityNumber_UNDEFINED_SEVERITY_NUMBER, ms.SeverityNumber()) - testValSeverityNumber := logsproto.SeverityNumber_INFO + assert.EqualValues(t, otlplogs.SeverityNumber_UNDEFINED_SEVERITY_NUMBER, ms.SeverityNumber()) + testValSeverityNumber := otlplogs.SeverityNumber_INFO ms.SetSeverityNumber(testValSeverityNumber) assert.EqualValues(t, testValSeverityNumber, ms.SeverityNumber()) } -func TestLogRecord_ShortName(t *testing.T) { +func TestLogRecord_Name(t *testing.T) { ms := NewLogRecord() ms.InitEmpty() - assert.EqualValues(t, "", ms.ShortName()) - testValShortName := "test_name" - ms.SetShortName(testValShortName) - assert.EqualValues(t, testValShortName, ms.ShortName()) + assert.EqualValues(t, "", ms.Name()) + testValName := "test_name" + ms.SetName(testValName) + assert.EqualValues(t, testValName, ms.Name()) } func TestLogRecord_Body(t *testing.T) { ms := NewLogRecord() ms.InitEmpty() - assert.EqualValues(t, "", ms.Body()) - testValBody := "test log message" - ms.SetBody(testValBody) - assert.EqualValues(t, testValBody, ms.Body()) + assert.EqualValues(t, true, ms.Body().IsNil()) + ms.Body().InitEmpty() + assert.EqualValues(t, false, ms.Body().IsNil()) + fillTestAttributeValue(ms.Body()) + assert.EqualValues(t, generateTestAttributeValue(), ms.Body()) } func TestLogRecord_Attributes(t *testing.T) { @@ -423,6 +576,32 @@ func generateTestResourceLogs() ResourceLogs { func fillTestResourceLogs(tv ResourceLogs) { tv.Resource().InitEmpty() fillTestResource(tv.Resource()) + fillTestInstrumentationLibraryLogsSlice(tv.InstrumentationLibraryLogs()) +} + +func generateTestInstrumentationLibraryLogsSlice() InstrumentationLibraryLogsSlice { + tv := NewInstrumentationLibraryLogsSlice() + fillTestInstrumentationLibraryLogsSlice(tv) + return tv +} + +func fillTestInstrumentationLibraryLogsSlice(tv InstrumentationLibraryLogsSlice) { + tv.Resize(7) + for i := 0; i < tv.Len(); i++ { + fillTestInstrumentationLibraryLogs(tv.At(i)) + } +} + +func generateTestInstrumentationLibraryLogs() InstrumentationLibraryLogs { + tv := NewInstrumentationLibraryLogs() + tv.InitEmpty() + fillTestInstrumentationLibraryLogs(tv) + return tv +} + +func fillTestInstrumentationLibraryLogs(tv InstrumentationLibraryLogs) { + tv.InstrumentationLibrary().InitEmpty() + fillTestInstrumentationLibrary(tv.InstrumentationLibrary()) fillTestLogSlice(tv.Logs()) } @@ -452,9 +631,10 @@ func fillTestLogRecord(tv LogRecord) { tv.SetSpanID(NewSpanID([]byte{1, 2, 3, 4, 5, 6, 7, 8})) tv.SetFlags(uint32(0x01)) tv.SetSeverityText("INFO") - tv.SetSeverityNumber(logsproto.SeverityNumber_INFO) - tv.SetShortName("test_name") - tv.SetBody("test log message") + tv.SetSeverityNumber(otlplogs.SeverityNumber_INFO) + tv.SetName("test_name") + tv.Body().InitEmpty() + fillTestAttributeValue(tv.Body()) fillTestAttributeMap(tv.Attributes()) tv.SetDroppedAttributesCount(uint32(17)) } diff --git a/consumer/pdata/log.go b/consumer/pdata/log.go index f9d58c897ba6..45c7c4df9094 100644 --- a/consumer/pdata/log.go +++ b/consumer/pdata/log.go @@ -14,14 +14,14 @@ package pdata -import logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" +import otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" -// NewResourceLogsSliceFromOrig creates ResourceLogsSlice from logsproto.ResourceLogs. +// NewResourceLogsSliceFromOrig creates ResourceLogsSlice from otlplogs.ResourceLogs. // This function simply makes generated newResourceLogsSlice() function publicly // available for internal.data.Log to call. We intentionally placed data.Log in the // internal package so that it is not available publicly while it is experimental. -// Once the expriment is over data.Log should move to this package (pdata) and +// Once the experiment is over data.Log should move to this package (pdata) and // NewResourceLogsSliceFromOrig function will no longer be needed. -func NewResourceLogsSliceFromOrig(orig *[]*logsproto.ResourceLogs) ResourceLogsSlice { +func NewResourceLogsSliceFromOrig(orig *[]*otlplogs.ResourceLogs) ResourceLogsSlice { return ResourceLogsSlice{orig} } diff --git a/exporter/fileexporter/file_exporter.go b/exporter/fileexporter/file_exporter.go index f1f647be09dd..75705ec792d6 100644 --- a/exporter/fileexporter/file_exporter.go +++ b/exporter/fileexporter/file_exporter.go @@ -225,10 +225,13 @@ func (e *Exporter) ConsumeLogs(ctx context.Context, ld data.Logs) error { return err } - for _, log := range rl.Logs { - if log != nil { - if err := jw.MarshalArrayItem(log); err != nil { - return err + for _, ill := range rl.InstrumentationLibraryLogs { + // TODO: output ill.InstrumentationLibrary + for _, log := range ill.Logs { + if log != nil { + if err := jw.MarshalArrayItem(log); err != nil { + return err + } } } } diff --git a/exporter/fileexporter/file_exporter_test.go b/exporter/fileexporter/file_exporter_test.go index b3c5cfbbe280..3e7930ef7892 100644 --- a/exporter/fileexporter/file_exporter_test.go +++ b/exporter/fileexporter/file_exporter_test.go @@ -177,14 +177,18 @@ func TestFileLogsExporterNoErrors(t *testing.T) { }, }, }, - Logs: []*logspb.LogRecord{ + InstrumentationLibraryLogs: []*logspb.InstrumentationLibraryLogs{ { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logA", - }, - { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logB", + Logs: []*logspb.LogRecord{ + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logA", + }, + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logB", + }, + }, }, }, }, @@ -197,10 +201,14 @@ func TestFileLogsExporterNoErrors(t *testing.T) { }, }, }, - Logs: []*logspb.LogRecord{ + InstrumentationLibraryLogs: []*logspb.InstrumentationLibraryLogs{ { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logC", + Logs: []*logspb.LogRecord{ + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logC", + }, + }, }, }, }, @@ -226,12 +234,12 @@ func TestFileLogsExporterNoErrors(t *testing.T) { }, "logs": []interface{}{ map[string]interface{}{ - "timestampUnixNano": strconv.Itoa(int(now.UnixNano())), - "shortName": "logA", + "timeUnixNano": strconv.Itoa(int(now.UnixNano())), + "name": "logA", }, map[string]interface{}{ - "timestampUnixNano": strconv.Itoa(int(now.UnixNano())), - "shortName": "logB", + "timeUnixNano": strconv.Itoa(int(now.UnixNano())), + "name": "logB", }, }, }, j) @@ -252,8 +260,8 @@ func TestFileLogsExporterNoErrors(t *testing.T) { }, "logs": []interface{}{ map[string]interface{}{ - "timestampUnixNano": strconv.Itoa(int(now.UnixNano())), - "shortName": "logC", + "timeUnixNano": strconv.Itoa(int(now.UnixNano())), + "name": "logC", }, }, }, j) @@ -272,14 +280,18 @@ func TestFileLogsExporterErrors(t *testing.T) { }, }, }, - Logs: []*logspb.LogRecord{ + InstrumentationLibraryLogs: []*logspb.InstrumentationLibraryLogs{ { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logA", - }, - { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logB", + Logs: []*logspb.LogRecord{ + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logA", + }, + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logB", + }, + }, }, }, }, @@ -292,10 +304,14 @@ func TestFileLogsExporterErrors(t *testing.T) { }, }, }, - Logs: []*logspb.LogRecord{ + InstrumentationLibraryLogs: []*logspb.InstrumentationLibraryLogs{ { - TimestampUnixNano: uint64(now.UnixNano()), - ShortName: "logC", + Logs: []*logspb.LogRecord{ + { + TimeUnixNano: uint64(now.UnixNano()), + Name: "logC", + }, + }, }, }, }, diff --git a/exporter/loggingexporter/logging_exporter.go b/exporter/loggingexporter/logging_exporter.go index eae98d3aa1b2..7491574a129d 100644 --- a/exporter/loggingexporter/logging_exporter.go +++ b/exporter/loggingexporter/logging_exporter.go @@ -215,8 +215,8 @@ func (b *logDataBuffer) logDataPointLabels(labels pdata.StringMap) { func (b *logDataBuffer) logLogRecord(lr pdata.LogRecord) { b.logEntry("Timestamp: %d", lr.Timestamp()) b.logEntry("Severity: %s", lr.SeverityText()) - b.logEntry("ShortName: %s", lr.ShortName()) - b.logEntry("Body: %s", lr.Body()) + b.logEntry("ShortName: %s", lr.Name()) + b.logEntry("Body: %s", attributeValueToString(lr.Body())) b.logAttributeMap("Attributes", lr.Attributes()) } @@ -438,26 +438,40 @@ func (s *loggingExporter) pushLogData( } buf := logDataBuffer{} - rms := ld.ResourceLogs() - for i := 0; i < rms.Len(); i++ { + rls := ld.ResourceLogs() + for i := 0; i < rls.Len(); i++ { buf.logEntry("ResourceLog #%d", i) - rm := rms.At(i) - if rm.IsNil() { + rl := rls.At(i) + if rl.IsNil() { buf.logEntry("* Nil ResourceLog") continue } - if !rm.Resource().IsNil() { - buf.logAttributeMap("Resource labels", rm.Resource().Attributes()) + if !rl.Resource().IsNil() { + buf.logAttributeMap("Resource labels", rl.Resource().Attributes()) } - lrs := rm.Logs() - for j := 0; j < lrs.Len(); j++ { - buf.logEntry("LogRecord #%d", j) - lr := lrs.At(j) - if lr.IsNil() { - buf.logEntry("* Nil LogRecord") + + ills := rl.InstrumentationLibraryLogs() + for j := 0; j < ills.Len(); j++ { + buf.logEntry("InstrumentationLibraryLogs #%d", j) + ils := ills.At(j) + if ils.IsNil() { + buf.logEntry("* Nil InstrumentationLibraryLogs") continue } - buf.logLogRecord(lr) + if !ils.InstrumentationLibrary().IsNil() { + buf.logInstrumentationLibrary(ils.InstrumentationLibrary()) + } + + logs := ils.Logs() + for j := 0; j < logs.Len(); j++ { + buf.logEntry("LogRecord #%d", j) + lr := logs.At(j) + if lr.IsNil() { + buf.logEntry("* Nil LogRecord") + continue + } + buf.logLogRecord(lr) + } } } diff --git a/exporter/otlpexporter/otlp.go b/exporter/otlpexporter/otlp.go index b2a58abab6de..f0c33704fcb6 100644 --- a/exporter/otlpexporter/otlp.go +++ b/exporter/otlpexporter/otlp.go @@ -33,9 +33,9 @@ import ( "go.opentelemetry.io/collector/consumer/pdata" "go.opentelemetry.io/collector/consumer/pdatautil" "go.opentelemetry.io/collector/internal/data" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/logs/v1" otlpmetrics "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/metrics/v1" otlptrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/trace/v1" - otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) type exporterImp struct { @@ -49,7 +49,7 @@ type exporterImp struct { type sender interface { exportTrace(ctx context.Context, request *otlptrace.ExportTraceServiceRequest) error exportMetrics(ctx context.Context, request *otlpmetrics.ExportMetricsServiceRequest) error - exportLogs(ctx context.Context, request *otlplogs.ExportLogServiceRequest) error + exportLogs(ctx context.Context, request *otlplogs.ExportLogsServiceRequest) error stop() error } @@ -112,7 +112,7 @@ func (e *exporterImp) pushMetricsData(ctx context.Context, md pdata.Metrics) (in } func (e *exporterImp) pushLogData(ctx context.Context, logs data.Logs) (int, error) { - request := &otlplogs.ExportLogServiceRequest{ + request := &otlplogs.ExportLogsServiceRequest{ ResourceLogs: data.LogsToProto(logs), } err := e.w.exportLogs(ctx, request) @@ -127,7 +127,7 @@ type grpcSender struct { // gRPC clients and connection. traceExporter otlptrace.TraceServiceClient metricExporter otlpmetrics.MetricsServiceClient - logExporter otlplogs.LogServiceClient + logExporter otlplogs.LogsServiceClient grpcClientConn *grpc.ClientConn metadata metadata.MD waitForReady bool @@ -147,7 +147,7 @@ func newGrpcSender(config *Config) (sender, error) { gs := &grpcSender{ traceExporter: otlptrace.NewTraceServiceClient(clientConn), metricExporter: otlpmetrics.NewMetricsServiceClient(clientConn), - logExporter: otlplogs.NewLogServiceClient(clientConn), + logExporter: otlplogs.NewLogsServiceClient(clientConn), grpcClientConn: clientConn, metadata: metadata.New(config.GRPCClientSettings.Headers), waitForReady: config.GRPCClientSettings.WaitForReady, @@ -173,7 +173,7 @@ func (gs *grpcSender) exportMetrics(ctx context.Context, request *otlpmetrics.Ex }) } -func (gs *grpcSender) exportLogs(ctx context.Context, request *otlplogs.ExportLogServiceRequest) error { +func (gs *grpcSender) exportLogs(ctx context.Context, request *otlplogs.ExportLogsServiceRequest) error { return exportRequest(gs.enhanceContext(ctx), func(ctx context.Context) error { _, err := gs.logExporter.Export(ctx, request, grpc.WaitForReady(gs.waitForReady)) return err diff --git a/exporter/otlpexporter/otlp_test.go b/exporter/otlpexporter/otlp_test.go index 0a9f40b5fd43..b32d03a885df 100644 --- a/exporter/otlpexporter/otlp_test.go +++ b/exporter/otlpexporter/otlp_test.go @@ -32,8 +32,8 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/consumer/pdata" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/logs/v1" otlptracecol "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/trace/v1" - otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" "go.opentelemetry.io/collector/internal/data/testdata" "go.opentelemetry.io/collector/obsreport" "go.opentelemetry.io/collector/testutil" @@ -81,18 +81,20 @@ type mockLogsReceiver struct { srv *grpc.Server requestCount int32 totalLogRecordCount int32 - lastRequest *otlplogs.ExportLogServiceRequest + lastRequest *otlplogs.ExportLogsServiceRequest } -func (r *mockLogsReceiver) Export(ctx context.Context, req *otlplogs.ExportLogServiceRequest) (*otlplogs.ExportLogServiceResponse, error) { +func (r *mockLogsReceiver) Export(ctx context.Context, req *otlplogs.ExportLogsServiceRequest) (*otlplogs.ExportLogsServiceResponse, error) { atomic.AddInt32(&r.requestCount, 1) recordCount := 0 for _, rs := range req.ResourceLogs { - recordCount += len(rs.Logs) + for _, il := range rs.InstrumentationLibraryLogs { + recordCount += len(il.Logs) + } } atomic.AddInt32(&r.totalLogRecordCount, int32(recordCount)) r.lastRequest = req - return &otlplogs.ExportLogServiceResponse{}, nil + return &otlplogs.ExportLogsServiceResponse{}, nil } func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver { @@ -100,7 +102,7 @@ func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver { // Now run it as a gRPC server rcv.srv = obsreport.GRPCServerWithObservabilityEnabled() - otlplogs.RegisterLogServiceServer(rcv.srv, rcv) + otlplogs.RegisterLogsServiceServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -365,7 +367,7 @@ func TestSendLogData(t *testing.T) { // A request with 2 log entries. td = testdata.GenerateLogDataTwoLogsSameResource() - expectedOTLPReq := &otlplogs.ExportLogServiceRequest{ + expectedOTLPReq := &otlplogs.ExportLogsServiceRequest{ ResourceLogs: testdata.GenerateLogOtlpSameResourceTwoLogs(), } diff --git a/internal/data/log.go b/internal/data/log.go index 0b13d8b0aa7e..644623de0162 100644 --- a/internal/data/log.go +++ b/internal/data/log.go @@ -17,7 +17,7 @@ import ( "github.com/gogo/protobuf/proto" "go.opentelemetry.io/collector/consumer/pdata" - logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) // This file defines in-memory data structures to represent logs. @@ -29,32 +29,32 @@ import ( // Must use NewLogs functions to create new instances. // Important: zero-initialized instance is not valid for use. type Logs struct { - orig *[]*logsproto.ResourceLogs + orig *[]*otlplogs.ResourceLogs } // LogsFromProto creates the internal Logs representation from the ProtoBuf. -func LogsFromProto(orig []*logsproto.ResourceLogs) Logs { +func LogsFromProto(orig []*otlplogs.ResourceLogs) Logs { return Logs{&orig} } // LogsToProto converts the internal Logs to the ProtoBuf. -func LogsToProto(ld Logs) []*logsproto.ResourceLogs { +func LogsToProto(ld Logs) []*otlplogs.ResourceLogs { return *ld.orig } // NewLogs creates a new Logs. func NewLogs() Logs { - orig := []*logsproto.ResourceLogs(nil) + orig := []*otlplogs.ResourceLogs(nil) return Logs{&orig} } // Clone returns a copy of Logs. func (ld Logs) Clone() Logs { otlp := LogsToProto(ld) - resourceSpansClones := make([]*logsproto.ResourceLogs, 0, len(otlp)) + resourceSpansClones := make([]*otlplogs.ResourceLogs, 0, len(otlp)) for _, resourceSpans := range otlp { resourceSpansClones = append(resourceSpansClones, - proto.Clone(resourceSpans).(*logsproto.ResourceLogs)) + proto.Clone(resourceSpans).(*otlplogs.ResourceLogs)) } return LogsFromProto(resourceSpansClones) } @@ -68,7 +68,15 @@ func (ld Logs) LogRecordCount() int { if rs.IsNil() { continue } - logCount += rs.Logs().Len() + + ill := rs.InstrumentationLibraryLogs() + for i := 0; i < ill.Len(); i++ { + logs := ill.At(i) + if logs.IsNil() { + continue + } + logCount += logs.Logs().Len() + } } return logCount } diff --git a/internal/data/log_test.go b/internal/data/log_test.go index 4bb5b657340d..c18d630fd704 100644 --- a/internal/data/log_test.go +++ b/internal/data/log_test.go @@ -19,7 +19,7 @@ import ( "github.com/stretchr/testify/assert" - logsproto "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" + otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) func TestLogRecordCount(t *testing.T) { @@ -29,28 +29,42 @@ func TestLogRecordCount(t *testing.T) { md.ResourceLogs().Resize(1) assert.EqualValues(t, 0, md.LogRecordCount()) - md.ResourceLogs().At(0).Logs().Resize(1) + md.ResourceLogs().At(0).InstrumentationLibraryLogs().Resize(1) + assert.EqualValues(t, 0, md.LogRecordCount()) + + md.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).Logs().Resize(1) assert.EqualValues(t, 1, md.LogRecordCount()) rms := md.ResourceLogs() rms.Resize(3) - rms.At(0).Logs().Resize(1) - rms.At(1).Logs().Resize(1) - rms.At(2).Logs().Resize(4) + rms.At(0).InstrumentationLibraryLogs().Resize(1) + rms.At(0).InstrumentationLibraryLogs().At(0).Logs().Resize(1) + rms.At(1).InstrumentationLibraryLogs().Resize(1) + rms.At(2).InstrumentationLibraryLogs().Resize(1) + rms.At(2).InstrumentationLibraryLogs().At(0).Logs().Resize(5) assert.EqualValues(t, 6, md.LogRecordCount()) } func TestLogRecordCountWithNils(t *testing.T) { - assert.EqualValues(t, 0, LogsFromProto([]*logsproto.ResourceLogs{nil, {}}).LogRecordCount()) - assert.EqualValues(t, 2, LogsFromProto([]*logsproto.ResourceLogs{ + assert.EqualValues(t, 0, LogsFromProto([]*otlplogs.ResourceLogs{nil, {}}).LogRecordCount()) + assert.EqualValues(t, 0, LogsFromProto([]*otlplogs.ResourceLogs{ + { + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{nil, {}}, + }, + }).LogRecordCount()) + assert.EqualValues(t, 2, LogsFromProto([]*otlplogs.ResourceLogs{ { - Logs: []*logsproto.LogRecord{nil, {}}, + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{nil, {}}, + }, + }, }, }).LogRecordCount()) } func TestToFromLogProto(t *testing.T) { - otlp := []*logsproto.ResourceLogs(nil) + otlp := []*otlplogs.ResourceLogs(nil) td := LogsFromProto(otlp) assert.EqualValues(t, NewLogs(), td) assert.EqualValues(t, otlp, LogsToProto(td)) diff --git a/internal/data/logsproto/logs/v1/logs.proto b/internal/data/logsproto/logs/v1/logs.proto deleted file mode 100644 index fbce7e1301b2..000000000000 --- a/internal/data/logsproto/logs/v1/logs.proto +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This proto is part of experiment Logs ProtoBuf definition. This file should be removed -// once the logs are added to OTLP. -// The ProtoBuf implements OpenTelemetry Log Data Model: -// https://github.com/open-telemetry/oteps/blob/master/text/0097-log-data-model.md - -syntax = "proto3"; - -package logsproto; - -import "opentelemetry/proto/common/v1/common.proto"; -import "opentelemetry/proto/resource/v1/resource.proto"; - -option go_package = "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"; - -// Service that can be used to push logs between one Application instrumented with -// OpenTelemetry and an collector, or between an collector and a central collector (in this -// case logs are sent/received to/from multiple Applications). -service LogService { - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - rpc Export(ExportLogServiceRequest) returns (ExportLogServiceResponse) {} -} - -message ExportLogServiceRequest { - // An array of ResourceLogs. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - repeated ResourceLogs resource_logs = 1; -} - -message ExportLogServiceResponse { -} - -// A collection of logs from a Resource. -message ResourceLogs { - // The resource for the logs in this message. - // If this field is not set then no resource info is known. - opentelemetry.proto.resource.v1.Resource resource = 1; - - repeated LogRecord logs = 2; -} - -enum SeverityNumber { - UNDEFINED_SEVERITY_NUMBER = 0; - TRACE = 1; - TRACE2 = 2; - TRACE3 = 3; - TRACE4 = 4; - DEBUG = 5; - DEBUG2 = 6; - DEBUG3 = 7; - DEBUG4 = 8; - INFO = 9; - INFO2 = 10; - INFO3 = 11; - INFO4 = 12; - WARN = 13; - WARN2 = 14; - WARN3 = 15; - WARN4 = 16; - ERROR = 17; - ERROR2 = 18; - ERROR3 = 19; - ERROR4 = 20; - FATAL = 21; - FATAL2 = 22; - FATAL3 = 23; - FATAL4 = 24; -} - -enum LogRecordFlags { - UNDEFINED_LOG_RECORD_FLAG = 0; - TRACE_FLAGS_MASK = 0x000000FF; -} - -message LogRecord { - // timestamp_unix_nano is the time when the event occurred. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // Value of 0 indicates unknown or missing timestamp. - fixed64 timestamp_unix_nano = 1; - - // A unique identifier for a trace. All logs from the same trace share - // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes - // is considered invalid. Can be set for logs that are part of request processing - // and have an assigned trace id. Optional. - bytes trace_id = 2; - - // A unique identifier for a span within a trace, assigned when the span - // is created. The ID is an 8-byte array. An ID with all zeroes is considered - // invalid. Can be set for logs that are part of a particular processing span. - // If span_id is present trace_id SHOULD be also present. Optional. - bytes span_id = 3; - - // Optional flags, a bit field. 8 least significant bits are the trace flags as - // defined in W3C Trace Context specification. 24 most significant bits are reserved - // and must be set to 0. Readers that must not assume that 24 most significant bits - // will be zero and must correctly mask the bits when reading 8-bit trace flag (use - // flags & TRACE_FLAGS_MASK). Optional. - uint32 flags = 4; - - // Numerical value of the severity, normalized to values described in - // https://github.com/open-telemetry/oteps/pull/97. Optional. - SeverityNumber severity_number = 5; - - // The severity text (also known as log level). The original string representation as - // it is known at the source. Optional. - string severity_text = 6; - - // Short event identifier that does not contain varying parts. ShortName describes - // what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - // characters. Not guaranteed to be unique in any way. Optional. - string short_name = 7; - - // A value containing the body of the log record. Can be for example a human-readable - // string message (including multi-line) describing the event in a free form or it can - // be a structured data composed of arrays and maps of other values. Optional. - // TODO: According to Log Data Model this must be of 'any' type, but we are not yet - // capable of representing it in memory so we are using string temporarily. - string body = 8; - - // Additional attributes that describe the specific event occurrence. Optional. - repeated opentelemetry.proto.common.v1.KeyValue attributes = 9; - uint32 dropped_attributes_count = 10; -} diff --git a/internal/data/opentelemetry-proto b/internal/data/opentelemetry-proto index e43e1abc4042..1d26e5268279 160000 --- a/internal/data/opentelemetry-proto +++ b/internal/data/opentelemetry-proto @@ -1 +1 @@ -Subproject commit e43e1abc40428a6ee98e3bfd79bec1dfa2ed18cd +Subproject commit 1d26e5268279d34ffd64bb99fe99d8b5d704df17 diff --git a/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.go b/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.go new file mode 100644 index 000000000000..159db48ceb67 --- /dev/null +++ b/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.go @@ -0,0 +1,555 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: opentelemetry/proto/collector/logs/v1/logs_service.proto + +package v1 + +import ( + context "context" + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ExportLogsServiceRequest struct { + // An array of ResourceLogs. + // For data coming from a single resource this array will typically contain one + // element. Intermediary nodes (such as OpenTelemetry Collector) that receive + // data from multiple origins typically batch the data before forwarding further and + // in that case this array will contain multiple elements. + ResourceLogs []*v1.ResourceLogs `protobuf:"bytes,1,rep,name=resource_logs,json=resourceLogs,proto3" json:"resource_logs,omitempty"` +} + +func (m *ExportLogsServiceRequest) Reset() { *m = ExportLogsServiceRequest{} } +func (m *ExportLogsServiceRequest) String() string { return proto.CompactTextString(m) } +func (*ExportLogsServiceRequest) ProtoMessage() {} +func (*ExportLogsServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8e3bf87aaa43acd4, []int{0} +} +func (m *ExportLogsServiceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExportLogsServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExportLogsServiceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExportLogsServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExportLogsServiceRequest.Merge(m, src) +} +func (m *ExportLogsServiceRequest) XXX_Size() int { + return m.Size() +} +func (m *ExportLogsServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ExportLogsServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ExportLogsServiceRequest proto.InternalMessageInfo + +func (m *ExportLogsServiceRequest) GetResourceLogs() []*v1.ResourceLogs { + if m != nil { + return m.ResourceLogs + } + return nil +} + +type ExportLogsServiceResponse struct { +} + +func (m *ExportLogsServiceResponse) Reset() { *m = ExportLogsServiceResponse{} } +func (m *ExportLogsServiceResponse) String() string { return proto.CompactTextString(m) } +func (*ExportLogsServiceResponse) ProtoMessage() {} +func (*ExportLogsServiceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8e3bf87aaa43acd4, []int{1} +} +func (m *ExportLogsServiceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExportLogsServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExportLogsServiceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExportLogsServiceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExportLogsServiceResponse.Merge(m, src) +} +func (m *ExportLogsServiceResponse) XXX_Size() int { + return m.Size() +} +func (m *ExportLogsServiceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ExportLogsServiceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ExportLogsServiceResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ExportLogsServiceRequest)(nil), "opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest") + proto.RegisterType((*ExportLogsServiceResponse)(nil), "opentelemetry.proto.collector.logs.v1.ExportLogsServiceResponse") +} + +func init() { + proto.RegisterFile("opentelemetry/proto/collector/logs/v1/logs_service.proto", fileDescriptor_8e3bf87aaa43acd4) +} + +var fileDescriptor_8e3bf87aaa43acd4 = []byte{ + // 291 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0xc8, 0x2f, 0x48, 0xcd, + 0x2b, 0x49, 0xcd, 0x49, 0xcd, 0x4d, 0x2d, 0x29, 0xaa, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, + 0x4f, 0xce, 0xcf, 0xc9, 0x49, 0x4d, 0x2e, 0xc9, 0x2f, 0xd2, 0xcf, 0xc9, 0x4f, 0x2f, 0xd6, 0x2f, + 0x33, 0x04, 0xd3, 0xf1, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7a, 0x60, 0x45, 0x42, 0xaa, + 0x28, 0x3a, 0x21, 0x82, 0x7a, 0x70, 0x9d, 0x7a, 0x20, 0x1d, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0xd8, + 0x2c, 0x40, 0x36, 0x16, 0xa2, 0x53, 0x29, 0x8b, 0x4b, 0xc2, 0xb5, 0xa2, 0x20, 0xbf, 0xa8, 0xc4, + 0x27, 0x3f, 0xbd, 0x38, 0x18, 0x62, 0x53, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x1f, + 0x17, 0x6f, 0x51, 0x6a, 0x71, 0x7e, 0x69, 0x51, 0x72, 0x6a, 0x3c, 0x48, 0x8b, 0x04, 0xa3, 0x02, + 0xb3, 0x06, 0xb7, 0x91, 0xa6, 0x1e, 0x36, 0x27, 0x40, 0x2d, 0xd6, 0x0b, 0x82, 0xea, 0x00, 0x99, + 0x17, 0xc4, 0x53, 0x84, 0xc4, 0x53, 0x92, 0xe6, 0x92, 0xc4, 0x62, 0x57, 0x71, 0x41, 0x7e, 0x5e, + 0x71, 0xaa, 0xd1, 0x5c, 0x46, 0x2e, 0x6e, 0x24, 0x71, 0xa1, 0x5e, 0x46, 0x2e, 0x36, 0x88, 0x6a, + 0x21, 0x7b, 0x3d, 0xa2, 0xfc, 0xac, 0x87, 0xcb, 0x23, 0x52, 0x0e, 0xe4, 0x1b, 0x00, 0x71, 0x9d, + 0x12, 0x83, 0xd3, 0x5a, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, + 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0xe0, 0xd2, + 0xc8, 0xcc, 0x27, 0xce, 0x02, 0x27, 0x01, 0x24, 0xb3, 0x03, 0x40, 0x6a, 0x02, 0x18, 0xa3, 0x42, + 0xd3, 0xd1, 0x75, 0x67, 0x22, 0x27, 0x85, 0xcc, 0xbc, 0x92, 0xd4, 0xa2, 0xbc, 0xc4, 0x1c, 0xfd, + 0x94, 0xc4, 0x92, 0x44, 0x7d, 0x14, 0x85, 0xba, 0x60, 0x6b, 0x74, 0xd3, 0x53, 0xf3, 0x30, 0x93, + 0x4e, 0x12, 0x1b, 0x58, 0xd2, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x0e, 0x9d, 0x24, 0x6a, + 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// LogsServiceClient is the client API for LogsService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type LogsServiceClient interface { + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(ctx context.Context, in *ExportLogsServiceRequest, opts ...grpc.CallOption) (*ExportLogsServiceResponse, error) +} + +type logsServiceClient struct { + cc *grpc.ClientConn +} + +func NewLogsServiceClient(cc *grpc.ClientConn) LogsServiceClient { + return &logsServiceClient{cc} +} + +func (c *logsServiceClient) Export(ctx context.Context, in *ExportLogsServiceRequest, opts ...grpc.CallOption) (*ExportLogsServiceResponse, error) { + out := new(ExportLogsServiceResponse) + err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.logs.v1.LogsService/Export", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LogsServiceServer is the server API for LogsService service. +type LogsServiceServer interface { + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(context.Context, *ExportLogsServiceRequest) (*ExportLogsServiceResponse, error) +} + +// UnimplementedLogsServiceServer can be embedded to have forward compatible implementations. +type UnimplementedLogsServiceServer struct { +} + +func (*UnimplementedLogsServiceServer) Export(ctx context.Context, req *ExportLogsServiceRequest) (*ExportLogsServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +} + +func RegisterLogsServiceServer(s *grpc.Server, srv LogsServiceServer) { + s.RegisterService(&_LogsService_serviceDesc, srv) +} + +func _LogsService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExportLogsServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LogsServiceServer).Export(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LogsServiceServer).Export(ctx, req.(*ExportLogsServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _LogsService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "opentelemetry.proto.collector.logs.v1.LogsService", + HandlerType: (*LogsServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Export", + Handler: _LogsService_Export_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "opentelemetry/proto/collector/logs/v1/logs_service.proto", +} + +func (m *ExportLogsServiceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExportLogsServiceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExportLogsServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ResourceLogs) > 0 { + for iNdEx := len(m.ResourceLogs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ResourceLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLogsService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ExportLogsServiceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExportLogsServiceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExportLogsServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintLogsService(dAtA []byte, offset int, v uint64) int { + offset -= sovLogsService(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExportLogsServiceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ResourceLogs) > 0 { + for _, e := range m.ResourceLogs { + l = e.Size() + n += 1 + l + sovLogsService(uint64(l)) + } + } + return n +} + +func (m *ExportLogsServiceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovLogsService(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLogsService(x uint64) (n int) { + return sovLogsService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExportLogsServiceRequest) Unmarshal(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 ErrIntOverflowLogsService + } + 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: ExportLogsServiceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExportLogsServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogsService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogsService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLogsService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceLogs = append(m.ResourceLogs, &v1.ResourceLogs{}) + if err := m.ResourceLogs[len(m.ResourceLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogsService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogsService + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthLogsService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExportLogsServiceResponse) Unmarshal(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 ErrIntOverflowLogsService + } + 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: ExportLogsServiceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExportLogsServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipLogsService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogsService + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthLogsService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLogsService(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogsService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogsService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogsService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthLogsService + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLogsService + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLogsService + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLogsService = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLogsService = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLogsService = fmt.Errorf("proto: unexpected end of group") +) diff --git a/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.gw.go b/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.gw.go new file mode 100644 index 000000000000..8003733add00 --- /dev/null +++ b/internal/data/opentelemetry-proto-gen/collector/logs/v1/logs_service.pb.gw.go @@ -0,0 +1,163 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: opentelemetry/proto/collector/logs/v1/logs_service.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_LogsService_Export_0(ctx context.Context, marshaler runtime.Marshaler, client LogsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ExportLogsServiceRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Export(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_LogsService_Export_0(ctx context.Context, marshaler runtime.Marshaler, server LogsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ExportLogsServiceRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Export(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterLogsServiceHandlerServer registers the http handlers for service LogsService to "mux". +// UnaryRPC :call LogsServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterLogsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LogsServiceServer) error { + + mux.Handle("POST", pattern_LogsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LogsService_Export_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_LogsService_Export_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterLogsServiceHandlerFromEndpoint is same as RegisterLogsServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterLogsServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterLogsServiceHandler(ctx, mux, conn) +} + +// RegisterLogsServiceHandler registers the http handlers for service LogsService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterLogsServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterLogsServiceHandlerClient(ctx, mux, NewLogsServiceClient(conn)) +} + +// RegisterLogsServiceHandlerClient registers the http handlers for service LogsService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LogsServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LogsServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "LogsServiceClient" to call the correct interceptors. +func RegisterLogsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LogsServiceClient) error { + + mux.Handle("POST", pattern_LogsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LogsService_Export_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_LogsService_Export_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_LogsService_Export_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "logs"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_LogsService_Export_0 = runtime.ForwardResponseMessage +) diff --git a/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go b/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go index 3beadd7dcb93..c5ee9f66d0eb 100644 --- a/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go +++ b/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go @@ -1,18 +1,14 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: logs/v1/logs.proto +// source: opentelemetry/proto/logs/v1/logs.proto package v1 import ( - context "context" encoding_binary "encoding/binary" fmt "fmt" proto "github.com/gogo/protobuf/proto" v11 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/resource/v1" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -29,6 +25,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// Possible values for LogRecord.SeverityNumber. type SeverityNumber int32 const ( @@ -120,9 +117,10 @@ func (x SeverityNumber) String() string { } func (SeverityNumber) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{0} + return fileDescriptor_d1c030a3ec7e961e, []int{0} } +// Masks for LogRecord.flags field. type LogRecordFlags int32 const ( @@ -145,30 +143,30 @@ func (x LogRecordFlags) String() string { } func (LogRecordFlags) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{1} + return fileDescriptor_d1c030a3ec7e961e, []int{1} } -type ExportLogServiceRequest struct { - // An array of ResourceLogs. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - ResourceLogs []*ResourceLogs `protobuf:"bytes,1,rep,name=resource_logs,json=resourceLogs,proto3" json:"resource_logs,omitempty"` +// A collection of InstrumentationLibraryLogs from a Resource. +type ResourceLogs struct { + // The resource for the logs in this message. + // If this field is not set then no resource info is known. + Resource *v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + // A list of InstrumentationLibraryLogs that originate from a resource. + InstrumentationLibraryLogs []*InstrumentationLibraryLogs `protobuf:"bytes,2,rep,name=instrumentation_library_logs,json=instrumentationLibraryLogs,proto3" json:"instrumentation_library_logs,omitempty"` } -func (m *ExportLogServiceRequest) Reset() { *m = ExportLogServiceRequest{} } -func (m *ExportLogServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExportLogServiceRequest) ProtoMessage() {} -func (*ExportLogServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{0} +func (m *ResourceLogs) Reset() { *m = ResourceLogs{} } +func (m *ResourceLogs) String() string { return proto.CompactTextString(m) } +func (*ResourceLogs) ProtoMessage() {} +func (*ResourceLogs) Descriptor() ([]byte, []int) { + return fileDescriptor_d1c030a3ec7e961e, []int{0} } -func (m *ExportLogServiceRequest) XXX_Unmarshal(b []byte) error { +func (m *ResourceLogs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ExportLogServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ResourceLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ExportLogServiceRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_ResourceLogs.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -178,81 +176,53 @@ func (m *ExportLogServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *ExportLogServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportLogServiceRequest.Merge(m, src) +func (m *ResourceLogs) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceLogs.Merge(m, src) } -func (m *ExportLogServiceRequest) XXX_Size() int { +func (m *ResourceLogs) XXX_Size() int { return m.Size() } -func (m *ExportLogServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExportLogServiceRequest.DiscardUnknown(m) +func (m *ResourceLogs) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceLogs.DiscardUnknown(m) } -var xxx_messageInfo_ExportLogServiceRequest proto.InternalMessageInfo +var xxx_messageInfo_ResourceLogs proto.InternalMessageInfo -func (m *ExportLogServiceRequest) GetResourceLogs() []*ResourceLogs { +func (m *ResourceLogs) GetResource() *v1.Resource { if m != nil { - return m.ResourceLogs + return m.Resource } return nil } -type ExportLogServiceResponse struct { -} - -func (m *ExportLogServiceResponse) Reset() { *m = ExportLogServiceResponse{} } -func (m *ExportLogServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExportLogServiceResponse) ProtoMessage() {} -func (*ExportLogServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{1} -} -func (m *ExportLogServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportLogServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportLogServiceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *ResourceLogs) GetInstrumentationLibraryLogs() []*InstrumentationLibraryLogs { + if m != nil { + return m.InstrumentationLibraryLogs } -} -func (m *ExportLogServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportLogServiceResponse.Merge(m, src) -} -func (m *ExportLogServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *ExportLogServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExportLogServiceResponse.DiscardUnknown(m) + return nil } -var xxx_messageInfo_ExportLogServiceResponse proto.InternalMessageInfo - -// A collection of logs from a Resource. -type ResourceLogs struct { - // The resource for the logs in this message. - // If this field is not set then no resource info is known. - Resource *v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` - Logs []*LogRecord `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` +// A collection of Logs produced by an InstrumentationLibrary. +type InstrumentationLibraryLogs struct { + // The instrumentation library information for the logs in this message. + // If this field is not set then no library info is known. + InstrumentationLibrary *v11.InstrumentationLibrary `protobuf:"bytes,1,opt,name=instrumentation_library,json=instrumentationLibrary,proto3" json:"instrumentation_library,omitempty"` + // A list of log records. + Logs []*LogRecord `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` } -func (m *ResourceLogs) Reset() { *m = ResourceLogs{} } -func (m *ResourceLogs) String() string { return proto.CompactTextString(m) } -func (*ResourceLogs) ProtoMessage() {} -func (*ResourceLogs) Descriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{2} +func (m *InstrumentationLibraryLogs) Reset() { *m = InstrumentationLibraryLogs{} } +func (m *InstrumentationLibraryLogs) String() string { return proto.CompactTextString(m) } +func (*InstrumentationLibraryLogs) ProtoMessage() {} +func (*InstrumentationLibraryLogs) Descriptor() ([]byte, []int) { + return fileDescriptor_d1c030a3ec7e961e, []int{1} } -func (m *ResourceLogs) XXX_Unmarshal(b []byte) error { +func (m *InstrumentationLibraryLogs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ResourceLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InstrumentationLibraryLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ResourceLogs.Marshal(b, m, deterministic) + return xxx_messageInfo_InstrumentationLibraryLogs.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -262,79 +232,79 @@ func (m *ResourceLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *ResourceLogs) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResourceLogs.Merge(m, src) +func (m *InstrumentationLibraryLogs) XXX_Merge(src proto.Message) { + xxx_messageInfo_InstrumentationLibraryLogs.Merge(m, src) } -func (m *ResourceLogs) XXX_Size() int { +func (m *InstrumentationLibraryLogs) XXX_Size() int { return m.Size() } -func (m *ResourceLogs) XXX_DiscardUnknown() { - xxx_messageInfo_ResourceLogs.DiscardUnknown(m) +func (m *InstrumentationLibraryLogs) XXX_DiscardUnknown() { + xxx_messageInfo_InstrumentationLibraryLogs.DiscardUnknown(m) } -var xxx_messageInfo_ResourceLogs proto.InternalMessageInfo +var xxx_messageInfo_InstrumentationLibraryLogs proto.InternalMessageInfo -func (m *ResourceLogs) GetResource() *v1.Resource { +func (m *InstrumentationLibraryLogs) GetInstrumentationLibrary() *v11.InstrumentationLibrary { if m != nil { - return m.Resource + return m.InstrumentationLibrary } return nil } -func (m *ResourceLogs) GetLogs() []*LogRecord { +func (m *InstrumentationLibraryLogs) GetLogs() []*LogRecord { if m != nil { return m.Logs } return nil } +// A log record according to OpenTelemetry Log Data Model: +// https://github.com/open-telemetry/oteps/blob/master/text/logs/0097-log-data-model.md type LogRecord struct { - // timestamp_unix_nano is the time when the event occurred. + // time_unix_nano is the time when the event occurred. // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. // Value of 0 indicates unknown or missing timestamp. - TimestampUnixNano uint64 `protobuf:"fixed64,1,opt,name=timestamp_unix_nano,json=timestampUnixNano,proto3" json:"timestamp_unix_nano,omitempty"` + TimeUnixNano uint64 `protobuf:"fixed64,1,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` + // Numerical value of the severity, normalized to values described in Log Data Model. + // [Optional]. + SeverityNumber SeverityNumber `protobuf:"varint,2,opt,name=severity_number,json=severityNumber,proto3,enum=opentelemetry.proto.logs.v1.SeverityNumber" json:"severity_number,omitempty"` + // The severity text (also known as log level). The original string representation as + // it is known at the source. [Optional]. + SeverityText string `protobuf:"bytes,3,opt,name=severity_text,json=severityText,proto3" json:"severity_text,omitempty"` + // Short event identifier that does not contain varying parts. Name describes + // what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 + // characters. Not guaranteed to be unique in any way. [Optional]. + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // A value containing the body of the log record. Can be for example a human-readable + // string message (including multi-line) describing the event in a free form or it can + // be a structured data composed of arrays and maps of other values. [Optional]. + Body *v11.AnyValue `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"` + // Additional attributes that describe the specific event occurrence. [Optional]. + Attributes []*v11.KeyValue `protobuf:"bytes,6,rep,name=attributes,proto3" json:"attributes,omitempty"` + DroppedAttributesCount uint32 `protobuf:"varint,7,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` + // Flags, a bit field. 8 least significant bits are the trace flags as + // defined in W3C Trace Context specification. 24 most significant bits are reserved + // and must be set to 0. Readers must not assume that 24 most significant bits + // will be zero and must correctly mask the bits when reading 8-bit trace flag (use + // flags & TRACE_FLAGS_MASK). [Optional]. + Flags uint32 `protobuf:"fixed32,8,opt,name=flags,proto3" json:"flags,omitempty"` // A unique identifier for a trace. All logs from the same trace share // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes // is considered invalid. Can be set for logs that are part of request processing - // and have an assigned trace id. Optional. - TraceId []byte `protobuf:"bytes,2,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + // and have an assigned trace id. [Optional]. + TraceId []byte `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` // A unique identifier for a span within a trace, assigned when the span // is created. The ID is an 8-byte array. An ID with all zeroes is considered // invalid. Can be set for logs that are part of a particular processing span. - // If span_id is present trace_id SHOULD be also present. Optional. - SpanId []byte `protobuf:"bytes,3,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"` - // Optional flags, a bit field. 8 least significant bits are the trace flags as - // defined in W3C Trace Context specification. 24 most significant bits are reserved - // and must be set to 0. Readers that must not assume that 24 most significant bits - // will be zero and must correctly mask the bits when reading 8-bit trace flag (use - // flags & TRACE_FLAGS_MASK). Optional. - Flags uint32 `protobuf:"varint,4,opt,name=flags,proto3" json:"flags,omitempty"` - // Numerical value of the severity, normalized to values described in - // https://github.com/open-telemetry/oteps/pull/97. Optional. - SeverityNumber SeverityNumber `protobuf:"varint,5,opt,name=severity_number,json=severityNumber,proto3,enum=logsproto.SeverityNumber" json:"severity_number,omitempty"` - // The severity text (also known as log level). The original string representation as - // it is known at the source. Optional. - SeverityText string `protobuf:"bytes,6,opt,name=severity_text,json=severityText,proto3" json:"severity_text,omitempty"` - // Short event identifier that does not contain varying parts. ShortName describes - // what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - // characters. Not guaranteed to be unique in any way. Optional. - ShortName string `protobuf:"bytes,7,opt,name=short_name,json=shortName,proto3" json:"short_name,omitempty"` - // A value containing the body of the log record. Can be for example a human-readable - // string message (including multi-line) describing the event in a free form or it can - // be a structured data composed of arrays and maps of other values. Optional. - // TODO: According to Log Data Model this must be of 'any' type, but we are not yet - // capable of representing it in memory so we are using string temporarily. - Body string `protobuf:"bytes,8,opt,name=body,proto3" json:"body,omitempty"` - // Additional attributes that describe the specific event occurrence. Optional. - Attributes []*v11.KeyValue `protobuf:"bytes,9,rep,name=attributes,proto3" json:"attributes,omitempty"` - DroppedAttributesCount uint32 `protobuf:"varint,10,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` + // If span_id is present trace_id SHOULD be also present. [Optional]. + SpanId []byte `protobuf:"bytes,10,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"` } func (m *LogRecord) Reset() { *m = LogRecord{} } func (m *LogRecord) String() string { return proto.CompactTextString(m) } func (*LogRecord) ProtoMessage() {} func (*LogRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_5e9a98bab354281e, []int{3} + return fileDescriptor_d1c030a3ec7e961e, []int{2} } func (m *LogRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -363,30 +333,9 @@ func (m *LogRecord) XXX_DiscardUnknown() { var xxx_messageInfo_LogRecord proto.InternalMessageInfo -func (m *LogRecord) GetTimestampUnixNano() uint64 { +func (m *LogRecord) GetTimeUnixNano() uint64 { if m != nil { - return m.TimestampUnixNano - } - return 0 -} - -func (m *LogRecord) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - -func (m *LogRecord) GetSpanId() []byte { - if m != nil { - return m.SpanId - } - return nil -} - -func (m *LogRecord) GetFlags() uint32 { - if m != nil { - return m.Flags + return m.TimeUnixNano } return 0 } @@ -405,18 +354,18 @@ func (m *LogRecord) GetSeverityText() string { return "" } -func (m *LogRecord) GetShortName() string { +func (m *LogRecord) GetName() string { if m != nil { - return m.ShortName + return m.Name } return "" } -func (m *LogRecord) GetBody() string { +func (m *LogRecord) GetBody() *v11.AnyValue { if m != nil { return m.Body } - return "" + return nil } func (m *LogRecord) GetAttributes() []*v11.KeyValue { @@ -433,155 +382,93 @@ func (m *LogRecord) GetDroppedAttributesCount() uint32 { return 0 } -func init() { - proto.RegisterEnum("logsproto.SeverityNumber", SeverityNumber_name, SeverityNumber_value) - proto.RegisterEnum("logsproto.LogRecordFlags", LogRecordFlags_name, LogRecordFlags_value) - proto.RegisterType((*ExportLogServiceRequest)(nil), "logsproto.ExportLogServiceRequest") - proto.RegisterType((*ExportLogServiceResponse)(nil), "logsproto.ExportLogServiceResponse") - proto.RegisterType((*ResourceLogs)(nil), "logsproto.ResourceLogs") - proto.RegisterType((*LogRecord)(nil), "logsproto.LogRecord") -} - -func init() { proto.RegisterFile("logs/v1/logs.proto", fileDescriptor_5e9a98bab354281e) } - -var fileDescriptor_5e9a98bab354281e = []byte{ - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xc1, 0x6e, 0xe2, 0x46, - 0x18, 0xc7, 0x71, 0x42, 0x08, 0x7c, 0x21, 0xec, 0xec, 0x6c, 0x76, 0xe3, 0x44, 0x5a, 0x84, 0xd8, - 0x43, 0x69, 0xa4, 0xc5, 0x8a, 0xe1, 0xd0, 0x43, 0x2f, 0x24, 0x31, 0x11, 0x0a, 0x6b, 0xa4, 0x01, - 0x76, 0xd5, 0x5e, 0x2c, 0x83, 0xa7, 0xd4, 0x12, 0xf6, 0xb8, 0xe3, 0x01, 0xc1, 0xa9, 0xaf, 0xd0, - 0x87, 0xe8, 0x8b, 0xf4, 0xd6, 0xe3, 0x1e, 0x7b, 0xac, 0x92, 0x07, 0x69, 0x35, 0x03, 0x9e, 0x85, - 0x36, 0xed, 0x89, 0xdf, 0xf7, 0xff, 0xfe, 0x9f, 0xe7, 0xef, 0x61, 0x3c, 0x80, 0xe7, 0x6c, 0x96, - 0x5a, 0xcb, 0x6b, 0x4b, 0xfe, 0x36, 0x13, 0xce, 0x04, 0xc3, 0x25, 0xc9, 0x0a, 0x2f, 0xaf, 0x58, - 0x42, 0x63, 0x41, 0xe7, 0x34, 0xa2, 0x82, 0xaf, 0x2d, 0x25, 0x5a, 0x53, 0x16, 0x45, 0x2c, 0x96, - 0x43, 0x1b, 0xda, 0x8c, 0x5d, 0x36, 0x9f, 0xf3, 0x72, 0x9a, 0xb2, 0x05, 0x9f, 0x52, 0xe9, 0xce, - 0x78, 0xe3, 0xaf, 0x7f, 0x82, 0x73, 0x67, 0x95, 0x30, 0x2e, 0xfa, 0x6c, 0x36, 0xa4, 0x7c, 0x19, - 0x4e, 0x29, 0xa1, 0x3f, 0x2d, 0x68, 0x2a, 0xf0, 0xb7, 0x70, 0x9a, 0x99, 0x3d, 0x19, 0xc6, 0x34, - 0x6a, 0x87, 0x8d, 0x13, 0xfb, 0xbc, 0xa9, 0x93, 0x35, 0xc9, 0xb6, 0xdf, 0x67, 0xb3, 0x94, 0x94, - 0xf9, 0x4e, 0x55, 0xbf, 0x04, 0xf3, 0xdf, 0x0f, 0x4e, 0x13, 0x16, 0xa7, 0xb4, 0xfe, 0x33, 0x94, - 0x77, 0x27, 0xb1, 0x03, 0xc5, 0x6c, 0xd6, 0x34, 0x6a, 0x46, 0xe3, 0xc4, 0xfe, 0x7a, 0xff, 0x3d, - 0x36, 0x61, 0x9b, 0x3a, 0xfb, 0xf2, 0x5a, 0x2f, 0x4d, 0xf4, 0x28, 0x6e, 0x40, 0x5e, 0xe5, 0x3c, - 0x50, 0x39, 0xcf, 0x76, 0x72, 0xf6, 0xd9, 0x8c, 0xd0, 0x29, 0xe3, 0x01, 0x51, 0x8e, 0xfa, 0xaf, - 0x87, 0x50, 0xd2, 0x1a, 0x6e, 0xc2, 0x2b, 0x11, 0x46, 0x34, 0x15, 0x7e, 0x94, 0x78, 0x8b, 0x38, - 0x5c, 0x79, 0xb1, 0x1f, 0x33, 0x95, 0xa4, 0x40, 0x5e, 0xea, 0xd6, 0x38, 0x0e, 0x57, 0xae, 0x1f, - 0x33, 0x7c, 0x01, 0x45, 0xc1, 0xfd, 0x29, 0xf5, 0xc2, 0xc0, 0x3c, 0xa8, 0x19, 0x8d, 0x32, 0x39, - 0x56, 0x75, 0x2f, 0xc0, 0xe7, 0x70, 0x9c, 0x26, 0x7e, 0x2c, 0x3b, 0x87, 0xaa, 0x53, 0x90, 0x65, - 0x2f, 0xc0, 0x67, 0x70, 0xf4, 0xc3, 0xdc, 0x9f, 0xa5, 0x66, 0xbe, 0x66, 0x34, 0x4e, 0xc9, 0xa6, - 0xc0, 0x37, 0xf0, 0x22, 0xa5, 0x4b, 0xca, 0x43, 0xb1, 0xf6, 0xe2, 0x45, 0x34, 0xa1, 0xdc, 0x3c, - 0xaa, 0x19, 0x8d, 0x8a, 0x7d, 0xb1, 0x13, 0x7e, 0xb8, 0x75, 0xb8, 0xca, 0x40, 0x2a, 0xe9, 0x5e, - 0x8d, 0xdf, 0xc1, 0xa9, 0x7e, 0x86, 0xa0, 0x2b, 0x61, 0x16, 0x6a, 0x46, 0xa3, 0x44, 0xca, 0x99, - 0x38, 0xa2, 0x2b, 0x81, 0xdf, 0x02, 0xa4, 0x3f, 0x32, 0x2e, 0xbc, 0xd8, 0x8f, 0xa8, 0x79, 0xac, - 0x1c, 0x25, 0xa5, 0xb8, 0x7e, 0x44, 0x31, 0x86, 0xfc, 0x84, 0x05, 0x6b, 0xb3, 0xa8, 0x1a, 0x8a, - 0xf1, 0x3d, 0x80, 0x2f, 0x04, 0x0f, 0x27, 0x0b, 0x41, 0x53, 0xb3, 0xa4, 0xf6, 0xf4, 0xab, 0x67, - 0xff, 0x96, 0xed, 0x01, 0x5c, 0x5e, 0x37, 0x1f, 0xe8, 0xfa, 0xa3, 0x3f, 0x5f, 0x50, 0xb2, 0x33, - 0x8a, 0xbf, 0x01, 0x33, 0xe0, 0x2c, 0x49, 0x68, 0xe0, 0x7d, 0x51, 0xbd, 0x29, 0x5b, 0xc4, 0xc2, - 0x04, 0xb5, 0x1b, 0x6f, 0xb6, 0xfd, 0x8e, 0x6e, 0xdf, 0xca, 0xee, 0xd5, 0x6f, 0x07, 0x50, 0xd9, - 0x7f, 0x7b, 0xfc, 0x16, 0x2e, 0xc6, 0xee, 0x9d, 0xd3, 0xed, 0xb9, 0xce, 0x9d, 0x37, 0x74, 0x3e, - 0x3a, 0xa4, 0x37, 0xfa, 0xce, 0x73, 0xc7, 0x1f, 0x6e, 0x1c, 0x82, 0x72, 0xb8, 0x04, 0x47, 0x23, - 0xd2, 0xb9, 0x75, 0x90, 0x81, 0x01, 0x0a, 0x0a, 0x6d, 0x74, 0xa0, 0xb9, 0x85, 0x0e, 0x35, 0xb7, - 0x51, 0x5e, 0xda, 0xef, 0x9c, 0x9b, 0xf1, 0x3d, 0x3a, 0x92, 0xb2, 0x42, 0x1b, 0x15, 0x34, 0xb7, - 0xd0, 0xb1, 0xe6, 0x36, 0x2a, 0xe2, 0x22, 0xe4, 0x7b, 0x6e, 0x77, 0x80, 0x4a, 0x72, 0x50, 0x92, - 0x8d, 0x20, 0xc3, 0x16, 0x3a, 0xc9, 0xb0, 0x8d, 0xca, 0xd2, 0xfa, 0xa9, 0x43, 0x5c, 0x74, 0x2a, - 0x45, 0x49, 0x36, 0xaa, 0x64, 0xd8, 0x42, 0x2f, 0x32, 0x6c, 0x23, 0x24, 0xd1, 0x21, 0x64, 0x40, - 0xd0, 0x4b, 0xb9, 0x98, 0x42, 0x1b, 0x61, 0xcd, 0x2d, 0xf4, 0x4a, 0x73, 0x1b, 0x9d, 0x49, 0x7b, - 0xb7, 0x33, 0xea, 0xf4, 0xd1, 0x6b, 0x29, 0x2b, 0xb4, 0xd1, 0x1b, 0xcd, 0x2d, 0x74, 0xae, 0xb9, - 0x8d, 0xcc, 0xab, 0x2e, 0x54, 0xf4, 0x49, 0xef, 0xaa, 0x43, 0xb7, 0xb7, 0x85, 0xfd, 0xc1, 0xbd, - 0x47, 0x9c, 0xdb, 0x01, 0xb9, 0xf3, 0xba, 0xfd, 0xce, 0x3d, 0xca, 0xe1, 0xd7, 0x80, 0xd4, 0xfe, - 0xa8, 0x7a, 0xe8, 0x7d, 0xe8, 0x0c, 0x1f, 0xd0, 0x5f, 0x86, 0xed, 0x03, 0x7c, 0xf9, 0x92, 0xf1, - 0x10, 0x0a, 0x9b, 0xaf, 0x1b, 0xd7, 0x77, 0x4e, 0xea, 0x7f, 0xdc, 0x24, 0x97, 0xef, 0xfe, 0xd7, - 0xb3, 0xbd, 0x14, 0x72, 0x37, 0xf4, 0xf7, 0xc7, 0xaa, 0xf1, 0xf9, 0xb1, 0x6a, 0xfc, 0xf9, 0x58, - 0x35, 0x7e, 0x79, 0xaa, 0xe6, 0x3e, 0x3f, 0x55, 0x73, 0x7f, 0x3c, 0x55, 0x73, 0xdf, 0x3f, 0xcc, - 0xd8, 0x3f, 0x4e, 0x5e, 0x28, 0x6f, 0xc0, 0xf9, 0x9c, 0x4e, 0x05, 0xe3, 0x56, 0x18, 0x0b, 0xca, - 0x63, 0x7f, 0x6e, 0x05, 0xbe, 0xf0, 0xad, 0x3d, 0xe3, 0x7b, 0xb5, 0xea, 0xfb, 0x19, 0x8d, 0xad, - 0xed, 0x25, 0x3b, 0x29, 0x28, 0xa9, 0xf5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x64, 0xcc, - 0x08, 0x76, 0x05, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// LogServiceClient is the client API for LogService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type LogServiceClient interface { - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(ctx context.Context, in *ExportLogServiceRequest, opts ...grpc.CallOption) (*ExportLogServiceResponse, error) -} - -type logServiceClient struct { - cc *grpc.ClientConn -} - -func NewLogServiceClient(cc *grpc.ClientConn) LogServiceClient { - return &logServiceClient{cc} -} - -func (c *logServiceClient) Export(ctx context.Context, in *ExportLogServiceRequest, opts ...grpc.CallOption) (*ExportLogServiceResponse, error) { - out := new(ExportLogServiceResponse) - err := c.cc.Invoke(ctx, "/logsproto.LogService/Export", in, out, opts...) - if err != nil { - return nil, err +func (m *LogRecord) GetFlags() uint32 { + if m != nil { + return m.Flags } - return out, nil -} - -// LogServiceServer is the server API for LogService service. -type LogServiceServer interface { - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(context.Context, *ExportLogServiceRequest) (*ExportLogServiceResponse, error) + return 0 } -// UnimplementedLogServiceServer can be embedded to have forward compatible implementations. -type UnimplementedLogServiceServer struct { +func (m *LogRecord) GetTraceId() []byte { + if m != nil { + return m.TraceId + } + return nil } -func (*UnimplementedLogServiceServer) Export(ctx context.Context, req *ExportLogServiceRequest) (*ExportLogServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +func (m *LogRecord) GetSpanId() []byte { + if m != nil { + return m.SpanId + } + return nil } -func RegisterLogServiceServer(s *grpc.Server, srv LogServiceServer) { - s.RegisterService(&_LogService_serviceDesc, srv) +func init() { + proto.RegisterEnum("opentelemetry.proto.logs.v1.SeverityNumber", SeverityNumber_name, SeverityNumber_value) + proto.RegisterEnum("opentelemetry.proto.logs.v1.LogRecordFlags", LogRecordFlags_name, LogRecordFlags_value) + proto.RegisterType((*ResourceLogs)(nil), "opentelemetry.proto.logs.v1.ResourceLogs") + proto.RegisterType((*InstrumentationLibraryLogs)(nil), "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs") + proto.RegisterType((*LogRecord)(nil), "opentelemetry.proto.logs.v1.LogRecord") } -func _LogService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExportLogServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LogServiceServer).Export(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/logsproto.LogService/Export", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LogServiceServer).Export(ctx, req.(*ExportLogServiceRequest)) - } - return interceptor(ctx, in, info, handler) +func init() { + proto.RegisterFile("opentelemetry/proto/logs/v1/logs.proto", fileDescriptor_d1c030a3ec7e961e) } -var _LogService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "logsproto.LogService", - HandlerType: (*LogServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Export", - Handler: _LogService_Export_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "logs/v1/logs.proto", +var fileDescriptor_d1c030a3ec7e961e = []byte{ + // 773 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x95, 0x4f, 0x8f, 0x22, 0x45, + 0x18, 0xc6, 0x29, 0xfe, 0x53, 0xc3, 0xb0, 0x65, 0xb9, 0x3b, 0xd3, 0x8b, 0x4a, 0xc8, 0x68, 0x56, + 0x1c, 0xb3, 0x90, 0x69, 0x30, 0x1a, 0x3d, 0x35, 0x43, 0x43, 0xc8, 0xb0, 0xb0, 0x29, 0x60, 0x8d, + 0x5e, 0x3a, 0x0d, 0x5d, 0x92, 0x4e, 0x9a, 0x2a, 0xd2, 0x5d, 0x10, 0xf8, 0x16, 0xc6, 0x6f, 0xe4, + 0x6d, 0xe3, 0x69, 0x8e, 0x1e, 0xcd, 0xcc, 0x07, 0xd1, 0x54, 0x41, 0xb7, 0xcb, 0x06, 0x98, 0x13, + 0xbf, 0x7a, 0xde, 0xe7, 0x79, 0xfb, 0xad, 0x97, 0x34, 0xc0, 0x57, 0x7c, 0x41, 0x99, 0xa0, 0x1e, + 0x9d, 0x53, 0xe1, 0x6f, 0x6a, 0x0b, 0x9f, 0x0b, 0x5e, 0xf3, 0xf8, 0x2c, 0xa8, 0xad, 0x6e, 0xd4, + 0x67, 0x55, 0x49, 0xf8, 0xb3, 0x3d, 0xdf, 0x56, 0xac, 0xaa, 0xfa, 0xea, 0xa6, 0x78, 0x7d, 0xa8, + 0xc9, 0x94, 0xcf, 0xe7, 0x9c, 0xc9, 0x36, 0x5b, 0xda, 0x66, 0x8a, 0xd5, 0x43, 0x5e, 0x9f, 0x06, + 0x7c, 0xe9, 0x4f, 0xa9, 0x74, 0x87, 0xbc, 0xf5, 0x5f, 0xdd, 0x03, 0x98, 0x27, 0x3b, 0xa9, 0xc7, + 0x67, 0x01, 0x36, 0x61, 0x36, 0xb4, 0x68, 0xa0, 0x0c, 0x2a, 0x67, 0xfa, 0x37, 0xd5, 0x43, 0xc3, + 0x45, 0x7d, 0x56, 0x37, 0xd5, 0xb0, 0x01, 0x89, 0xa2, 0x78, 0x03, 0x3f, 0x77, 0x59, 0x20, 0xfc, + 0xe5, 0x9c, 0x32, 0x61, 0x0b, 0x97, 0x33, 0xcb, 0x73, 0x27, 0xbe, 0xed, 0x6f, 0x2c, 0x79, 0x2d, + 0x2d, 0x5e, 0x4e, 0x54, 0xce, 0xf4, 0xef, 0xab, 0x27, 0xee, 0x5d, 0xed, 0xee, 0x37, 0xe8, 0x6d, + 0xf3, 0x72, 0x4a, 0x52, 0x74, 0x8f, 0xd6, 0xae, 0xde, 0x03, 0x58, 0x3c, 0x1e, 0xc5, 0x0c, 0x5e, + 0x1e, 0x99, 0x6c, 0x77, 0xdf, 0xef, 0x0e, 0x0e, 0xb5, 0xdb, 0xf2, 0xd1, 0xb1, 0xc8, 0xc5, 0xe1, + 0x91, 0xf0, 0x8f, 0x30, 0xf9, 0xc1, 0x8d, 0x5f, 0x9d, 0xbc, 0x71, 0x8f, 0xcf, 0x08, 0x9d, 0x72, + 0xdf, 0x21, 0x2a, 0x73, 0xf5, 0x57, 0x02, 0xe6, 0x22, 0x0d, 0x7f, 0x05, 0x0b, 0xc2, 0x9d, 0x53, + 0x6b, 0xc9, 0xdc, 0xb5, 0xc5, 0x6c, 0xc6, 0xd5, 0xc0, 0x69, 0x92, 0x97, 0xea, 0x98, 0xb9, 0xeb, + 0xbe, 0xcd, 0x38, 0x1e, 0xc1, 0x67, 0x01, 0x5d, 0x51, 0xdf, 0x15, 0x1b, 0x8b, 0x2d, 0xe7, 0x13, + 0xea, 0x6b, 0xf1, 0x32, 0xa8, 0x14, 0xf4, 0x6f, 0x4f, 0x3e, 0x7a, 0xb8, 0xcb, 0xf4, 0x55, 0x84, + 0x14, 0x82, 0xbd, 0x33, 0xfe, 0x12, 0x9e, 0x47, 0x5d, 0x05, 0x5d, 0x0b, 0x2d, 0x51, 0x06, 0x95, + 0x1c, 0xc9, 0x87, 0xe2, 0x88, 0xae, 0x05, 0xc6, 0x30, 0xc9, 0xec, 0x39, 0xd5, 0x92, 0xaa, 0xa6, + 0x18, 0xff, 0x04, 0x93, 0x13, 0xee, 0x6c, 0xb4, 0x94, 0xda, 0xed, 0xd7, 0x4f, 0xec, 0xd6, 0x60, + 0x9b, 0x77, 0xb6, 0xb7, 0xa4, 0x44, 0x85, 0x70, 0x07, 0x42, 0x5b, 0x08, 0xdf, 0x9d, 0x2c, 0x05, + 0x0d, 0xb4, 0xb4, 0xda, 0xe0, 0x53, 0x2d, 0xee, 0xe8, 0xae, 0xc5, 0x07, 0x51, 0xfc, 0x03, 0xd4, + 0x1c, 0x9f, 0x2f, 0x16, 0xd4, 0xb1, 0xfe, 0x57, 0xad, 0x29, 0x5f, 0x32, 0xa1, 0x65, 0xca, 0xa0, + 0x72, 0x4e, 0x2e, 0x76, 0x75, 0x23, 0x2a, 0xdf, 0xca, 0x2a, 0x7e, 0x0e, 0x53, 0xbf, 0x79, 0xf6, + 0x2c, 0xd0, 0xb2, 0x65, 0x50, 0xc9, 0x90, 0xed, 0x01, 0xbf, 0x84, 0x59, 0xe1, 0xdb, 0x53, 0x6a, + 0xb9, 0x8e, 0x96, 0x2b, 0x83, 0x4a, 0x9e, 0x64, 0xd4, 0xb9, 0xeb, 0xe0, 0x4b, 0x98, 0x09, 0x16, + 0x36, 0x93, 0x15, 0xa8, 0x2a, 0x69, 0x79, 0xec, 0x3a, 0xd7, 0x7f, 0xc6, 0x61, 0x61, 0x7f, 0xcb, + 0xf8, 0x0b, 0xf8, 0x72, 0xdc, 0x6f, 0x99, 0xed, 0x6e, 0xdf, 0x6c, 0x59, 0x43, 0xf3, 0x9d, 0x49, + 0xba, 0xa3, 0x5f, 0xac, 0xfe, 0xf8, 0x4d, 0xd3, 0x24, 0x28, 0x86, 0x73, 0x30, 0x35, 0x22, 0xc6, + 0xad, 0x89, 0x00, 0x86, 0x30, 0xad, 0x50, 0x47, 0xf1, 0x88, 0xeb, 0x28, 0x11, 0x71, 0x03, 0x25, + 0xa5, 0xbd, 0x65, 0x36, 0xc7, 0x1d, 0x94, 0x92, 0xb2, 0x42, 0x1d, 0xa5, 0x23, 0xae, 0xa3, 0x4c, + 0xc4, 0x0d, 0x94, 0xc5, 0x59, 0x98, 0xec, 0xf6, 0xdb, 0x03, 0x94, 0x93, 0x41, 0x49, 0x3a, 0x82, + 0x21, 0xd6, 0xd1, 0x59, 0x88, 0x0d, 0x94, 0x97, 0xd6, 0x9f, 0x0d, 0xd2, 0x47, 0xe7, 0x52, 0x94, + 0xa4, 0xa3, 0x42, 0x88, 0x75, 0xf4, 0x2c, 0xc4, 0x06, 0x42, 0x12, 0x4d, 0x42, 0x06, 0x04, 0x7d, + 0x22, 0x1f, 0xa6, 0x50, 0x47, 0x38, 0xe2, 0x3a, 0xfa, 0x34, 0xe2, 0x06, 0x7a, 0x2e, 0xed, 0x6d, + 0x63, 0x64, 0xf4, 0xd0, 0x0b, 0x29, 0x2b, 0xd4, 0xd1, 0x45, 0xc4, 0x75, 0x74, 0x19, 0x71, 0x03, + 0x69, 0xd7, 0x6d, 0x58, 0x88, 0xde, 0x87, 0xb6, 0xfa, 0x26, 0xf6, 0x56, 0xd8, 0x1b, 0x74, 0x2c, + 0x62, 0xde, 0x0e, 0x48, 0xcb, 0x6a, 0xf7, 0x8c, 0x0e, 0x8a, 0xe1, 0x17, 0x10, 0xa9, 0xfd, 0xa8, + 0xf3, 0xd0, 0x7a, 0x63, 0x0c, 0xef, 0xd0, 0xbf, 0xa0, 0xf9, 0x07, 0x78, 0xff, 0x50, 0x02, 0xf7, + 0x0f, 0x25, 0xf0, 0xcf, 0x43, 0x09, 0xfc, 0xfe, 0x58, 0x8a, 0xdd, 0x3f, 0x96, 0x62, 0x7f, 0x3f, + 0x96, 0x62, 0xb0, 0xe4, 0xf2, 0x53, 0x2f, 0x4a, 0x53, 0xbe, 0x90, 0xc1, 0x5b, 0x29, 0xbd, 0x05, + 0xbf, 0xde, 0xcd, 0x3e, 0x36, 0xbb, 0xf2, 0xa7, 0xd9, 0xf3, 0xe8, 0x54, 0x70, 0xbf, 0xe6, 0x32, + 0x41, 0x7d, 0x66, 0x7b, 0x35, 0xc7, 0x16, 0x76, 0x6d, 0xcf, 0xf8, 0x5a, 0x75, 0x7d, 0x3d, 0xa3, + 0x2c, 0xfc, 0x3f, 0x98, 0xa4, 0x95, 0x54, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x66, 0x84, + 0x11, 0x35, 0x06, 0x00, 0x00, } -func (m *ExportLogServiceRequest) Marshal() (dAtA []byte, err error) { +func (m *ResourceLogs) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -591,20 +478,20 @@ func (m *ExportLogServiceRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ExportLogServiceRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *ResourceLogs) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ExportLogServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ResourceLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ResourceLogs) > 0 { - for iNdEx := len(m.ResourceLogs) - 1; iNdEx >= 0; iNdEx-- { + if len(m.InstrumentationLibraryLogs) > 0 { + for iNdEx := len(m.InstrumentationLibraryLogs) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.ResourceLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.InstrumentationLibraryLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -612,36 +499,25 @@ func (m *ExportLogServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintLogs(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 } } - return len(dAtA) - i, nil -} - -func (m *ExportLogServiceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.Resource != nil { + { + size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLogs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return dAtA[:n], nil -} - -func (m *ExportLogServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportLogServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l return len(dAtA) - i, nil } -func (m *ResourceLogs) Marshal() (dAtA []byte, err error) { +func (m *InstrumentationLibraryLogs) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -651,12 +527,12 @@ func (m *ResourceLogs) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ResourceLogs) MarshalTo(dAtA []byte) (int, error) { +func (m *InstrumentationLibraryLogs) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ResourceLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InstrumentationLibraryLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -675,9 +551,9 @@ func (m *ResourceLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if m.Resource != nil { + if m.InstrumentationLibrary != nil { { - size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.InstrumentationLibrary.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -710,10 +586,30 @@ func (m *LogRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.SpanId) > 0 { + i -= len(m.SpanId) + copy(dAtA[i:], m.SpanId) + i = encodeVarintLogs(dAtA, i, uint64(len(m.SpanId))) + i-- + dAtA[i] = 0x52 + } + if len(m.TraceId) > 0 { + i -= len(m.TraceId) + copy(dAtA[i:], m.TraceId) + i = encodeVarintLogs(dAtA, i, uint64(len(m.TraceId))) + i-- + dAtA[i] = 0x4a + } + if m.Flags != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Flags)) + i-- + dAtA[i] = 0x45 + } if m.DroppedAttributesCount != 0 { i = encodeVarintLogs(dAtA, i, uint64(m.DroppedAttributesCount)) i-- - dAtA[i] = 0x50 + dAtA[i] = 0x38 } if len(m.Attributes) > 0 { for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { @@ -726,57 +622,43 @@ func (m *LogRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintLogs(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x32 } } - if len(m.Body) > 0 { - i -= len(m.Body) - copy(dAtA[i:], m.Body) - i = encodeVarintLogs(dAtA, i, uint64(len(m.Body))) + if m.Body != nil { + { + size, err := m.Body.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLogs(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x2a } - if len(m.ShortName) > 0 { - i -= len(m.ShortName) - copy(dAtA[i:], m.ShortName) - i = encodeVarintLogs(dAtA, i, uint64(len(m.ShortName))) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintLogs(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x22 } if len(m.SeverityText) > 0 { i -= len(m.SeverityText) copy(dAtA[i:], m.SeverityText) i = encodeVarintLogs(dAtA, i, uint64(len(m.SeverityText))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x1a } if m.SeverityNumber != 0 { i = encodeVarintLogs(dAtA, i, uint64(m.SeverityNumber)) i-- - dAtA[i] = 0x28 - } - if m.Flags != 0 { - i = encodeVarintLogs(dAtA, i, uint64(m.Flags)) - i-- - dAtA[i] = 0x20 + dAtA[i] = 0x10 } - if len(m.SpanId) > 0 { - i -= len(m.SpanId) - copy(dAtA[i:], m.SpanId) - i = encodeVarintLogs(dAtA, i, uint64(len(m.SpanId))) - i-- - dAtA[i] = 0x1a - } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintLogs(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0x12 - } - if m.TimestampUnixNano != 0 { + if m.TimeUnixNano != 0 { i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimestampUnixNano)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) i-- dAtA[i] = 0x9 } @@ -794,14 +676,18 @@ func encodeVarintLogs(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *ExportLogServiceRequest) Size() (n int) { +func (m *ResourceLogs) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.ResourceLogs) > 0 { - for _, e := range m.ResourceLogs { + if m.Resource != nil { + l = m.Resource.Size() + n += 1 + l + sovLogs(uint64(l)) + } + if len(m.InstrumentationLibraryLogs) > 0 { + for _, e := range m.InstrumentationLibraryLogs { l = e.Size() n += 1 + l + sovLogs(uint64(l)) } @@ -809,23 +695,14 @@ func (m *ExportLogServiceRequest) Size() (n int) { return n } -func (m *ExportLogServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *ResourceLogs) Size() (n int) { +func (m *InstrumentationLibraryLogs) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Resource != nil { - l = m.Resource.Size() + if m.InstrumentationLibrary != nil { + l = m.InstrumentationLibrary.Size() n += 1 + l + sovLogs(uint64(l)) } if len(m.Logs) > 0 { @@ -843,20 +720,9 @@ func (m *LogRecord) Size() (n int) { } var l int _ = l - if m.TimestampUnixNano != 0 { + if m.TimeUnixNano != 0 { n += 9 } - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - l = len(m.SpanId) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - if m.Flags != 0 { - n += 1 + sovLogs(uint64(m.Flags)) - } if m.SeverityNumber != 0 { n += 1 + sovLogs(uint64(m.SeverityNumber)) } @@ -864,12 +730,12 @@ func (m *LogRecord) Size() (n int) { if l > 0 { n += 1 + l + sovLogs(uint64(l)) } - l = len(m.ShortName) + l = len(m.Name) if l > 0 { n += 1 + l + sovLogs(uint64(l)) } - l = len(m.Body) - if l > 0 { + if m.Body != nil { + l = m.Body.Size() n += 1 + l + sovLogs(uint64(l)) } if len(m.Attributes) > 0 { @@ -881,6 +747,17 @@ func (m *LogRecord) Size() (n int) { if m.DroppedAttributesCount != 0 { n += 1 + sovLogs(uint64(m.DroppedAttributesCount)) } + if m.Flags != 0 { + n += 5 + } + l = len(m.TraceId) + if l > 0 { + n += 1 + l + sovLogs(uint64(l)) + } + l = len(m.SpanId) + if l > 0 { + n += 1 + l + sovLogs(uint64(l)) + } return n } @@ -890,7 +767,7 @@ func sovLogs(x uint64) (n int) { func sozLogs(x uint64) (n int) { return sovLogs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *ExportLogServiceRequest) Unmarshal(dAtA []byte) error { +func (m *ResourceLogs) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -913,15 +790,15 @@ func (m *ExportLogServiceRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ExportLogServiceRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ResourceLogs: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ExportLogServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ResourceLogs: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -948,64 +825,47 @@ func (m *ExportLogServiceRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ResourceLogs = append(m.ResourceLogs, &ResourceLogs{}) - if err := m.ResourceLogs[len(m.ResourceLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Resource == nil { + m.Resource = &v1.Resource{} + } + if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogs(dAtA[iNdEx:]) - if err != nil { - return err + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InstrumentationLibraryLogs", wireType) } - if skippy < 0 { - return ErrInvalidLengthLogs + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) < 0 { + if msglen < 0 { return ErrInvalidLengthLogs } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportLogServiceResponse) Unmarshal(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 ErrIntOverflowLogs + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLogs } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.InstrumentationLibraryLogs = append(m.InstrumentationLibraryLogs, &InstrumentationLibraryLogs{}) + if err := m.InstrumentationLibraryLogs[len(m.InstrumentationLibraryLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportLogServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportLogServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipLogs(dAtA[iNdEx:]) @@ -1030,7 +890,7 @@ func (m *ExportLogServiceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *ResourceLogs) Unmarshal(dAtA []byte) error { +func (m *InstrumentationLibraryLogs) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1053,15 +913,15 @@ func (m *ResourceLogs) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ResourceLogs: wiretype end group for non-group") + return fmt.Errorf("proto: InstrumentationLibraryLogs: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceLogs: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InstrumentationLibraryLogs: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InstrumentationLibrary", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1088,10 +948,10 @@ func (m *ResourceLogs) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Resource == nil { - m.Resource = &v1.Resource{} + if m.InstrumentationLibrary == nil { + m.InstrumentationLibrary = &v11.InstrumentationLibrary{} } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.InstrumentationLibrary.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1184,19 +1044,19 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimestampUnixNano", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) } - m.TimestampUnixNano = 0 + m.TimeUnixNano = 0 if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.TimestampUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SeverityNumber", wireType) } - var byteLen int + m.SeverityNumber = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1206,31 +1066,16 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.SeverityNumber |= SeverityNumber(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} - } - iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SeverityText", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1240,31 +1085,29 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthLogs } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthLogs } if postIndex > l { return io.ErrUnexpectedEOF } - m.SpanId = append(m.SpanId[:0], dAtA[iNdEx:postIndex]...) - if m.SpanId == nil { - m.SpanId = []byte{} - } + m.SeverityText = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } - m.Flags = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1274,35 +1117,29 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Flags |= uint32(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SeverityNumber", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogs } - m.SeverityNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SeverityNumber |= SeverityNumber(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLogs } - case 6: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SeverityText", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1312,29 +1149,33 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthLogs } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthLogs } if postIndex > l { return io.ErrUnexpectedEOF } - m.SeverityText = string(dAtA[iNdEx:postIndex]) + if m.Body == nil { + m.Body = &v11.AnyValue{} + } + if err := m.Body.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 7: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ShortName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1344,29 +1185,31 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthLogs } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthLogs } if postIndex > l { return io.ErrUnexpectedEOF } - m.ShortName = string(dAtA[iNdEx:postIndex]) + m.Attributes = append(m.Attributes, &v11.KeyValue{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) } - var stringLen uint64 + m.DroppedAttributesCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1376,29 +1219,26 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.DroppedAttributesCount |= uint32(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogs + case 8: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) } - if postIndex > l { + m.Flags = 0 + if (iNdEx + 4) > l { return io.ErrUnexpectedEOF } - m.Body = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex + m.Flags = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1408,31 +1248,31 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthLogs } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthLogs } if postIndex > l { return io.ErrUnexpectedEOF } - m.Attributes = append(m.Attributes, &v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) + if m.TraceId == nil { + m.TraceId = []byte{} } iNdEx = postIndex case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) } - m.DroppedAttributesCount = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLogs @@ -1442,11 +1282,26 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthLogs + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthLogs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpanId = append(m.SpanId[:0], dAtA[iNdEx:postIndex]...) + if m.SpanId == nil { + m.SpanId = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipLogs(dAtA[iNdEx:]) diff --git a/internal/data/testdata/log.go b/internal/data/testdata/log.go index 69bdc82c11ac..d0cc7e60cc1a 100644 --- a/internal/data/testdata/log.go +++ b/internal/data/testdata/log.go @@ -84,7 +84,8 @@ func generateLogOtlpNoLogRecords() []*otlplogs.ResourceLogs { func GenerateLogDataOneEmptyLogs() data.Logs { ld := GenerateLogDataNoLogRecords() rs0 := ld.ResourceLogs().At(0) - rs0.Logs().Resize(1) + rs0.InstrumentationLibraryLogs().Resize(1) + rs0.InstrumentationLibraryLogs().At(0).Logs().Resize(1) return ld } @@ -92,8 +93,12 @@ func generateLogOtlpOneEmptyLogs() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - {}, + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + {}, + }, + }, }, }, } @@ -107,9 +112,13 @@ func generateLogOtlpOneEmptyOneNilLogRecord() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - {}, - nil, + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + {}, + nil, + }, + }, }, }, } @@ -118,8 +127,9 @@ func generateLogOtlpOneEmptyOneNilLogRecord() []*otlplogs.ResourceLogs { func GenerateLogDataOneLogNoResource() data.Logs { ld := GenerateLogDataOneEmptyResourceLogs() rs0 := ld.ResourceLogs().At(0) - rs0.Logs().Resize(1) - rs0lr0 := rs0.Logs().At(0) + rs0.InstrumentationLibraryLogs().Resize(1) + rs0.InstrumentationLibraryLogs().At(0).Logs().Resize(1) + rs0lr0 := rs0.InstrumentationLibraryLogs().At(0).Logs().At(0) fillLogOne(rs0lr0) return ld } @@ -127,8 +137,12 @@ func GenerateLogDataOneLogNoResource() data.Logs { func generateLogOtlpOneLogNoResource() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { - Logs: []*otlplogs.LogRecord{ - generateOtlpLogOne(), + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogOne(), + }, + }, }, }, } @@ -136,9 +150,11 @@ func generateLogOtlpOneLogNoResource() []*otlplogs.ResourceLogs { func GenerateLogDataOneLog() data.Logs { ld := GenerateLogDataOneEmptyLogs() - rs0lr0 := ld.ResourceLogs().At(0) - rs0lr0.Logs().Resize(1) - fillLogOne(rs0lr0.Logs().At(0)) + rs0 := ld.ResourceLogs().At(0) + rs0.InstrumentationLibraryLogs().Resize(1) + rs0.InstrumentationLibraryLogs().At(0).Logs().Resize(1) + rs0lr0 := rs0.InstrumentationLibraryLogs().At(0).Logs().At(0) + fillLogOne(rs0lr0) return ld } @@ -146,8 +162,12 @@ func generateLogOtlpOneLog() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - generateOtlpLogOne(), + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogOne(), + }, + }, }, }, } @@ -161,9 +181,13 @@ func generateLogOtlpOneLogOneNil() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - generateOtlpLogOne(), - nil, + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogOne(), + nil, + }, + }, }, }, } @@ -172,9 +196,10 @@ func generateLogOtlpOneLogOneNil() []*otlplogs.ResourceLogs { func GenerateLogDataTwoLogsSameResource() data.Logs { ld := GenerateLogDataOneEmptyLogs() rs0 := ld.ResourceLogs().At(0) - rs0.Logs().Resize(2) - fillLogOne(rs0.Logs().At(0)) - fillLogTwo(rs0.Logs().At(1)) + rs0.InstrumentationLibraryLogs().Resize(1) + rs0.InstrumentationLibraryLogs().At(0).Logs().Resize(2) + fillLogOne(rs0.InstrumentationLibraryLogs().At(0).Logs().At(0)) + fillLogTwo(rs0.InstrumentationLibraryLogs().At(0).Logs().At(1)) return ld } @@ -183,9 +208,13 @@ func GenerateLogOtlpSameResourceTwoLogs() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - generateOtlpLogOne(), - generateOtlpLogTwo(), + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogOne(), + generateOtlpLogTwo(), + }, + }, }, }, } @@ -196,13 +225,15 @@ func GenerateLogDataTwoLogsSameResourceOneDifferent() data.Logs { ld.ResourceLogs().Resize(2) rl0 := ld.ResourceLogs().At(0) initResource1(rl0.Resource()) - rl0.Logs().Resize(2) - fillLogOne(rl0.Logs().At(0)) - fillLogTwo(rl0.Logs().At(1)) + rl0.InstrumentationLibraryLogs().Resize(1) + rl0.InstrumentationLibraryLogs().At(0).Logs().Resize(2) + fillLogOne(rl0.InstrumentationLibraryLogs().At(0).Logs().At(0)) + fillLogTwo(rl0.InstrumentationLibraryLogs().At(0).Logs().At(1)) rl1 := ld.ResourceLogs().At(1) initResource2(rl1.Resource()) - rl1.Logs().Resize(1) - fillLogThree(rl1.Logs().At(0)) + rl1.InstrumentationLibraryLogs().Resize(1) + rl1.InstrumentationLibraryLogs().At(0).Logs().Resize(1) + fillLogThree(rl1.InstrumentationLibraryLogs().At(0).Logs().At(0)) return ld } @@ -210,22 +241,30 @@ func generateLogOtlpTwoLogsSameResourceOneDifferent() []*otlplogs.ResourceLogs { return []*otlplogs.ResourceLogs{ { Resource: generateOtlpResource1(), - Logs: []*otlplogs.LogRecord{ - generateOtlpLogOne(), - generateOtlpLogTwo(), + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogOne(), + generateOtlpLogTwo(), + }, + }, }, }, { Resource: generateOtlpResource2(), - Logs: []*otlplogs.LogRecord{ - generateOtlpLogThree(), + InstrumentationLibraryLogs: []*otlplogs.InstrumentationLibraryLogs{ + { + Logs: []*otlplogs.LogRecord{ + generateOtlpLogThree(), + }, + }, }, }, } } func fillLogOne(log pdata.LogRecord) { - log.SetShortName("logA") + log.SetName("logA") log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) log.SetSeverityNumber(otlplogs.SeverityNumber_INFO) @@ -237,17 +276,17 @@ func fillLogOne(log pdata.LogRecord) { attrs.InsertString("app", "server") attrs.InsertInt("instance_num", 1) - log.SetBody("This is a log message") + log.Body().SetStringVal("This is a log message") } func generateOtlpLogOne() *otlplogs.LogRecord { return &otlplogs.LogRecord{ - ShortName: "logA", - TimestampUnixNano: uint64(TestLogTimestamp), + Name: "logA", + TimeUnixNano: uint64(TestLogTimestamp), DroppedAttributesCount: 1, SeverityNumber: otlplogs.SeverityNumber_INFO, SeverityText: "Info", - Body: "This is a log message", + Body: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "This is a log message"}}, SpanId: []byte{0x01, 0x02, 0x04, 0x08}, TraceId: []byte{0x08, 0x04, 0x02, 0x01}, Attributes: []*otlpcommon.KeyValue{ @@ -264,7 +303,7 @@ func generateOtlpLogOne() *otlplogs.LogRecord { } func fillLogTwo(log pdata.LogRecord) { - log.SetShortName("logB") + log.SetName("logB") log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) log.SetSeverityNumber(otlplogs.SeverityNumber_INFO) @@ -274,17 +313,17 @@ func fillLogTwo(log pdata.LogRecord) { attrs.InsertString("customer", "acme") attrs.InsertString("env", "dev") - log.SetBody("something happened") + log.Body().SetStringVal("something happened") } func generateOtlpLogTwo() *otlplogs.LogRecord { return &otlplogs.LogRecord{ - ShortName: "logB", - TimestampUnixNano: uint64(TestLogTimestamp), + Name: "logB", + TimeUnixNano: uint64(TestLogTimestamp), DroppedAttributesCount: 1, SeverityNumber: otlplogs.SeverityNumber_INFO, SeverityText: "Info", - Body: "something happened", + Body: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "something happened"}}, Attributes: []*otlpcommon.KeyValue{ { Key: "customer", @@ -299,22 +338,22 @@ func generateOtlpLogTwo() *otlplogs.LogRecord { } func fillLogThree(log pdata.LogRecord) { - log.SetShortName("logC") + log.SetName("logC") log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) log.SetSeverityNumber(otlplogs.SeverityNumber_WARN) log.SetSeverityText("Warning") - log.SetBody("something else happened") + log.Body().SetStringVal("something else happened") } func generateOtlpLogThree() *otlplogs.LogRecord { return &otlplogs.LogRecord{ - ShortName: "logC", - TimestampUnixNano: uint64(TestLogTimestamp), + Name: "logC", + TimeUnixNano: uint64(TestLogTimestamp), DroppedAttributesCount: 1, SeverityNumber: otlplogs.SeverityNumber_WARN, SeverityText: "Warning", - Body: "something else happened", + Body: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "something else happened"}}, } } diff --git a/internal/data/testdata/log_test.go b/internal/data/testdata/log_test.go index dc6b14804efb..59222876ea07 100644 --- a/internal/data/testdata/log_test.go +++ b/internal/data/testdata/log_test.go @@ -112,13 +112,13 @@ func TestToFromOtlpLogWithNils(t *testing.T) { md = GenerateLogDataOneEmptyOneNilLogRecord() rs := md.ResourceLogs().At(0) - assert.EqualValues(t, 2, rs.Logs().Len()) - assert.False(t, rs.Logs().At(0).IsNil()) - assert.True(t, rs.Logs().At(1).IsNil()) + assert.EqualValues(t, 2, rs.InstrumentationLibraryLogs().At(0).Logs().Len()) + assert.False(t, rs.InstrumentationLibraryLogs().At(0).Logs().At(0).IsNil()) + assert.True(t, rs.InstrumentationLibraryLogs().At(0).Logs().At(1).IsNil()) md = GenerateLogDataOneLogOneNil() rl0 := md.ResourceLogs().At(0) - assert.EqualValues(t, 2, rl0.Logs().Len()) - assert.False(t, rl0.Logs().At(0).IsNil()) - assert.True(t, rl0.Logs().At(1).IsNil()) + assert.EqualValues(t, 2, rl0.InstrumentationLibraryLogs().At(0).Logs().Len()) + assert.False(t, rl0.InstrumentationLibraryLogs().At(0).Logs().At(0).IsNil()) + assert.True(t, rl0.InstrumentationLibraryLogs().At(0).Logs().At(1).IsNil()) }