From 79b50d99dde17c5bb085a0204db406d8f6ad880b Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" Date: Thu, 10 Oct 2024 20:32:10 -0700 Subject: [PATCH] fix/respect-nullable-in-schema: Reorganize imports and update nullable fields in Arrow schemas - Reorder imports in components.go for clarity - Make HistogramSum, HistogramMin, and HistogramMax fields nullable in Arrow schemas for ehistogram_dp.go, histogram_dp.go, and number_data_point.go - Remove empty connector factory map initialization in components.go - Swap import order in main_windows.go for consistency --- collector/cmd/otelarrowcol/components.go | 25 ++++++++++----------- collector/cmd/otelarrowcol/main_windows.go | 2 +- pkg/otel/metrics/arrow/ehistogram_dp.go | 6 ++--- pkg/otel/metrics/arrow/histogram_dp.go | 6 ++--- pkg/otel/metrics/arrow/number_data_point.go | 6 ++--- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/collector/cmd/otelarrowcol/components.go b/collector/cmd/otelarrowcol/components.go index 5f82c3d2..53f339b3 100644 --- a/collector/cmd/otelarrowcol/components.go +++ b/collector/cmd/otelarrowcol/components.go @@ -3,24 +3,24 @@ package main import ( + otelarrowexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/otelarrowexporter" + basicauthextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension" + headerssetterextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension" + pprofextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension" + otelarrowreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/otelarrowreceiver" + fileexporter "github.com/open-telemetry/otel-arrow/collector/exporter/fileexporter" + concurrentbatchprocessor "github.com/open-telemetry/otel-arrow/collector/processor/concurrentbatchprocessor" + obfuscationprocessor "github.com/open-telemetry/otel-arrow/collector/processor/obfuscationprocessor" + filereceiver "github.com/open-telemetry/otel-arrow/collector/receiver/filereceiver" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector" "go.opentelemetry.io/collector/exporter" + debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" + otlphttpexporter "go.opentelemetry.io/collector/exporter/otlphttpexporter" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/otelcol" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" - otelarrowexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/otelarrowexporter" - debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" - otlphttpexporter "go.opentelemetry.io/collector/exporter/otlphttpexporter" - fileexporter "github.com/open-telemetry/otel-arrow/collector/exporter/fileexporter" - headerssetterextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension" - basicauthextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension" - pprofextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension" - concurrentbatchprocessor "github.com/open-telemetry/otel-arrow/collector/processor/concurrentbatchprocessor" - obfuscationprocessor "github.com/open-telemetry/otel-arrow/collector/processor/obfuscationprocessor" - otelarrowreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/otelarrowreceiver" - filereceiver "github.com/open-telemetry/otel-arrow/collector/receiver/filereceiver" otlpreceiver "go.opentelemetry.io/collector/receiver/otlpreceiver" ) @@ -80,8 +80,7 @@ func components() (otelcol.Factories, error) { factories.ProcessorModules[concurrentbatchprocessor.NewFactory().Type()] = "github.com/open-telemetry/otel-arrow/collector/processor/concurrentbatchprocessor v0.26.0" factories.ProcessorModules[obfuscationprocessor.NewFactory().Type()] = "github.com/open-telemetry/otel-arrow/collector/processor/obfuscationprocessor v0.26.0" - factories.Connectors, err = connector.MakeFactoryMap( - ) + factories.Connectors, err = connector.MakeFactoryMap() if err != nil { return otelcol.Factories{}, err } diff --git a/collector/cmd/otelarrowcol/main_windows.go b/collector/cmd/otelarrowcol/main_windows.go index a4930afd..60d78b30 100644 --- a/collector/cmd/otelarrowcol/main_windows.go +++ b/collector/cmd/otelarrowcol/main_windows.go @@ -7,9 +7,9 @@ package main import ( "errors" "fmt" + "go.opentelemetry.io/collector/otelcol" "golang.org/x/sys/windows" "golang.org/x/sys/windows/svc" - "go.opentelemetry.io/collector/otelcol" ) func run(params otelcol.CollectorSettings) error { diff --git a/pkg/otel/metrics/arrow/ehistogram_dp.go b/pkg/otel/metrics/arrow/ehistogram_dp.go index 2a112991..6ee06807 100644 --- a/pkg/otel/metrics/arrow/ehistogram_dp.go +++ b/pkg/otel/metrics/arrow/ehistogram_dp.go @@ -53,14 +53,14 @@ var ( {Name: constants.StartTimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.TimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.HistogramCount, Type: arrow.PrimitiveTypes.Uint64, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramSum, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, + {Name: constants.HistogramSum, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, {Name: constants.ExpHistogramScale, Type: arrow.PrimitiveTypes.Int32, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.ExpHistogramZeroCount, Type: arrow.PrimitiveTypes.Uint64, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.ExpHistogramPositive, Type: EHistogramDataPointBucketsDT, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.ExpHistogramNegative, Type: EHistogramDataPointBucketsDT, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.Flags, Type: arrow.PrimitiveTypes.Uint32, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramMin, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramMax, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, + {Name: constants.HistogramMin, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, + {Name: constants.HistogramMax, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, }, nil) ) diff --git a/pkg/otel/metrics/arrow/histogram_dp.go b/pkg/otel/metrics/arrow/histogram_dp.go index 9bb65c3f..8d6646d5 100644 --- a/pkg/otel/metrics/arrow/histogram_dp.go +++ b/pkg/otel/metrics/arrow/histogram_dp.go @@ -56,12 +56,12 @@ var ( {Name: constants.StartTimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.TimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns, Metadata: schema.Metadata(schema.Optional)}, {Name: constants.HistogramCount, Type: arrow.PrimitiveTypes.Uint64, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramSum, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, + {Name: constants.HistogramSum, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, {Name: constants.HistogramBucketCounts, Type: arrow.ListOf(arrow.PrimitiveTypes.Uint64), Metadata: schema.Metadata(schema.Optional)}, {Name: constants.HistogramExplicitBounds, Type: arrow.ListOf(arrow.PrimitiveTypes.Float64), Metadata: schema.Metadata(schema.Optional)}, {Name: constants.Flags, Type: arrow.PrimitiveTypes.Uint32, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramMin, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, - {Name: constants.HistogramMax, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional)}, + {Name: constants.HistogramMin, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, + {Name: constants.HistogramMax, Type: arrow.PrimitiveTypes.Float64, Metadata: schema.Metadata(schema.Optional), Nullable: true}, }, nil) ) diff --git a/pkg/otel/metrics/arrow/number_data_point.go b/pkg/otel/metrics/arrow/number_data_point.go index f4e62ecd..d605d397 100644 --- a/pkg/otel/metrics/arrow/number_data_point.go +++ b/pkg/otel/metrics/arrow/number_data_point.go @@ -39,10 +39,10 @@ var ( {Name: constants.ID, Type: arrow.PrimitiveTypes.Uint32, Metadata: schema.Metadata(schema.DeltaEncoding)}, // The ID of the parent scope metric. {Name: constants.ParentID, Type: arrow.PrimitiveTypes.Uint16}, - {Name: constants.StartTimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns}, + {Name: constants.StartTimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns, Nullable: true}, {Name: constants.TimeUnixNano, Type: arrow.FixedWidthTypes.Timestamp_ns}, - {Name: constants.IntValue, Type: arrow.PrimitiveTypes.Int64}, - {Name: constants.DoubleValue, Type: arrow.PrimitiveTypes.Float64}, + {Name: constants.IntValue, Type: arrow.PrimitiveTypes.Int64, Nullable: true}, + {Name: constants.DoubleValue, Type: arrow.PrimitiveTypes.Float64, Nullable: true}, {Name: constants.Flags, Type: arrow.PrimitiveTypes.Uint32, Metadata: schema.Metadata(schema.Optional)}, }, nil) )