From dd016f1158942cbd0950e7a7a0a8a95bd162af97 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Thu, 7 Nov 2024 13:21:49 +0100 Subject: [PATCH 1/3] [processor/resourcedetection] add support for Profiles signal type Signed-off-by: odubajDT --- .../resourcedetectionprocessor-profiles.yaml | 27 +++++++++ connector/datadogconnector/go.sum | 2 + exporter/datadogexporter/go.mod | 2 + exporter/datadogexporter/go.sum | 2 + .../datadogexporter/integrationtest/go.sum | 2 + .../resourcedetectionprocessor/README.md | 8 ++- .../resourcedetectionprocessor/factory.go | 33 +++++++++-- .../factory_test.go | 9 +++ processor/resourcedetectionprocessor/go.mod | 7 ++- processor/resourcedetectionprocessor/go.sum | 2 + .../internal/metadata/generated_status.go | 7 ++- .../resourcedetectionprocessor/metadata.yaml | 1 + .../resourcedetection_processor.go | 13 +++++ .../resourcedetection_processor_test.go | 55 +++++++++++++++++++ 14 files changed, 159 insertions(+), 11 deletions(-) create mode 100644 .chloggen/resourcedetectionprocessor-profiles.yaml diff --git a/.chloggen/resourcedetectionprocessor-profiles.yaml b/.chloggen/resourcedetectionprocessor-profiles.yaml new file mode 100644 index 000000000000..11a69f5bab0d --- /dev/null +++ b/.chloggen/resourcedetectionprocessor-profiles.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: resourcedetectionprocessor + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Introduce support for Profiles signal type." + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35980] + +# (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. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/connector/datadogconnector/go.sum b/connector/datadogconnector/go.sum index ac9bdf4b497e..d51d935661a2 100644 --- a/connector/datadogconnector/go.sum +++ b/connector/datadogconnector/go.sum @@ -999,6 +999,8 @@ go.opentelemetry.io/collector/processor/batchprocessor v0.113.0 h1:LPNbVILg+cKTF go.opentelemetry.io/collector/processor/batchprocessor v0.113.0/go.mod h1:tCg+B/1idJS5inxod+nRPXFdVi89Bsnl6RvzIOO9k5I= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0 h1:3/5z0Pe/yduwF0DSpytW2+mwDA5JaIL/w6vfNYy5KzQ= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0/go.mod h1:h3wIlqMtJGIDKttjMJBo6J4dHU/Mi6+bKSxvRVUpsXs= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 h1:bZ1i5l6/4nj7PsLqeHw7Opw5vdrpUsDvuH6a6kx+2yg= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0/go.mod h1:Uxv+5NNIJJCuz52DPFa9INjrpZSfidoTkv849tNp1qI= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 h1:cczN6whdrCWww3T0FBV3U7lsVKQmkWDX05M+9lANHgk= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0/go.mod h1:4Dmx5qsvujgJ+MC+KqWI7UDVM2liXa3sH/9XnGiL9aE= go.opentelemetry.io/collector/processor/processortest v0.113.0 h1:jGoDJ+tDCzuDcAWZeshQtnK/DQAvMKd4wZAIDgAM5aA= diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index b635050a4fd8..f3ddbedac678 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -339,6 +339,7 @@ require ( go.opentelemetry.io/collector/connector/connectortest v0.113.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.113.0 // indirect go.opentelemetry.io/collector/consumer/consumertest v0.113.0 // indirect + go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles v0.113.0 // indirect go.opentelemetry.io/collector/exporter/exporterprofiles v0.113.0 // indirect go.opentelemetry.io/collector/extension v0.113.0 // indirect go.opentelemetry.io/collector/extension/auth v0.113.0 // indirect @@ -352,6 +353,7 @@ require ( go.opentelemetry.io/collector/pdata/testdata v0.113.0 // indirect go.opentelemetry.io/collector/pipeline v0.113.0 // indirect go.opentelemetry.io/collector/pipeline/pipelineprofiles v0.113.0 // indirect + go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 // indirect go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 // indirect go.opentelemetry.io/collector/processor/processortest v0.113.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.113.0 // indirect diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index 0809d95c9f9d..c29d1e892c8a 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -1127,6 +1127,8 @@ go.opentelemetry.io/collector/processor/batchprocessor v0.113.0 h1:LPNbVILg+cKTF go.opentelemetry.io/collector/processor/batchprocessor v0.113.0/go.mod h1:tCg+B/1idJS5inxod+nRPXFdVi89Bsnl6RvzIOO9k5I= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0 h1:3/5z0Pe/yduwF0DSpytW2+mwDA5JaIL/w6vfNYy5KzQ= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0/go.mod h1:h3wIlqMtJGIDKttjMJBo6J4dHU/Mi6+bKSxvRVUpsXs= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 h1:bZ1i5l6/4nj7PsLqeHw7Opw5vdrpUsDvuH6a6kx+2yg= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0/go.mod h1:Uxv+5NNIJJCuz52DPFa9INjrpZSfidoTkv849tNp1qI= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 h1:cczN6whdrCWww3T0FBV3U7lsVKQmkWDX05M+9lANHgk= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0/go.mod h1:4Dmx5qsvujgJ+MC+KqWI7UDVM2liXa3sH/9XnGiL9aE= go.opentelemetry.io/collector/processor/processortest v0.113.0 h1:jGoDJ+tDCzuDcAWZeshQtnK/DQAvMKd4wZAIDgAM5aA= diff --git a/exporter/datadogexporter/integrationtest/go.sum b/exporter/datadogexporter/integrationtest/go.sum index 16e1341b2ec1..07abc40f75fe 100644 --- a/exporter/datadogexporter/integrationtest/go.sum +++ b/exporter/datadogexporter/integrationtest/go.sum @@ -1111,6 +1111,8 @@ go.opentelemetry.io/collector/processor/batchprocessor v0.113.0 h1:LPNbVILg+cKTF go.opentelemetry.io/collector/processor/batchprocessor v0.113.0/go.mod h1:tCg+B/1idJS5inxod+nRPXFdVi89Bsnl6RvzIOO9k5I= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0 h1:3/5z0Pe/yduwF0DSpytW2+mwDA5JaIL/w6vfNYy5KzQ= go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.113.0/go.mod h1:h3wIlqMtJGIDKttjMJBo6J4dHU/Mi6+bKSxvRVUpsXs= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 h1:bZ1i5l6/4nj7PsLqeHw7Opw5vdrpUsDvuH6a6kx+2yg= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0/go.mod h1:Uxv+5NNIJJCuz52DPFa9INjrpZSfidoTkv849tNp1qI= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 h1:cczN6whdrCWww3T0FBV3U7lsVKQmkWDX05M+9lANHgk= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0/go.mod h1:4Dmx5qsvujgJ+MC+KqWI7UDVM2liXa3sH/9XnGiL9aE= go.opentelemetry.io/collector/processor/processortest v0.113.0 h1:jGoDJ+tDCzuDcAWZeshQtnK/DQAvMKd4wZAIDgAM5aA= diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 30e91a3d6227..3885caa91757 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -3,12 +3,18 @@ | Status | | | ------------- |-----------| -| Stability | [beta]: traces, metrics, logs | +| Stability | [development]: profiles | +| | [beta]: traces, metrics, logs | | Distributions | [contrib], [k8s] | | Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fresourcedetection%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fresourcedetection) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fresourcedetection%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fresourcedetection) | | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@Aneurysm9](https://www.github.com/Aneurysm9), [@dashpole](https://www.github.com/dashpole) | +<<<<<<< HEAD [beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta +======= +[development]: https://github.com/open-telemetry/opentelemetry-collector#development +[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta +>>>>>>> ef80cc5bd0 (adapt README) [contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib [k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s diff --git a/processor/resourcedetectionprocessor/factory.go b/processor/resourcedetectionprocessor/factory.go index f1ae4b11ac35..05ff7934f81b 100644 --- a/processor/resourcedetectionprocessor/factory.go +++ b/processor/resourcedetectionprocessor/factory.go @@ -12,8 +12,11 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processorhelper" + "go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles" + "go.opentelemetry.io/collector/processor/processorprofiles" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/ec2" @@ -70,12 +73,13 @@ func NewFactory() processor.Factory { providers: map[component.ID]*internal.ResourceProvider{}, } - return processor.NewFactory( + return processorprofiles.NewFactory( metadata.Type, createDefaultConfig, - processor.WithTraces(f.createTracesProcessor, metadata.TracesStability), - processor.WithMetrics(f.createMetricsProcessor, metadata.MetricsStability), - processor.WithLogs(f.createLogsProcessor, metadata.LogsStability)) + processorprofiles.WithTraces(f.createTracesProcessor, metadata.TracesStability), + processorprofiles.WithMetrics(f.createMetricsProcessor, metadata.MetricsStability), + processorprofiles.WithLogs(f.createLogsProcessor, metadata.LogsStability), + processorprofiles.WithProfiles(f.createProfilesProcessor, metadata.ProfilesStability)) } // Type gets the type of the Option config created by this factory. @@ -164,6 +168,27 @@ func (f *factory) createLogsProcessor( processorhelper.WithStart(rdp.Start)) } +func (f *factory) createProfilesProcessor( + ctx context.Context, + set processor.Settings, + cfg component.Config, + nextConsumer consumerprofiles.Profiles, +) (processorprofiles.Profiles, error) { + rdp, err := f.getResourceDetectionProcessor(set, cfg) + if err != nil { + return nil, err + } + + return processorhelperprofiles.NewProfiles( + ctx, + set, + cfg, + nextConsumer, + rdp.processProfiles, + processorhelperprofiles.WithCapabilities(consumerCapabilities), + processorhelperprofiles.WithStart(rdp.Start)) +} + func (f *factory) getResourceDetectionProcessor( params processor.Settings, cfg component.Config, diff --git a/processor/resourcedetectionprocessor/factory_test.go b/processor/resourcedetectionprocessor/factory_test.go index 7256f074aa82..1d2fdc1db014 100644 --- a/processor/resourcedetectionprocessor/factory_test.go +++ b/processor/resourcedetectionprocessor/factory_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/processor/processorprofiles" "go.opentelemetry.io/collector/processor/processortest" ) @@ -37,6 +38,10 @@ func TestCreateProcessor(t *testing.T) { lp, err := factory.CreateLogs(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, lp) + + pp, err := factory.(processorprofiles.Factory).CreateProfiles(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) + assert.NoError(t, err) + assert.NotNil(t, pp) } func TestCreateConfigProcessors(t *testing.T) { @@ -82,4 +87,8 @@ func TestInvalidConfig(t *testing.T) { lp, err := factory.CreateLogs(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.Error(t, err) assert.Nil(t, lp) + + pp, err := factory.(processorprofiles.Factory).CreateProfiles(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) + assert.Error(t, err) + assert.Nil(t, pp) } diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index d7eff97cd5ae..01a5250cf62f 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -20,10 +20,14 @@ require ( go.opentelemetry.io/collector/config/configtls v1.19.0 go.opentelemetry.io/collector/confmap v1.19.0 go.opentelemetry.io/collector/consumer v0.113.0 + go.opentelemetry.io/collector/consumer/consumerprofiles v0.113.0 go.opentelemetry.io/collector/consumer/consumertest v0.113.0 go.opentelemetry.io/collector/featuregate v1.19.0 go.opentelemetry.io/collector/pdata v1.19.0 + go.opentelemetry.io/collector/pdata/pprofile v0.113.0 go.opentelemetry.io/collector/processor v0.113.0 + go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 + go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 go.opentelemetry.io/collector/processor/processortest v0.113.0 go.opentelemetry.io/collector/semconv v0.113.0 go.uber.org/goleak v1.3.0 @@ -114,13 +118,10 @@ require ( go.opentelemetry.io/collector/config/configcompression v1.19.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.113.0 // indirect go.opentelemetry.io/collector/config/internal v0.113.0 // indirect - go.opentelemetry.io/collector/consumer/consumerprofiles v0.113.0 // indirect go.opentelemetry.io/collector/extension v0.113.0 // indirect go.opentelemetry.io/collector/extension/auth v0.113.0 // indirect - go.opentelemetry.io/collector/pdata/pprofile v0.113.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.113.0 // indirect go.opentelemetry.io/collector/pipeline v0.113.0 // indirect - go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect go.opentelemetry.io/otel v1.31.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 24c848ce37b5..f639f07ef9fc 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -502,6 +502,8 @@ go.opentelemetry.io/collector/pipeline v0.113.0 h1:vSRzRe3717jV0btCNPhVkhg2lu0uF go.opentelemetry.io/collector/pipeline v0.113.0/go.mod h1:4vOvjVsoYTHVGTbfFwqfnQOSV2K3RKUHofh3jNRc2Mg= go.opentelemetry.io/collector/processor v0.113.0 h1:BQI6MsKtiCG9HT/nmiRXTKP6SZFrjFKVfM6pTQfbc0k= go.opentelemetry.io/collector/processor v0.113.0/go.mod h1:oX91zMI8ZkoaYSUfUYflHiMiiBJPKtODNBUCrETLLd8= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0 h1:bZ1i5l6/4nj7PsLqeHw7Opw5vdrpUsDvuH6a6kx+2yg= +go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles v0.113.0/go.mod h1:Uxv+5NNIJJCuz52DPFa9INjrpZSfidoTkv849tNp1qI= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0 h1:cczN6whdrCWww3T0FBV3U7lsVKQmkWDX05M+9lANHgk= go.opentelemetry.io/collector/processor/processorprofiles v0.113.0/go.mod h1:4Dmx5qsvujgJ+MC+KqWI7UDVM2liXa3sH/9XnGiL9aE= go.opentelemetry.io/collector/processor/processortest v0.113.0 h1:jGoDJ+tDCzuDcAWZeshQtnK/DQAvMKd4wZAIDgAM5aA= diff --git a/processor/resourcedetectionprocessor/internal/metadata/generated_status.go b/processor/resourcedetectionprocessor/internal/metadata/generated_status.go index ecca969e7db9..ee0a49313187 100644 --- a/processor/resourcedetectionprocessor/internal/metadata/generated_status.go +++ b/processor/resourcedetectionprocessor/internal/metadata/generated_status.go @@ -12,7 +12,8 @@ var ( ) const ( - TracesStability = component.StabilityLevelBeta - MetricsStability = component.StabilityLevelBeta - LogsStability = component.StabilityLevelBeta + ProfilesStability = component.StabilityLevelDevelopment + TracesStability = component.StabilityLevelBeta + MetricsStability = component.StabilityLevelBeta + LogsStability = component.StabilityLevelBeta ) diff --git a/processor/resourcedetectionprocessor/metadata.yaml b/processor/resourcedetectionprocessor/metadata.yaml index fee99b032daf..9e98d1f5cbd7 100644 --- a/processor/resourcedetectionprocessor/metadata.yaml +++ b/processor/resourcedetectionprocessor/metadata.yaml @@ -4,6 +4,7 @@ status: class: processor stability: beta: [traces, metrics, logs] + development: [profiles] distributions: [contrib, k8s] codeowners: active: [Aneurysm9, dashpole] diff --git a/processor/resourcedetectionprocessor/resourcedetection_processor.go b/processor/resourcedetectionprocessor/resourcedetection_processor.go index 44f3331e6473..40d2939ad354 100644 --- a/processor/resourcedetectionprocessor/resourcedetection_processor.go +++ b/processor/resourcedetectionprocessor/resourcedetection_processor.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal" @@ -69,3 +70,15 @@ func (rdp *resourceDetectionProcessor) processLogs(_ context.Context, ld plog.Lo } return ld, nil } + +// processProfiles implements the ProcessProfilesFunc type. +func (rdp *resourceDetectionProcessor) processProfiles(_ context.Context, ld pprofile.Profiles) (pprofile.Profiles, error) { + rl := ld.ResourceProfiles() + for i := 0; i < rl.Len(); i++ { + rss := rl.At(i) + rss.SetSchemaUrl(internal.MergeSchemaURL(rss.SchemaUrl(), rdp.schemaURL)) + res := rss.Resource() + internal.MergeResource(res, rdp.resource, rdp.override) + } + return ld, nil +} diff --git a/processor/resourcedetectionprocessor/resourcedetection_processor_test.go b/processor/resourcedetectionprocessor/resourcedetection_processor_test.go index 78f63a150a0d..a61c8a4efaaf 100644 --- a/processor/resourcedetectionprocessor/resourcedetection_processor_test.go +++ b/processor/resourcedetectionprocessor/resourcedetection_processor_test.go @@ -19,8 +19,10 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/collector/processor/processorprofiles" "go.opentelemetry.io/collector/processor/processortest" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal" @@ -259,6 +261,37 @@ func TestResourceProcessor(t *testing.T) { got = tln.AllLogs()[0].ResourceLogs().At(0).Resource().Attributes().AsRaw() assert.Equal(t, tt.expectedResource, got) + + // Test profiles consumer + tpn := new(consumertest.ProfilesSink) + rpp, err := factory.createProfilesProcessor(context.Background(), processortest.NewNopSettings(), cfg, tpn) + + if tt.expectedNewError != "" { + assert.EqualError(t, err, tt.expectedNewError) + return + } + + require.NoError(t, err) + assert.True(t, rpp.Capabilities().MutatesData) + + err = rpp.Start(context.Background(), componenttest.NewNopHost()) + + if tt.detectedError != nil { + require.NoError(t, err) + return + } + + require.NoError(t, err) + defer func() { assert.NoError(t, rpp.Shutdown(context.Background())) }() + + pd := pprofile.NewProfiles() + require.NoError(t, pd.ResourceProfiles().AppendEmpty().Resource().Attributes().FromRaw(tt.sourceResource)) + + err = rpp.ConsumeProfiles(context.Background(), pd) + require.NoError(t, err) + got = tpn.AllProfiles()[0].ResourceProfiles().At(0).Resource().Attributes().AsRaw() + + assert.Equal(t, tt.expectedResource, got) }) } } @@ -328,3 +361,25 @@ func BenchmarkConsumeLogsAll(b *testing.B) { cfg := &Config{Override: true, Detectors: []string{env.TypeStr, gcp.TypeStr}} benchmarkConsumeLogs(b, cfg) } + +func benchmarkConsumeProfiles(b *testing.B, cfg *Config) { + factory := NewFactory() + sink := new(consumertest.ProfilesSink) + processor, _ := factory.(processorprofiles.Factory).CreateProfiles(context.Background(), processortest.NewNopSettings(), cfg, sink) + + b.ResetTimer() + for n := 0; n < b.N; n++ { + // TODO use testbed.PerfTestDataProvider here once that includes resources + assert.NoError(b, processor.ConsumeProfiles(context.Background(), pprofile.NewProfiles())) + } +} + +func BenchmarkConsumeProfilesDefault(b *testing.B) { + cfg := NewFactory().CreateDefaultConfig() + benchmarkConsumeProfiles(b, cfg.(*Config)) +} + +func BenchmarkConsumeProfilesAll(b *testing.B) { + cfg := &Config{Override: true, Detectors: []string{env.TypeStr, gcp.TypeStr}} + benchmarkConsumeProfiles(b, cfg) +} From 9612143833342cca302dc07b81b2a70044607581 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Thu, 7 Nov 2024 13:39:15 +0100 Subject: [PATCH 2/3] fix after rebase Signed-off-by: odubajDT --- exporter/datadogexporter/go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index f3ddbedac678..677a31246d27 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -339,7 +339,6 @@ require ( go.opentelemetry.io/collector/connector/connectortest v0.113.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.113.0 // indirect go.opentelemetry.io/collector/consumer/consumertest v0.113.0 // indirect - go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles v0.113.0 // indirect go.opentelemetry.io/collector/exporter/exporterprofiles v0.113.0 // indirect go.opentelemetry.io/collector/extension v0.113.0 // indirect go.opentelemetry.io/collector/extension/auth v0.113.0 // indirect From 77265c986658e4bdb6f8b032b724a99ae2654dda Mon Sep 17 00:00:00 2001 From: odubajDT Date: Thu, 7 Nov 2024 14:02:24 +0100 Subject: [PATCH 3/3] make generate Signed-off-by: odubajDT --- processor/resourcedetectionprocessor/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 3885caa91757..cf16a5abc9e8 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -9,12 +9,8 @@ | Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fresourcedetection%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fresourcedetection) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fresourcedetection%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fresourcedetection) | | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@Aneurysm9](https://www.github.com/Aneurysm9), [@dashpole](https://www.github.com/dashpole) | -<<<<<<< HEAD +[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development [beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta -======= -[development]: https://github.com/open-telemetry/opentelemetry-collector#development -[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta ->>>>>>> ef80cc5bd0 (adapt README) [contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib [k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s