From 0cb434c414e2414a091b383cb92547b78093dc25 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 8 Feb 2024 18:05:21 +0100 Subject: [PATCH] [chore] Even more one-off fixes for component.Type changes --- connector/servicegraphconnector/factory.go | 4 +--- exporter/awsxrayexporter/awsxray.go | 2 +- processor/groupbytraceprocessor/metrics.go | 16 ++++++++-------- receiver/receivercreator/config_test.go | 4 ++-- receiver/receivercreator/receiver_test.go | 2 +- receiver/solacereceiver/observability.go | 2 +- .../mockdatadogagentexporter/factory.go | 6 +++--- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/connector/servicegraphconnector/factory.go b/connector/servicegraphconnector/factory.go index 4b720af11ba6..daec2316c71c 100644 --- a/connector/servicegraphconnector/factory.go +++ b/connector/servicegraphconnector/factory.go @@ -18,8 +18,6 @@ import ( ) const ( - // The value of "type" key in configuration. - typeStr = "servicegraph" // The stability level of the processor. connectorStability = component.StabilityLevelDevelopment virtualNodeFeatureGateID = "connector.servicegraph.virtualNode" @@ -54,7 +52,7 @@ func init() { // NewFactory returns a ConnectorFactory. func NewFactory() connector.Factory { return connector.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, connector.WithTracesToMetrics(createTracesToMetricsConnector, metadata.TracesToMetricsStability), ) diff --git a/exporter/awsxrayexporter/awsxray.go b/exporter/awsxrayexporter/awsxray.go index 6cd3e77be21a..23bca1bf446c 100644 --- a/exporter/awsxrayexporter/awsxray.go +++ b/exporter/awsxrayexporter/awsxray.go @@ -34,7 +34,7 @@ func newTracesExporter( cn awsutil.ConnAttr, registry telemetry.Registry, ) (exporter.Traces, error) { - typeLog := zap.String("type", string(set.ID.Type())) + typeLog := zap.String("type", set.ID.Type().String()) nameLog := zap.String("name", set.ID.String()) logger := set.Logger awsConfig, session, err := awsutil.GetAWSConfigSession(logger, cn, &cfg.AWSSessionSettings) diff --git a/processor/groupbytraceprocessor/metrics.go b/processor/groupbytraceprocessor/metrics.go index 52584db63e5e..eabd362dbdbb 100644 --- a/processor/groupbytraceprocessor/metrics.go +++ b/processor/groupbytraceprocessor/metrics.go @@ -27,50 +27,50 @@ var ( func metricViews() []*view.View { return []*view.View{ { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mNumTracesConf.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mNumTracesConf.Name()), Measure: mNumTracesConf, Description: mNumTracesConf.Description(), Aggregation: view.LastValue(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mNumEventsInQueue.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mNumEventsInQueue.Name()), Measure: mNumEventsInQueue, Description: mNumEventsInQueue.Description(), Aggregation: view.LastValue(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mNumTracesInMemory.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mNumTracesInMemory.Name()), Measure: mNumTracesInMemory, Description: mNumTracesInMemory.Description(), Aggregation: view.LastValue(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mTracesEvicted.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mTracesEvicted.Name()), Measure: mTracesEvicted, Description: mTracesEvicted.Description(), // sum allows us to start from 0, count will only show up if there's at least one eviction, which might take a while to happen (if ever!) Aggregation: view.Sum(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mReleasedSpans.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mReleasedSpans.Name()), Measure: mReleasedSpans, Description: mReleasedSpans.Description(), Aggregation: view.Sum(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mReleasedTraces.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mReleasedTraces.Name()), Measure: mReleasedTraces, Description: mReleasedTraces.Description(), Aggregation: view.Sum(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mIncompleteReleases.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mIncompleteReleases.Name()), Measure: mIncompleteReleases, Description: mIncompleteReleases.Description(), Aggregation: view.Sum(), }, { - Name: processorhelper.BuildCustomMetricName(string(metadata.Type), mEventLatency.Name()), + Name: processorhelper.BuildCustomMetricName(metadata.Type.String(), mEventLatency.Name()), Measure: mEventLatency, Description: mEventLatency.Description(), TagKeys: []tag.Key{ diff --git a/receiver/receivercreator/config_test.go b/receiver/receivercreator/config_test.go index 9daee44b7602..533118e9f5b1 100644 --- a/receiver/receivercreator/config_test.go +++ b/receiver/receivercreator/config_test.go @@ -139,7 +139,7 @@ func TestInvalidResourceAttributeEndpointType(t *testing.T) { factories, err := otelcoltest.NopFactories() require.NoError(t, err) - factories.Receivers[("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} + factories.Receivers[component.MustNewType("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} factory := NewFactory() factories.Receivers[metadata.Type] = factory @@ -152,7 +152,7 @@ func TestInvalidReceiverResourceAttributeValueType(t *testing.T) { factories, err := otelcoltest.NopFactories() require.NoError(t, err) - factories.Receivers[("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} + factories.Receivers[component.MustNewType("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} factory := NewFactory() factories.Receivers[metadata.Type] = factory diff --git a/receiver/receivercreator/receiver_test.go b/receiver/receivercreator/receiver_test.go index 6e5b70d3f87f..68d0bf801846 100644 --- a/receiver/receivercreator/receiver_test.go +++ b/receiver/receivercreator/receiver_test.go @@ -60,7 +60,7 @@ func TestMockedEndToEnd(t *testing.T) { require.NoError(t, err) factories, _ := otelcoltest.NopFactories() - factories.Receivers[("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} + factories.Receivers[component.MustNewType("nop")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} factory := NewFactory() factories.Receivers[metadata.Type] = factory diff --git a/receiver/solacereceiver/observability.go b/receiver/solacereceiver/observability.go index 3bee09aced4b..4d100d65d472 100644 --- a/receiver/solacereceiver/observability.go +++ b/receiver/solacereceiver/observability.go @@ -142,7 +142,7 @@ func fromMeasure(measure stats.Measure, agg *view.Aggregation) *view.View { } func buildReceiverCustomMetricName(metric string) string { - return receiverKey + nameSep + string(metadata.Type) + nameSep + metric + return receiverKey + nameSep + metadata.Type.String() + nameSep + metric } // recordFailedReconnection increments the metric that records failed reconnection event. diff --git a/testbed/mockdatasenders/mockdatadogagentexporter/factory.go b/testbed/mockdatasenders/mockdatadogagentexporter/factory.go index 38b1e12ab9de..132d00c0d94e 100644 --- a/testbed/mockdatasenders/mockdatadogagentexporter/factory.go +++ b/testbed/mockdatasenders/mockdatadogagentexporter/factory.go @@ -17,13 +17,13 @@ import ( // This file implements factory for awsxray receiver. -const ( +var ( // The value of "type" key in configuration. - typeStr = "datadog" + compType = component.MustNewType("datadog") ) func NewFactory() exporter.Factory { - return exporter.NewFactory(typeStr, + return exporter.NewFactory(compType, createDefaultConfig, exporter.WithTraces(CreateTracesExporter, component.StabilityLevelAlpha)) }