diff --git a/.github/workflows/verify-collector-ocb.yml b/.github/workflows/verify-collector-ocb.yml index 64a6d4ef8..eeda5e6a6 100644 --- a/.github/workflows/verify-collector-ocb.yml +++ b/.github/workflows/verify-collector-ocb.yml @@ -20,6 +20,7 @@ jobs: working-directory: ./collector run: | if [[ $(git diff --exit-code) ]]; then + git diff echo "odigos collector distribution module is not in sync with builder config. Please run 'make genodigoscol' in 'collector' directory and commit the changes." exit 1 fi diff --git a/cli/cmd/resources/profiles.go b/cli/cmd/resources/profiles.go index 6f4738f73..2d70f6f8a 100644 --- a/cli/cmd/resources/profiles.go +++ b/cli/cmd/resources/profiles.go @@ -31,6 +31,11 @@ var ( ShortDescription: "Collect db payload from the cluster where supported with default settings", ClientObject: &odigosv1alpha1.InstrumentationRule{}, } + queryOperationDetector = Profile{ + ProfileName: common.ProfileName("query-operation-detector"), + ShortDescription: "Detect the SQL operation name from the query text", + ClientObject: &odigosv1alpha1.Processor{}, + } semconvUpgraderProfile = Profile{ ProfileName: common.ProfileName("semconv"), ShortDescription: "Upgrade and align some attribute names to a newer version of the OpenTelemetry semantic conventions", @@ -62,8 +67,8 @@ var ( } kratosProfile = Profile{ ProfileName: common.ProfileName("kratos"), - ShortDescription: "Bundle profile that includes db-payload-collection, semconv, category-attributes, copy-scope, hostname-as-podname, java-native-instrumentations, code-attributes", - Dependencies: []common.ProfileName{"db-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations", "code-attributes"}, + ShortDescription: "Bundle profile that includes db-payload-collection, semconv, category-attributes, copy-scope, hostname-as-podname, java-native-instrumentations, code-attributes, query-operation-detector", + Dependencies: []common.ProfileName{"db-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations", "code-attributes", "query-operation-detector"}, } ) @@ -72,7 +77,7 @@ func GetAvailableCommunityProfiles() []Profile { } func GetAvailableOnPremProfiles() []Profile { - return append([]Profile{fullPayloadCollectionProfile, dbPayloadCollectionProfile, categoryAttributesProfile, hostnameAsPodNameProfile, javaNativeInstrumentationsProfile, kratosProfile}, + return append([]Profile{fullPayloadCollectionProfile, dbPayloadCollectionProfile, categoryAttributesProfile, hostnameAsPodNameProfile, javaNativeInstrumentationsProfile, kratosProfile, queryOperationDetector}, GetAvailableCommunityProfiles()...) } diff --git a/cli/cmd/resources/profiles/query-operation-detector.yaml b/cli/cmd/resources/profiles/query-operation-detector.yaml new file mode 100644 index 000000000..a22d1f701 --- /dev/null +++ b/cli/cmd/resources/profiles/query-operation-detector.yaml @@ -0,0 +1,14 @@ +apiVersion: odigos.io/v1alpha1 +kind: Processor +metadata: + name: query-operation-detector + namespace: odigos-system +spec: + type: odigossqldboperationprocessor + processorName: query-operation-detector + notes: "Auto generated rule from query-operation-detector profile. Do not edit." + processorConfig: {} + signals: + - TRACES + collectorRoles: + - CLUSTER_GATEWAY \ No newline at end of file diff --git a/collector/builder-config.yaml b/collector/builder-config.yaml index b9dc0d6af..a3f0fd476 100644 --- a/collector/builder-config.yaml +++ b/collector/builder-config.yaml @@ -61,6 +61,7 @@ exporters: processors: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigosresourcenameprocessor v0.106.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor v0.106.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor v0.106.0 - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.106.0 - gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.106.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.106.0 @@ -107,6 +108,7 @@ connectors: replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigosresourcenameprocessor => ../processors/odigosresourcenameprocessor - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor => ../processors/odigossamplingprocessor + - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor => ../processors/odigossqldboperationprocessor - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/exporter/azureblobstorageexporter => ../exporters/azureblobstorageexporter - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/exporter/googlecloudstorageexporter => ../exporters/googlecloudstorageexporter - github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigostrafficmetrics => ../processors/odigostrafficmetrics \ No newline at end of file diff --git a/collector/odigosotelcol/components.go b/collector/odigosotelcol/components.go index 8bf1e2130..581712a10 100644 --- a/collector/odigosotelcol/components.go +++ b/collector/odigosotelcol/components.go @@ -67,6 +67,7 @@ import ( basicauthextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension" odigosresourcenameprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigosresourcenameprocessor" odigossamplingprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor" + odigossqldboperationprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor" batchprocessor "go.opentelemetry.io/collector/processor/batchprocessor" memorylimiterprocessor "go.opentelemetry.io/collector/processor/memorylimiterprocessor" attributesprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor" @@ -230,6 +231,7 @@ func components() (otelcol.Factories, error) { factories.Processors, err = processor.MakeFactoryMap( odigosresourcenameprocessor.NewFactory(), odigossamplingprocessor.NewFactory(), + odigossqldboperationprocessor.NewFactory(), batchprocessor.NewFactory(), memorylimiterprocessor.NewFactory(), attributesprocessor.NewFactory(), @@ -259,6 +261,7 @@ func components() (otelcol.Factories, error) { factories.ProcessorModules = make(map[component.Type]string, len(factories.Processors)) factories.ProcessorModules[odigosresourcenameprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigosresourcenameprocessor v0.106.0" factories.ProcessorModules[odigossamplingprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor v0.106.0" + factories.ProcessorModules[odigossqldboperationprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor v0.106.0" factories.ProcessorModules[batchprocessor.NewFactory().Type()] = "go.opentelemetry.io/collector/processor/batchprocessor v0.106.0" factories.ProcessorModules[memorylimiterprocessor.NewFactory().Type()] = "go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.106.0" factories.ProcessorModules[attributesprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.106.0" diff --git a/collector/odigosotelcol/go.mod b/collector/odigosotelcol/go.mod index 9adfe1a3c..aa93c06ee 100644 --- a/collector/odigosotelcol/go.mod +++ b/collector/odigosotelcol/go.mod @@ -57,6 +57,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/odigos/exporter/googlecloudstorageexporter v0.106.0 github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigosresourcenameprocessor v0.106.0 github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor v0.106.0 + github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor v0.106.0 github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigostrafficmetrics v0.106.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.106.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.106.0 @@ -281,7 +282,7 @@ require ( github.com/elastic/go-sysinfo v1.7.1 // indirect github.com/elastic/go-windows v1.0.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/envoyproxy/go-control-plane v0.12.0 // indirect + github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect github.com/expr-lang/expr v1.16.9 // indirect github.com/fatih/color v1.16.0 // indirect @@ -451,6 +452,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect github.com/prometheus/client_golang v1.19.1 // indirect @@ -567,7 +569,7 @@ require ( google.golang.org/genproto v0.0.0-20240722135656-d784300faade // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240709173604-40e1e62336c5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect - google.golang.org/grpc v1.65.0 // indirect + google.golang.org/grpc v1.66.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect @@ -593,6 +595,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/odigos/process replace github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossamplingprocessor => ../processors/odigossamplingprocessor +replace github.com/open-telemetry/opentelemetry-collector-contrib/odigos/processor/odigossqldboperationprocessor => ../processors/odigossqldboperationprocessor + replace github.com/open-telemetry/opentelemetry-collector-contrib/odigos/exporter/azureblobstorageexporter => ../exporters/azureblobstorageexporter replace github.com/open-telemetry/opentelemetry-collector-contrib/odigos/exporter/googlecloudstorageexporter => ../exporters/googlecloudstorageexporter diff --git a/collector/odigosotelcol/go.sum b/collector/odigosotelcol/go.sum index ad05a6db8..0ca8a48b2 100644 --- a/collector/odigosotelcol/go.sum +++ b/collector/odigosotelcol/go.sum @@ -528,8 +528,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.12.0 h1:4X+VP1GHd1Mhj6IB5mMeGbLCleqxjletLK6K0rbxyZI= -github.com/envoyproxy/go-control-plane v0.12.0/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0= +github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155 h1:IgJPqnrlY2Mr4pYB6oaMKvFvwJ9H+X6CCY5x1vCTcpc= +github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155/go.mod h1:5Wkq+JduFtdAXihLmeTJf+tRYIT4KBc2vPXDhwVo1pA= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= @@ -1356,6 +1356,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -2215,8 +2217,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= +google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/collector/processors/odigossqldboperationprocessor/README.md b/collector/processors/odigossqldboperationprocessor/README.md new file mode 100644 index 000000000..888bc4c39 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/README.md @@ -0,0 +1,5 @@ +# SQL DB Operation Processor + +The SQL DB Operation Processor is responsible for detecting the type of SQL operation performed by analyzing the SQL query within a trace. It extracts the query text, checks for common SQL operations (SELECT, INSERT, UPDATE, DELETE, CREATE), and assigns the appropriate operation name to the trace span. + +This processor ensures that each trace contains clear metadata about the database operation performed, enabling better observability and trace analysis. diff --git a/collector/processors/odigossqldboperationprocessor/config.go b/collector/processors/odigossqldboperationprocessor/config.go new file mode 100644 index 000000000..56feaeb20 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/config.go @@ -0,0 +1,15 @@ +package odigossqldboperationprocessor + +import ( + "go.opentelemetry.io/collector/component" +) + +type Config struct { +} + +var _ component.Config = (*Config)(nil) + +func (cfg *Config) Validate() error { + + return nil +} diff --git a/collector/processors/odigossqldboperationprocessor/factory.go b/collector/processors/odigossqldboperationprocessor/factory.go new file mode 100644 index 000000000..bd7665af3 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/factory.go @@ -0,0 +1,41 @@ +package odigossqldboperationprocessor + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processorhelper" +) + +// NewFactory returns a new factory for the Resource processor. +func NewFactory() processor.Factory { + return processor.NewFactory( + component.MustNewType("odigossqldboperationprocessor"), + createDefaultConfig, + processor.WithTraces(createTracesProcessor, component.StabilityLevelBeta), + ) +} + +func createDefaultConfig() component.Config { + return &Config{} +} + +func createTracesProcessor( + ctx context.Context, + set processor.Settings, + cfg component.Config, + nextConsumer consumer.Traces) (processor.Traces, error) { + + proc := &DBOperationProcessor{logger: set.Logger} + + return processorhelper.NewTracesProcessor( + ctx, + set, + cfg, + nextConsumer, + proc.processTraces, + processorhelper.WithCapabilities(consumer.Capabilities{MutatesData: true}), + ) +} diff --git a/collector/processors/odigossqldboperationprocessor/generated_component_test.go b/collector/processors/odigossqldboperationprocessor/generated_component_test.go new file mode 100644 index 000000000..ac5209816 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/generated_component_test.go @@ -0,0 +1,92 @@ +package odigossqldboperationprocessor + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processortest" +) + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, "odigossqldboperationprocessor", NewFactory().Type().String()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + tests := []struct { + name string + createFn func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) + }{ + + { + name: "traces", + createFn: func(ctx context.Context, set processor.Settings, cfg component.Config) (component.Component, error) { + return factory.CreateTracesProcessor(ctx, set, cfg, consumertest.NewNop()) + }, + }, + } + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + + for _, test := range tests { + t.Run(test.name+"-shutdown", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run(test.name+"-lifecycle", func(t *testing.T) { + c, err := test.createFn(context.Background(), processortest.NewNopSettings(), cfg) + require.NoError(t, err) + host := componenttest.NewNopHost() + err = c.Start(context.Background(), host) + require.NoError(t, err) + require.NotPanics(t, func() { + switch test.name { + case "traces": + e, ok := c.(processor.Traces) + require.True(t, ok) + traces := generateLifecycleTestTraces() + if !e.Capabilities().MutatesData { + traces.MarkReadOnly() + } + err = e.ConsumeTraces(context.Background(), traces) + } + }) + require.NoError(t, err) + err = c.Shutdown(context.Background()) + require.NoError(t, err) + }) + } +} + +func generateLifecycleTestTraces() ptrace.Traces { + traces := ptrace.NewTraces() + rs := traces.ResourceSpans().AppendEmpty() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/collector/processors/odigossqldboperationprocessor/generated_package_test.go b/collector/processors/odigossqldboperationprocessor/generated_package_test.go new file mode 100644 index 000000000..aa0da6e50 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/generated_package_test.go @@ -0,0 +1,11 @@ +package odigossqldboperationprocessor + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/collector/processors/odigossqldboperationprocessor/go.mod b/collector/processors/odigossqldboperationprocessor/go.mod new file mode 100644 index 000000000..fed85aec1 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/go.mod @@ -0,0 +1,65 @@ +module odigossqldboperationprocessor + +go 1.22.0 + +require ( + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/component v0.106.0 + go.opentelemetry.io/collector/confmap v0.106.0 + go.opentelemetry.io/collector/consumer v0.106.0 + go.opentelemetry.io/collector/consumer/consumertest v0.106.0 + go.opentelemetry.io/collector/pdata v1.12.0 + go.opentelemetry.io/collector/processor v0.106.0 + go.opentelemetry.io/otel v1.28.0 + go.uber.org/goleak v1.3.0 + go.uber.org/zap v1.27.0 +) + +require github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.106.0 // indirect + +require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-viper/mapstructure/v2 v2.0.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/knadh/koanf/maps v0.1.1 // indirect + github.com/knadh/koanf/providers/confmap v0.1.0 // indirect + github.com/knadh/koanf/v2 v2.1.1 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.106.0 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/collector v0.106.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.106.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.106.0 // indirect + go.opentelemetry.io/collector/featuregate v1.12.0 // indirect + go.opentelemetry.io/collector/internal/globalgates v0.106.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.106.0 // indirect + go.opentelemetry.io/collector/pdata/testdata v0.106.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/grpc v1.66.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/collector/processors/odigossqldboperationprocessor/go.sum b/collector/processors/odigossqldboperationprocessor/go.sum new file mode 100644 index 000000000..e7db5f618 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/go.sum @@ -0,0 +1,158 @@ +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.0.0 h1:dhn8MZ1gZ0mzeodTG3jt5Vj/o87xZKuNAprG2mQfMfc= +github.com/go-viper/mapstructure/v2 v2.0.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= +github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= +github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= +github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= +github.com/knadh/koanf/v2 v2.1.1 h1:/R8eXqasSTsmDCsAyYj+81Wteg8AqrV9CP6gvsTsOmM= +github.com/knadh/koanf/v2 v2.1.1/go.mod h1:4mnTRbZCK+ALuBXHZMjDfG9y714L7TykVnZkXbMU3Es= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.106.0 h1:c6uX5fUZ48z7ezTCBDrFZYfM6yolEe1kWr4RkPMh5B0= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.106.0/go.mod h1:Li8dLFzDCiSt8cIO5263eOUOLuPlmktWw9xksv/4W8k= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.106.0 h1:jYoM8RiT2yCsuGKZpNYeizraOMZ86TGOEeBtkiVE0io= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.106.0/go.mod h1:ITs5yhRHFANrGSYQAlbX1FOJ1CD5LqNoakwB0b/H8AE= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.106.0 h1:3swX+tPbGC+7tM69jkRUf5OsLxtcik1pcGjxiCdhE/g= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.106.0/go.mod h1:ehzaiDdkrww7l1Stvse5GCOAsAZOpFcgeIbB/2PqFs4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector v0.106.0 h1:SeKdfCT84j1P2GlfWxNPpuGl4qBRX641fxC6ONeGsGQ= +go.opentelemetry.io/collector v0.106.0/go.mod h1:qm5bE3SaL95zwV/hL8Su170GMUGKNDfNL72wJ+87xD8= +go.opentelemetry.io/collector/component v0.106.0 h1:2CJbqV8taL7nBKuHxeULvJySa4+gfsgvAENb+lS/vYM= +go.opentelemetry.io/collector/component v0.106.0/go.mod h1:lAcHA7k8WVzJRxlkOtOWqgf9+2uRJLfLUiYJapRbr5w= +go.opentelemetry.io/collector/config/configtelemetry v0.106.0 h1:UEUO2pkLpPoAi92MoLhVu3q7mVZONFAxAGorJCtF+aE= +go.opentelemetry.io/collector/config/configtelemetry v0.106.0/go.mod h1:WxWKNVAQJg/Io1nA3xLgn/DWLE/W1QOB2+/Js3ACi40= +go.opentelemetry.io/collector/confmap v0.106.0 h1:oZ/QfGjtOTz6sEbNkp8CxSwDFRHXej8u6MywvhTzjqI= +go.opentelemetry.io/collector/confmap v0.106.0/go.mod h1:X+nvuiQs3zdeXKkrEX1Ta3R49eLZ2/NYZLs3KUp1pik= +go.opentelemetry.io/collector/consumer v0.106.0 h1:sXq7AmpqILo6+RaVvuXtHNJNCI7uriVkgCX7zYvysyo= +go.opentelemetry.io/collector/consumer v0.106.0/go.mod h1:a1pWsQC+Gw8WbLVN4Tk+y1FzU5dTX27C04WrLiBGDmw= +go.opentelemetry.io/collector/consumer/consumerprofiles v0.106.0 h1:RjjHTkfo4FkATyZ5drzigXpcWjUOoPpwdsPxMcE3wWc= +go.opentelemetry.io/collector/consumer/consumerprofiles v0.106.0/go.mod h1:CEjdD/YIK9eh0CCLFfD330Zf3upMM0JkRmi9IVjiMnI= +go.opentelemetry.io/collector/consumer/consumertest v0.106.0 h1:gLBal8/6axYDlUDAwIdQs8tWq5Vp2Qv15OYLATWgVL0= +go.opentelemetry.io/collector/consumer/consumertest v0.106.0/go.mod h1:oLDV3fCrndcWxsDGr8iMDejwq9qy0STb0ntfTsHFLfQ= +go.opentelemetry.io/collector/featuregate v1.12.0 h1:l5WbV2vMQd2bL8ubfGrbKNtZaeJRckE12CTHvRe47Tw= +go.opentelemetry.io/collector/featuregate v1.12.0/go.mod h1:PsOINaGgTiFc+Tzu2K/X2jP+Ngmlp7YKGV1XrnBkH7U= +go.opentelemetry.io/collector/internal/globalgates v0.106.0 h1:Rg6ZM2DROO4nx93nEFoNInisUGLHBq4IAU0oK1/T7jw= +go.opentelemetry.io/collector/internal/globalgates v0.106.0/go.mod h1:Z5US6O2xkZAtxVSSBnHAPFZwPhFoxlyKLUvS67Vx4gc= +go.opentelemetry.io/collector/pdata v1.12.0 h1:Xx5VK1p4VO0md8MWm2icwC1MnJ7f8EimKItMWw46BmA= +go.opentelemetry.io/collector/pdata v1.12.0/go.mod h1:MYeB0MmMAxeM0hstCFrCqWLzdyeYySim2dG6pDT6nYI= +go.opentelemetry.io/collector/pdata/pprofile v0.106.0 h1:LvZD2ARCBmPUGghXaHDD+lD3tnS60pytYh3lp1fH/SU= +go.opentelemetry.io/collector/pdata/pprofile v0.106.0/go.mod h1:chr7lMJIzyXkccnPRkIPhyXtqLZLSReZYhwsggOGEfg= +go.opentelemetry.io/collector/pdata/testdata v0.106.0 h1:LNVLj+r/rPWOniDtoFCJAWJ1ShlDiFkB5N5Ui/K9kSE= +go.opentelemetry.io/collector/pdata/testdata v0.106.0/go.mod h1:2TXzn9v74UPUH+ktzioP6cFaFd6/E8TDe8NVPyA4CiA= +go.opentelemetry.io/collector/processor v0.106.0 h1:9LjBUk/ILbhww2BHG0Om8vYR2aQoBJrJjhAwJ0x2V4U= +go.opentelemetry.io/collector/processor v0.106.0/go.mod h1:fc1mKAaG0YsP/wa+PWisiLqJPVVsH+42fLQBhPqhfMo= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= +google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/collector/processors/odigossqldboperationprocessor/metadata.yaml b/collector/processors/odigossqldboperationprocessor/metadata.yaml new file mode 100644 index 000000000..64014230f --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/metadata.yaml @@ -0,0 +1,8 @@ +type: odigossqldboperationprocessor +status: + class: processor + stability: + beta: [traces] + distributions: [contrib] + codeowners: + active: [tamird] diff --git a/collector/processors/odigossqldboperationprocessor/processor.go b/collector/processors/odigossqldboperationprocessor/processor.go new file mode 100644 index 000000000..7e8c528a5 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/processor.go @@ -0,0 +1,101 @@ +package odigossqldboperationprocessor + +import ( + "context" + "strings" + + "go.opentelemetry.io/collector/pdata/ptrace" + semconv "go.opentelemetry.io/otel/semconv/v1.26.0" + "go.uber.org/zap" +) + +type DBOperationProcessor struct { + logger *zap.Logger +} + +const ( + OperationSelect string = "SELECT" + OperationInsert string = "INSERT" + OperationUpdate string = "UPDATE" + OperationDelete string = "DELETE" + OperationCreate string = "CREATE" + OperationDrop string = "DROP" + OperationAlter string = "ALTER" + OperationUnknown string = "UNKNOWN" +) + +func (sp *DBOperationProcessor) processTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) { + resources := td.ResourceSpans() + // Iterate over resources + for r := 0; r < resources.Len(); r++ { + scoreSpan := resources.At(r).ScopeSpans() + + // Iterate over scopes + for j := 0; j < scoreSpan.Len(); j++ { + ils := scoreSpan.At(j) + + // Iterate over spans + for k := 0; k < ils.Spans().Len(); k++ { + span := ils.Spans().At(k) + + // Get the `db.query.text`` attribute, If no found, continue to the next span + dbQueryText, found := span.Attributes().Get(string(semconv.DBQueryTextKey)) + if !found { + continue + } + + // Check if `db.operation.name` is already defined, If already defined, continue to the next span + _, operationNameExists := span.Attributes().Get(string(semconv.DBOperationNameKey)) + if operationNameExists { + continue + } + + // Detect the `db.operation.name` from the query text + operationName := DetectSQLOperationName(dbQueryText.AsString()) + + // Only set the `db.operation.name` if the detected operation name is not "UNKNOWN" + if operationName != OperationUnknown { + span.Attributes().PutStr(string(semconv.DBOperationNameKey), operationName) + } + } + } + } + return td, nil +} + +// DetectSQLType is a simple heuristic to determine the SQL operation by checking if +// the first word of the query is a common keyword (e.g., SELECT, INSERT, UPDATE, DELETE, CREATE). +// It returns the corresponding operation name or "UNKNOWN" if no match is found, +// providing an efficient, lightweight solution for quick query classification. +func DetectSQLOperationName(query string) string { + query = strings.TrimSpace(query) + if len(query) == 0 { + return OperationUnknown + } + + firstWord := extractFirstWord(query) + + // Convert the first word to uppercase for comparison + firstWord = strings.ToUpper(firstWord) + + switch firstWord { + case OperationSelect, OperationInsert, OperationUpdate, OperationDelete, OperationCreate, OperationDrop, OperationAlter: + return firstWord + default: + return OperationUnknown + } +} + +// This function handles common cases like trimming whitespace, tabs, and newlines. +// We avoid using `strings.Fields` here to prevent unnecessary allocations (especially for large queries). +// Instead, we iterate through the string only until we find the first space or delimiter, making it more efficient. +func extractFirstWord(query string) string { + for i := 0; i < len(query); i++ { + if query[i] == ' ' || query[i] == '\t' || query[i] == '\n' { + return query[:i] + } + } + + // return the entire query (single-word case) + return query +} diff --git a/collector/processors/odigossqldboperationprocessor/processor_test.go b/collector/processors/odigossqldboperationprocessor/processor_test.go new file mode 100644 index 000000000..158a613a0 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/processor_test.go @@ -0,0 +1,110 @@ +package odigossqldboperationprocessor + +import ( + "context" + "testing" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/ptrace" + semconv "go.opentelemetry.io/otel/semconv/v1.26.0" + "go.uber.org/zap" +) + +func generateTestTrace(dbQueryText string, dbOperationNameExists bool) ptrace.Traces { + td := ptrace.NewTraces() + rs := td.ResourceSpans().AppendEmpty() + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + + if dbQueryText != "" { + span.Attributes().PutStr(string(semconv.DBQueryTextKey), dbQueryText) + } + if dbOperationNameExists { + span.Attributes().PutStr(string(semconv.DBOperationNameKey), "EXISTING_OPERATION") + } + return td +} + +func TestDBOperationProcessor_NoDbQueryText(t *testing.T) { + logger, _ := zap.NewDevelopment() // Enable logging in development mode + processor := &DBOperationProcessor{logger: logger} + + // Generate trace with no db.query.text attribute + logger.Info("Running test: NoDbQueryText - No db.query.text attribute in span") + traces := generateTestTrace("", false) + + logger.Info("Generated traces", zap.Any("Traces", traces)) + processedTraces, err := processor.processTraces(context.Background(), traces) + + logger.Info("Processed traces", zap.Any("ProcessedTraces", processedTraces)) + require.NoError(t, err) + + // Ensure the processed traces match the original + logger.Info("Checking trace comparison") + require.NoError(t, ptracetest.CompareTraces(traces, processedTraces)) + + logger.Info("Test passed: NoDbQueryText") +} + +func TestDBOperationProcessor_ExistingDbOperationName(t *testing.T) { + logger, _ := zap.NewDevelopment() // Enable logging in development mode + processor := &DBOperationProcessor{logger: logger} + + // Generate trace with an existing db.operation.name attribute + logger.Info("Running test: ExistingDbOperationName - db.operation.name already exists") + traces := generateTestTrace("SELECT * FROM users", true) + + logger.Info("Generated traces", zap.String("Query", "SELECT * FROM users"), zap.Any("TracesCount ", traces.SpanCount())) + processedTraces, err := processor.processTraces(context.Background(), traces) + + logger.Info("Processed traces", zap.Any("ProcessedTraces", processedTraces)) + require.NoError(t, err) + + // Ensure that db.operation.name was not overwritten + span := processedTraces.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0) + attrValue, exists := span.Attributes().Get(string(semconv.DBOperationNameKey)) + + // Print the current attribute value + logger.Info("Checking db.operation.name", zap.String("OperationName", attrValue.AsString()), zap.Bool("Exists", exists)) + require.True(t, exists) + require.Equal(t, "EXISTING_OPERATION", attrValue.AsString()) + + logger.Info("Test passed: ExistingDbOperationName", zap.String("Detected Operation", attrValue.AsString())) +} + +func TestDBOperationProcessor_SetDbOperationName(t *testing.T) { + logger, _ := zap.NewDevelopment() // Enable logging in development mode + processor := &DBOperationProcessor{logger: logger} + + testCases := []struct { + query string + expected string + }{ + {"SELECT * FROM users", "SELECT"}, + {"INSERT INTO users VALUES(1)", "INSERT"}, + {"UPDATE users SET name='John'", "UPDATE"}, + {"DELETE FROM users WHERE id=1", "DELETE"}, + {"CREATE TABLE users", "CREATE"}, + {"", "UNKNOWN"}, + } + + for _, tc := range testCases { + logger.Info("Running test: SetDbOperationName", zap.String("Query", tc.query), zap.String("Expected Operation", tc.expected)) + traces := generateTestTrace(tc.query, false) + processedTraces, err := processor.processTraces(context.Background(), traces) + + require.NoError(t, err) + + // Ensure that db.operation.name was set correctly + span := processedTraces.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0) + attrValue, exists := span.Attributes().Get(string(semconv.DBOperationNameKey)) + // Check if the attribute exists before asserting its value + if exists { + require.Equal(t, tc.expected, attrValue.AsString()) + logger.Info("Test passed: SetDbOperationName", zap.String("Query", tc.query), zap.String("Detected Operation", attrValue.AsString())) + } else { + require.Equal(t, tc.expected, "UNKNOWN") + logger.Info("Test passed: SetDbOperationName", zap.String("Query", tc.query), zap.String("Detected Operation", "UNKNOWN")) + } + } +}