From bfbcde5c8f506ed55c2d010638a0c71a98445834 Mon Sep 17 00:00:00 2001 From: jackgopack4 Date: Fri, 24 Jan 2025 13:48:17 -0500 Subject: [PATCH] apply suggestions from code review --- .../datadogconnector-add-stats-obfuscation.yaml | 2 +- connector/datadogconnector/connector_native.go | 2 -- .../datadogconnector/connector_native_test.go | 15 ++++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.chloggen/datadogconnector-add-stats-obfuscation.yaml b/.chloggen/datadogconnector-add-stats-obfuscation.yaml index 73d2997afd1d6..66ab2473586ca 100644 --- a/.chloggen/datadogconnector-add-stats-obfuscation.yaml +++ b/.chloggen/datadogconnector-add-stats-obfuscation.yaml @@ -10,7 +10,7 @@ component: datadogconnector note: Support obfuscating sql queries in APM stats # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [35401] +issues: [37457] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. diff --git a/connector/datadogconnector/connector_native.go b/connector/datadogconnector/connector_native.go index e72b3c2095d22..5f2ff50863fcb 100644 --- a/connector/datadogconnector/connector_native.go +++ b/connector/datadogconnector/connector_native.go @@ -116,8 +116,6 @@ func (c *traceToMetricConnectorNative) Shutdown(context.Context) error { c.logger.Info("Stopping obfuscator and concentrator") // stop the obfuscator and concentrator and wait for the run loop to exit c.obfuscator.Stop() - c.logger.Info("Stopping concentrator") - // stop the concentrator and wait for the run loop to exit c.concentrator.Stop() c.exit <- struct{}{} // signal exit <-c.exit // wait for close diff --git a/connector/datadogconnector/connector_native_test.go b/connector/datadogconnector/connector_native_test.go index 394838ed4fce9..af6637ef8d7e1 100644 --- a/connector/datadogconnector/connector_native_test.go +++ b/connector/datadogconnector/connector_native_test.go @@ -73,6 +73,8 @@ func creteConnectorNativeWithCfg(t *testing.T, cfg *Config) (*traceToMetricConne connector, ok := tconn.(*traceToMetricConnectorNative) require.True(t, ok) + oconf := obfuscate.Config{Redis: obfuscate.RedisConfig{Enabled: false}} + connector.obfuscator = obfuscate.NewObfuscator(oconf) return connector, metricsSink } @@ -273,12 +275,15 @@ func testMeasuredAndClientKindNative(t *testing.T, enableOperationAndResourceNam func TestObfuscate(t *testing.T) { cfg := NewFactory().CreateDefaultConfig().(*Config) cfg.Traces.BucketInterval = time.Second - connector, metricsSink := creteConnectorNativeWithCfg(t, cfg) - oconf := obfuscate.Config{Redis: obfuscate.RedisConfig{Enabled: true}} - connector.obfuscator = obfuscate.NewObfuscator(oconf) - connector.tcfg.Features["enable_receive_resource_spans_v2"] = struct{}{} - connector.tcfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{} + if err := featuregate.GlobalRegistry().Set("datadog.EnableReceiveResourceSpansV2", true); err != nil { + t.Fatal(err) + } + if err := featuregate.GlobalRegistry().Set("datadog.EnableOperationAndResourceNameV2", true); err != nil { + t.Fatal(err) + } + + connector, metricsSink := creteConnectorNativeWithCfg(t, cfg) err := connector.Start(context.Background(), componenttest.NewNopHost()) require.NoError(t, err)