From f9d44de9b6360683aa1009d47aff5ae8ccd51b74 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Thu, 3 Oct 2024 03:47:39 -0600 Subject: [PATCH 1/2] [exporter/logging] Remove logging exporter (#11037) #### Description It is September, which means we get to remove this deprecated component. - The helm chart was updated to exclude the logging exporter already: https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/UPGRADING.md#0840-to-0850. - The Operator references have been updated: https://github.com/open-telemetry/opentelemetry-operator/pull/3259. - Opentelemetry.io site final references to update: https://github.com/open-telemetry/opentelemetry.io/pull/5143 #### Link to tracking issue Related to https://github.com/open-telemetry/opentelemetry-collector/issues/7769 --- .chloggen/remove-logging-exporter.yaml | 25 +++ Makefile | 2 - cmd/builder/internal/config/default.yaml | 1 - cmd/builder/test/core.builder.yaml | 1 - cmd/otelcorecol/builder-config.yaml | 2 - cmd/otelcorecol/components.go | 3 - cmd/otelcorecol/go.mod | 3 - component/config_test.go | 1 - connector/forwardconnector/README.md | 2 +- exporter/debugexporter/README.md | 2 +- exporter/debugexporter/config.go | 4 +- exporter/debugexporter/exporter.go | 4 - exporter/loggingexporter/Makefile | 1 - exporter/loggingexporter/README.md | 52 ----- exporter/loggingexporter/config.go | 94 --------- exporter/loggingexporter/config_test.go | 181 ------------------ exporter/loggingexporter/doc.go | 7 - exporter/loggingexporter/factory.go | 80 -------- exporter/loggingexporter/factory_test.go | 49 ----- .../generated_component_test.go | 151 --------------- .../loggingexporter/generated_package_test.go | 13 -- exporter/loggingexporter/go.mod | 100 ---------- exporter/loggingexporter/go.sum | 110 ----------- .../internal/metadata/generated_status.go | 18 -- exporter/loggingexporter/metadata.yaml | 8 - .../testdata/config_loglevel.yaml | 3 - .../testdata/config_loglevel_typo.yaml | 2 - .../testdata/config_verbosity.yaml | 3 - .../testdata/invalid_verbosity_loglevel.yaml | 2 - .../testdata/loglevel_info.yaml | 1 - otelcol/internal/configunmarshaler/configs.go | 4 + .../configunmarshaler/configs_test.go | 12 ++ versions.yaml | 1 - 33 files changed, 45 insertions(+), 897 deletions(-) create mode 100644 .chloggen/remove-logging-exporter.yaml delete mode 100644 exporter/loggingexporter/Makefile delete mode 100644 exporter/loggingexporter/README.md delete mode 100644 exporter/loggingexporter/config.go delete mode 100644 exporter/loggingexporter/config_test.go delete mode 100644 exporter/loggingexporter/doc.go delete mode 100644 exporter/loggingexporter/factory.go delete mode 100644 exporter/loggingexporter/factory_test.go delete mode 100644 exporter/loggingexporter/generated_component_test.go delete mode 100644 exporter/loggingexporter/generated_package_test.go delete mode 100644 exporter/loggingexporter/go.mod delete mode 100644 exporter/loggingexporter/go.sum delete mode 100644 exporter/loggingexporter/internal/metadata/generated_status.go delete mode 100644 exporter/loggingexporter/metadata.yaml delete mode 100644 exporter/loggingexporter/testdata/config_loglevel.yaml delete mode 100644 exporter/loggingexporter/testdata/config_loglevel_typo.yaml delete mode 100644 exporter/loggingexporter/testdata/config_verbosity.yaml delete mode 100644 exporter/loggingexporter/testdata/invalid_verbosity_loglevel.yaml delete mode 100644 exporter/loggingexporter/testdata/loglevel_info.yaml diff --git a/.chloggen/remove-logging-exporter.yaml b/.chloggen/remove-logging-exporter.yaml new file mode 100644 index 00000000000..9de89981bf1 --- /dev/null +++ b/.chloggen/remove-logging-exporter.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: loggingexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Removed the deprecated logging exporter. Use the debug exporter instead. + +# One or more tracking issues or pull requests related to the change +issues: [11037] + +# (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: + +# 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/Makefile b/Makefile index 404c97632a9..62f1e6c0d36 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,6 @@ check-contrib: -replace go.opentelemetry.io/collector/exporter=$(CURDIR)/exporter \ -replace go.opentelemetry.io/collector/exporter/debugexporter=$(CURDIR)/exporter/debugexporter \ -replace go.opentelemetry.io/collector/exporter/exporterprofiles=$(CURDIR)/exporter/exporterprofiles \ - -replace go.opentelemetry.io/collector/exporter/loggingexporter=$(CURDIR)/exporter/loggingexporter \ -replace go.opentelemetry.io/collector/exporter/nopexporter=$(CURDIR)/exporter/nopexporter \ -replace go.opentelemetry.io/collector/exporter/otlpexporter=$(CURDIR)/exporter/otlpexporter \ -replace go.opentelemetry.io/collector/exporter/otlphttpexporter=$(CURDIR)/exporter/otlphttpexporter \ @@ -363,7 +362,6 @@ restore-contrib: -dropreplace go.opentelemetry.io/collector/consumer/consumertest \ -dropreplace go.opentelemetry.io/collector/exporter \ -dropreplace go.opentelemetry.io/collector/exporter/debugexporter \ - -dropreplace go.opentelemetry.io/collector/exporter/loggingexporter \ -dropreplace go.opentelemetry.io/collector/exporter/nopexporter \ -dropreplace go.opentelemetry.io/collector/exporter/otlpexporter \ -dropreplace go.opentelemetry.io/collector/exporter/otlphttpexporter \ diff --git a/cmd/builder/internal/config/default.yaml b/cmd/builder/internal/config/default.yaml index d7b7a011acd..3e3f2483d70 100644 --- a/cmd/builder/internal/config/default.yaml +++ b/cmd/builder/internal/config/default.yaml @@ -18,7 +18,6 @@ receivers: - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.110.0 exporters: - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.110.0 - - gomod: go.opentelemetry.io/collector/exporter/loggingexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.110.0 diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index e6aab6c3c6b..b9b7b03166b 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -40,7 +40,6 @@ replaces: - go.opentelemetry.io/collector/connector/connectorprofiles => ${WORKSPACE_DIR}/connector/connectorprofiles - go.opentelemetry.io/collector/exporter => ${WORKSPACE_DIR}/exporter - go.opentelemetry.io/collector/exporter/debugexporter => ${WORKSPACE_DIR}/exporter/debugexporter - - go.opentelemetry.io/collector/exporter/loggingexporter => ${WORKSPACE_DIR}/exporter/loggingexporter - go.opentelemetry.io/collector/exporter/exporterprofiles => ${WORKSPACE_DIR}/exporter/exporterprofiles - go.opentelemetry.io/collector/extension => ${WORKSPACE_DIR}/extension - go.opentelemetry.io/collector/extension/auth => ${WORKSPACE_DIR}/extension/auth diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index e3f58c89e34..defb0612a0c 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -18,7 +18,6 @@ receivers: - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.110.0 exporters: - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.110.0 - - gomod: go.opentelemetry.io/collector/exporter/loggingexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.110.0 - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.110.0 @@ -72,7 +71,6 @@ replaces: - go.opentelemetry.io/collector/exporter => ../../exporter - go.opentelemetry.io/collector/exporter/debugexporter => ../../exporter/debugexporter - go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles - - go.opentelemetry.io/collector/exporter/loggingexporter => ../../exporter/loggingexporter - go.opentelemetry.io/collector/exporter/nopexporter => ../../exporter/nopexporter - go.opentelemetry.io/collector/exporter/otlpexporter => ../../exporter/otlpexporter - go.opentelemetry.io/collector/exporter/otlphttpexporter => ../../exporter/otlphttpexporter diff --git a/cmd/otelcorecol/components.go b/cmd/otelcorecol/components.go index aa0858060ef..c5901f2beef 100644 --- a/cmd/otelcorecol/components.go +++ b/cmd/otelcorecol/components.go @@ -8,7 +8,6 @@ import ( forwardconnector "go.opentelemetry.io/collector/connector/forwardconnector" "go.opentelemetry.io/collector/exporter" debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" - loggingexporter "go.opentelemetry.io/collector/exporter/loggingexporter" nopexporter "go.opentelemetry.io/collector/exporter/nopexporter" otlpexporter "go.opentelemetry.io/collector/exporter/otlpexporter" otlphttpexporter "go.opentelemetry.io/collector/exporter/otlphttpexporter" @@ -52,7 +51,6 @@ func components() (otelcol.Factories, error) { factories.Exporters, err = exporter.MakeFactoryMap( debugexporter.NewFactory(), - loggingexporter.NewFactory(), nopexporter.NewFactory(), otlpexporter.NewFactory(), otlphttpexporter.NewFactory(), @@ -62,7 +60,6 @@ func components() (otelcol.Factories, error) { } factories.ExporterModules = make(map[component.Type]string, len(factories.Exporters)) factories.ExporterModules[debugexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/debugexporter v0.110.0" - factories.ExporterModules[loggingexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/loggingexporter v0.110.0" factories.ExporterModules[nopexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/nopexporter v0.110.0" factories.ExporterModules[otlpexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/otlpexporter v0.110.0" factories.ExporterModules[otlphttpexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/otlphttpexporter v0.110.0" diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index 947852a287f..61b81db4e04 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -18,7 +18,6 @@ require ( go.opentelemetry.io/collector/connector/forwardconnector v0.110.0 go.opentelemetry.io/collector/exporter v0.110.0 go.opentelemetry.io/collector/exporter/debugexporter v0.110.0 - go.opentelemetry.io/collector/exporter/loggingexporter v0.110.0 go.opentelemetry.io/collector/exporter/nopexporter v0.110.0 go.opentelemetry.io/collector/exporter/otlpexporter v0.110.0 go.opentelemetry.io/collector/exporter/otlphttpexporter v0.110.0 @@ -214,8 +213,6 @@ replace go.opentelemetry.io/collector/exporter/debugexporter => ../../exporter/d replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles -replace go.opentelemetry.io/collector/exporter/loggingexporter => ../../exporter/loggingexporter - replace go.opentelemetry.io/collector/exporter/nopexporter => ../../exporter/nopexporter replace go.opentelemetry.io/collector/exporter/otlpexporter => ../../exporter/otlpexporter diff --git a/component/config_test.go b/component/config_test.go index afdbc61b06e..9e6daa0f618 100644 --- a/component/config_test.go +++ b/component/config_test.go @@ -306,7 +306,6 @@ func TestNewType(t *testing.T) { {name: "kinetica"}, {name: "kubeletstats"}, {name: "loadbalancing"}, - {name: "logging"}, {name: "logicmonitor"}, {name: "logstransform"}, {name: "logzio"}, diff --git a/connector/forwardconnector/README.md b/connector/forwardconnector/README.md index bf71e5785d8..413b87a7464 100644 --- a/connector/forwardconnector/README.md +++ b/connector/forwardconnector/README.md @@ -129,7 +129,7 @@ service: # - forward # traces/log: # receivers: [forward] - # exporters: [logging] + # exporters: [debug] ``` [Connectors README]:../README.md diff --git a/exporter/debugexporter/README.md b/exporter/debugexporter/README.md index 9b581eea46f..d9cb1304b39 100644 --- a/exporter/debugexporter/README.md +++ b/exporter/debugexporter/README.md @@ -24,7 +24,7 @@ See also the [Troubleshooting][troubleshooting_docs] document for examples on us The following settings are optional: -- `verbosity` (default = `basic`): the verbosity of the logging export +- `verbosity` (default = `basic`): the verbosity of the debug exporter (detailed|normal|basic). When set to `detailed`, pipeline data is verbosely logged. - `sampling_initial` (default = `2`): number of messages initially logged each diff --git a/exporter/debugexporter/config.go b/exporter/debugexporter/config.go index 2ebd85e78ab..3ddf8434dfa 100644 --- a/exporter/debugexporter/config.go +++ b/exporter/debugexporter/config.go @@ -20,9 +20,9 @@ var ( } ) -// Config defines configuration for logging exporter. +// Config defines configuration for debug exporter. type Config struct { - // Verbosity defines the logging exporter verbosity. + // Verbosity defines the debug exporter verbosity. Verbosity configtelemetry.Level `mapstructure:"verbosity,omitempty"` // SamplingInitial defines how many samples are initially logged during each second. diff --git a/exporter/debugexporter/exporter.go b/exporter/debugexporter/exporter.go index 324cd19935c..2df9edf7a6f 100644 --- a/exporter/debugexporter/exporter.go +++ b/exporter/debugexporter/exporter.go @@ -1,10 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -// NOTE: If you are making changes to this file, consider whether you want to make similar changes -// to the Logging exporter in /exporter/internal/common/logging_exporter.go, which has similar logic. -// This is especially important for security issues. - package debugexporter // import "go.opentelemetry.io/collector/exporter/debugexporter" import ( diff --git a/exporter/loggingexporter/Makefile b/exporter/loggingexporter/Makefile deleted file mode 100644 index ded7a36092d..00000000000 --- a/exporter/loggingexporter/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../../Makefile.Common diff --git a/exporter/loggingexporter/README.md b/exporter/loggingexporter/README.md deleted file mode 100644 index 685e1264e28..00000000000 --- a/exporter/loggingexporter/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Logging Exporter - - -| Status | | -| ------------- |-----------| -| Stability | [deprecated]: traces, metrics, logs | -| Distributions | [core], [contrib] | -| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Flogging%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Flogging) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Flogging%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Flogging) | - -[deprecated]: https://github.com/open-telemetry/opentelemetry-collector#deprecated -[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol -[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib - - -This exporter is being deprecated in favour of the [debug exporter]. It will be removed in September 2024. - -Exports data to the console via zap.Logger. - -Supported pipeline types: traces, metrics, logs - -## Getting Started - -The following settings are optional: - -- `loglevel` (default = `info`): the log level of the logging export - (debug|info|warn|error). When set to `debug`, pipeline data is verbosely - logged. - - **Note**: This option has been deprecated in favor of `verbosity` -- `verbosity` (default = `normal`): the verbosity of the logging export - (detailed|normal|basic). When set to `detailed`, pipeline data is verbosely - logged. -- `sampling_initial` (default = `2`): number of messages initially logged each - second. -- `sampling_thereafter` (default = `500`): sampling rate after the initial - messages are logged (every Mth message is logged). Refer to [Zap - docs](https://godoc.org/go.uber.org/zap/zapcore#NewSampler) for more details - on how sampling parameters impact number of messages. - -### Note -`loglevel` is deprecated, use `verbosity` instead. - -Example: - -```yaml -exporters: - logging: - verbosity: detailed - sampling_initial: 5 - sampling_thereafter: 200 -``` - -[debug exporter]: ../debugexporter/README.md diff --git a/exporter/loggingexporter/config.go b/exporter/loggingexporter/config.go deleted file mode 100644 index d35cdd6fa4d..00000000000 --- a/exporter/loggingexporter/config.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package loggingexporter // import "go.opentelemetry.io/collector/exporter/loggingexporter" - -import ( - "fmt" - - "go.uber.org/zap/zapcore" - - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config/configtelemetry" - "go.opentelemetry.io/collector/confmap" -) - -var ( - // supportedLevels in this exporter's configuration. - // configtelemetry.LevelNone and other future values are not supported. - supportedLevels map[configtelemetry.Level]struct{} = map[configtelemetry.Level]struct{}{ - configtelemetry.LevelBasic: {}, - configtelemetry.LevelNormal: {}, - configtelemetry.LevelDetailed: {}, - } -) - -// Config defines configuration for logging exporter. -type Config struct { - // LogLevel defines log level of the logging exporter; options are debug, info, warn, error. - // Deprecated: Use `Verbosity` instead. - LogLevel zapcore.Level `mapstructure:"loglevel,omitempty"` - - // Verbosity defines the logging exporter verbosity. - Verbosity configtelemetry.Level `mapstructure:"verbosity,omitempty"` - - // SamplingInitial defines how many samples are initially logged during each second. - SamplingInitial int `mapstructure:"sampling_initial"` - - // SamplingThereafter defines the sampling rate after the initial samples are logged. - SamplingThereafter int `mapstructure:"sampling_thereafter"` - - // warnLogLevel is set on unmarshaling to warn users about `loglevel` usage. - warnLogLevel bool -} - -var _ component.Config = (*Config)(nil) -var _ confmap.Unmarshaler = (*Config)(nil) - -func mapLevel(level zapcore.Level) (configtelemetry.Level, error) { - switch level { - case zapcore.DebugLevel: - return configtelemetry.LevelDetailed, nil - case zapcore.InfoLevel: - return configtelemetry.LevelNormal, nil - case zapcore.WarnLevel, zapcore.ErrorLevel, - zapcore.DPanicLevel, zapcore.PanicLevel, zapcore.FatalLevel: - // Anything above info is mapped to 'basic' level. - return configtelemetry.LevelBasic, nil - default: - return configtelemetry.LevelNone, fmt.Errorf("log level %q is not supported", level) - } -} - -func (cfg *Config) Unmarshal(conf *confmap.Conf) error { - if conf.IsSet("loglevel") && conf.IsSet("verbosity") { - return fmt.Errorf("'loglevel' and 'verbosity' are incompatible. Use only 'verbosity' instead") - } - - if err := conf.Unmarshal(cfg); err != nil { - return err - } - - if conf.IsSet("loglevel") { - verbosity, err := mapLevel(cfg.LogLevel) - if err != nil { - return fmt.Errorf("failed to map 'loglevel': %w", err) - } - - // 'verbosity' is unset but 'loglevel' is set. - // Override default verbosity. - cfg.Verbosity = verbosity - cfg.warnLogLevel = true - } - - return nil -} - -// Validate checks if the exporter configuration is valid -func (cfg *Config) Validate() error { - if _, ok := supportedLevels[cfg.Verbosity]; !ok { - return fmt.Errorf("verbosity level %q is not supported", cfg.Verbosity) - } - - return nil -} diff --git a/exporter/loggingexporter/config_test.go b/exporter/loggingexporter/config_test.go deleted file mode 100644 index 6280113f981..00000000000 --- a/exporter/loggingexporter/config_test.go +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package loggingexporter - -import ( - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zapcore" - - "go.opentelemetry.io/collector/config/configtelemetry" - "go.opentelemetry.io/collector/confmap" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestUnmarshalDefaultConfig(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - require.NoError(t, confmap.New().Unmarshal(&cfg)) - assert.Equal(t, factory.CreateDefaultConfig(), cfg) -} - -func TestUnmarshalConfig(t *testing.T) { - tests := []struct { - filename string - cfg *Config - expectedErr string - }{ - { - filename: "config_loglevel.yaml", - cfg: &Config{ - LogLevel: zapcore.DebugLevel, - Verbosity: configtelemetry.LevelDetailed, - SamplingInitial: 10, - SamplingThereafter: 50, - warnLogLevel: true, - }, - }, - { - filename: "config_verbosity.yaml", - cfg: &Config{ - LogLevel: zapcore.InfoLevel, - Verbosity: configtelemetry.LevelDetailed, - SamplingInitial: 10, - SamplingThereafter: 50, - }, - }, - { - filename: "loglevel_info.yaml", - cfg: &Config{ - LogLevel: zapcore.InfoLevel, - Verbosity: configtelemetry.LevelNormal, - SamplingInitial: 2, - SamplingThereafter: 500, - warnLogLevel: true, - }, - }, - { - filename: "invalid_verbosity_loglevel.yaml", - expectedErr: "'loglevel' and 'verbosity' are incompatible. Use only 'verbosity' instead", - }, - { - filename: "config_loglevel_typo.yaml", - expectedErr: "'' has invalid keys: logLevel", - }, - } - - for _, tt := range tests { - t.Run(tt.filename, func(t *testing.T) { - cm, err := confmaptest.LoadConf(filepath.Join("testdata", tt.filename)) - require.NoError(t, err) - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - err = cm.Unmarshal(&cfg) - if tt.expectedErr != "" { - assert.ErrorContains(t, err, tt.expectedErr) - } else { - require.NoError(t, err) - assert.Equal(t, tt.cfg, cfg) - } - }) - } -} - -func Test_UnmarshalMarshalled(t *testing.T) { - for name, tc := range map[string]struct { - inCfg *Config - expectedConfig *Config - expectedErr string - }{ - "Base": { - inCfg: &Config{}, - expectedConfig: &Config{}, - }, - "VerbositySpecified": { - inCfg: &Config{ - Verbosity: configtelemetry.LevelDetailed, - }, - expectedConfig: &Config{ - Verbosity: configtelemetry.LevelDetailed, - }, - }, - "LogLevelSpecified": { - inCfg: &Config{ - LogLevel: zapcore.DebugLevel, - }, - expectedConfig: &Config{ - LogLevel: zapcore.DebugLevel, - Verbosity: configtelemetry.LevelDetailed, - warnLogLevel: true, - }, - }, - "SpecifiedLogLevelExpectedErr": { - inCfg: &Config{ - // Cannot specify both log level and verbosity so an error is expected - LogLevel: zapcore.DebugLevel, - Verbosity: configtelemetry.LevelNormal, - }, - expectedErr: "'loglevel' and 'verbosity' are incompatible. Use only 'verbosity' instead", - }, - } { - t.Run(name, func(t *testing.T) { - - conf := confmap.New() - err := conf.Marshal(tc.inCfg) - require.NoError(t, err) - - raw := conf.ToStringMap() - - conf = confmap.NewFromStringMap(raw) - - outCfg := &Config{} - - err = conf.Unmarshal(outCfg) - - if tc.expectedErr == "" { - require.NoError(t, err) - assert.Equal(t, tc.expectedConfig, outCfg) - return - } - require.Error(t, err) - assert.EqualError(t, err, tc.expectedErr) - }) - } -} - -func TestValidate(t *testing.T) { - tests := []struct { - name string - cfg *Config - expectedErr string - }{ - { - name: "verbosity none", - cfg: &Config{ - Verbosity: configtelemetry.LevelNone, - }, - expectedErr: "verbosity level \"None\" is not supported", - }, - { - name: "verbosity detailed", - cfg: &Config{ - Verbosity: configtelemetry.LevelDetailed, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.cfg.Validate() - if tt.expectedErr != "" { - assert.EqualError(t, err, tt.expectedErr) - } else { - assert.NoError(t, err) - } - }) - } -} diff --git a/exporter/loggingexporter/doc.go b/exporter/loggingexporter/doc.go deleted file mode 100644 index 3a5c01850d9..00000000000 --- a/exporter/loggingexporter/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -//go:generate mdatagen metadata.yaml - -// Package loggingexporter exports data to console as logs. -package loggingexporter // import "go.opentelemetry.io/collector/exporter/loggingexporter" diff --git a/exporter/loggingexporter/factory.go b/exporter/loggingexporter/factory.go deleted file mode 100644 index c19d7e16ac6..00000000000 --- a/exporter/loggingexporter/factory.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package loggingexporter // import "go.opentelemetry.io/collector/exporter/loggingexporter" - -import ( - "context" - - "go.uber.org/zap/zapcore" - - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config/configtelemetry" - "go.opentelemetry.io/collector/exporter" - "go.opentelemetry.io/collector/exporter/internal/common" - "go.opentelemetry.io/collector/exporter/loggingexporter/internal/metadata" -) - -// The value of "type" key in configuration. -var componentType = component.MustNewType("logging") - -const ( - defaultSamplingInitial = 2 - defaultSamplingThereafter = 500 -) - -// NewFactory creates a factory for Logging exporter -func NewFactory() exporter.Factory { - return exporter.NewFactory( - componentType, - createDefaultConfig, - exporter.WithTraces(createTracesExporter, metadata.TracesStability), - exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability), - exporter.WithLogs(createLogsExporter, metadata.LogsStability), - ) -} - -func createDefaultConfig() component.Config { - return &Config{ - LogLevel: zapcore.InfoLevel, - Verbosity: configtelemetry.LevelNormal, - SamplingInitial: defaultSamplingInitial, - SamplingThereafter: defaultSamplingThereafter, - } -} - -func createTracesExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Traces, error) { - set.TelemetrySettings.Logger.Warn("The logging exporter is DEPRECATED and will be REMOVED in v0.111.0. Use the debug exporter instead: https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/debugexporter") - cfg := config.(*Config) - return common.CreateTracesExporter(ctx, set, config, &common.Common{ - Verbosity: cfg.Verbosity, - WarnLogLevel: cfg.warnLogLevel, - LogLevel: cfg.LogLevel, - SamplingInitial: cfg.SamplingInitial, - SamplingThereafter: cfg.SamplingThereafter, - }) -} - -func createMetricsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Metrics, error) { - set.TelemetrySettings.Logger.Warn("The logging exporter is DEPRECATED and will be REMOVED in v0.111.0. Use the debug exporter instead: https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/debugexporter") - cfg := config.(*Config) - return common.CreateMetricsExporter(ctx, set, config, &common.Common{ - Verbosity: cfg.Verbosity, - WarnLogLevel: cfg.warnLogLevel, - LogLevel: cfg.LogLevel, - SamplingInitial: cfg.SamplingInitial, - SamplingThereafter: cfg.SamplingThereafter, - }) -} - -func createLogsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Logs, error) { - set.TelemetrySettings.Logger.Warn("The logging exporter is DEPRECATED and will be REMOVED in v0.111.0. Use the debug exporter instead: https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/debugexporter") - cfg := config.(*Config) - return common.CreateLogsExporter(ctx, set, config, &common.Common{ - Verbosity: cfg.Verbosity, - WarnLogLevel: cfg.warnLogLevel, - LogLevel: cfg.LogLevel, - SamplingInitial: cfg.SamplingInitial, - SamplingThereafter: cfg.SamplingThereafter, - }) -} diff --git a/exporter/loggingexporter/factory_test.go b/exporter/loggingexporter/factory_test.go deleted file mode 100644 index 2b35acddf3c..00000000000 --- a/exporter/loggingexporter/factory_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package loggingexporter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/exporter/exportertest" -) - -func TestCreateDefaultConfig(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - assert.NotNil(t, cfg, "failed to create default config") - assert.NoError(t, componenttest.CheckConfigStruct(cfg)) -} - -func TestCreateMetricsExporter(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - - me, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopSettings(), cfg) - require.NoError(t, err) - assert.NotNil(t, me) -} - -func TestCreateTracesExporter(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - - te, err := factory.CreateTracesExporter(context.Background(), exportertest.NewNopSettings(), cfg) - require.NoError(t, err) - assert.NotNil(t, te) -} - -func TestCreateLogsExporter(t *testing.T) { - factory := NewFactory() - cfg := factory.CreateDefaultConfig() - - te, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopSettings(), cfg) - require.NoError(t, err) - assert.NotNil(t, te) -} diff --git a/exporter/loggingexporter/generated_component_test.go b/exporter/loggingexporter/generated_component_test.go deleted file mode 100644 index be058ef46c5..00000000000 --- a/exporter/loggingexporter/generated_component_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by mdatagen. DO NOT EDIT. - -package loggingexporter - -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/exporter" - "go.opentelemetry.io/collector/exporter/exportertest" - "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/plog" - "go.opentelemetry.io/collector/pdata/pmetric" - "go.opentelemetry.io/collector/pdata/ptrace" -) - -func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "logging", 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 exporter.Settings, cfg component.Config) (component.Component, error) - }{ - - { - name: "logs", - createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsExporter(ctx, set, cfg) - }, - }, - - { - name: "metrics", - createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsExporter(ctx, set, cfg) - }, - }, - - { - name: "traces", - createFn: func(ctx context.Context, set exporter.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesExporter(ctx, set, cfg) - }, - }, - } - - 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 _, tt := range tests { - t.Run(tt.name+"-shutdown", func(t *testing.T) { - c, err := tt.createFn(context.Background(), exportertest.NewNopSettings(), cfg) - require.NoError(t, err) - err = c.Shutdown(context.Background()) - require.NoError(t, err) - }) - t.Run(tt.name+"-lifecycle", func(t *testing.T) { - c, err := tt.createFn(context.Background(), exportertest.NewNopSettings(), cfg) - require.NoError(t, err) - host := componenttest.NewNopHost() - err = c.Start(context.Background(), host) - require.NoError(t, err) - require.NotPanics(t, func() { - switch tt.name { - case "logs": - e, ok := c.(exporter.Logs) - require.True(t, ok) - logs := generateLifecycleTestLogs() - if !e.Capabilities().MutatesData { - logs.MarkReadOnly() - } - err = e.ConsumeLogs(context.Background(), logs) - case "metrics": - e, ok := c.(exporter.Metrics) - require.True(t, ok) - metrics := generateLifecycleTestMetrics() - if !e.Capabilities().MutatesData { - metrics.MarkReadOnly() - } - err = e.ConsumeMetrics(context.Background(), metrics) - case "traces": - e, ok := c.(exporter.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 generateLifecycleTestLogs() plog.Logs { - logs := plog.NewLogs() - rl := logs.ResourceLogs().AppendEmpty() - rl.Resource().Attributes().PutStr("resource", "R1") - l := rl.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() - l.Body().SetStr("test log message") - l.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) - return logs -} - -func generateLifecycleTestMetrics() pmetric.Metrics { - metrics := pmetric.NewMetrics() - rm := metrics.ResourceMetrics().AppendEmpty() - rm.Resource().Attributes().PutStr("resource", "R1") - m := rm.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() - m.SetName("test_metric") - dp := m.SetEmptyGauge().DataPoints().AppendEmpty() - dp.Attributes().PutStr("test_attr", "value_1") - dp.SetIntValue(123) - dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) - return metrics -} - -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/exporter/loggingexporter/generated_package_test.go b/exporter/loggingexporter/generated_package_test.go deleted file mode 100644 index 14eb697fde5..00000000000 --- a/exporter/loggingexporter/generated_package_test.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by mdatagen. DO NOT EDIT. - -package loggingexporter - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} diff --git a/exporter/loggingexporter/go.mod b/exporter/loggingexporter/go.mod deleted file mode 100644 index 49e11a93fd9..00000000000 --- a/exporter/loggingexporter/go.mod +++ /dev/null @@ -1,100 +0,0 @@ -// Deprecated: loggingexporter is deprecated in favour of the debugexporter. It will be removed in September 2024. -module go.opentelemetry.io/collector/exporter/loggingexporter - -go 1.22.0 - -require ( - github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/component v0.110.0 - go.opentelemetry.io/collector/config/configtelemetry v0.110.0 - go.opentelemetry.io/collector/confmap v1.16.0 - go.opentelemetry.io/collector/exporter v0.110.0 - go.opentelemetry.io/collector/pdata v1.16.0 - go.uber.org/goleak v1.3.0 - go.uber.org/zap v1.27.0 -) - -require ( - github.com/cenkalti/backoff/v4 v4.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.1.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/uuid v1.6.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/pmezard/go-difflib v1.0.0 // indirect - go.opentelemetry.io/collector/config/configretry v1.16.0 // indirect - go.opentelemetry.io/collector/consumer v0.110.0 // indirect - go.opentelemetry.io/collector/consumer/consumerprofiles v0.110.0 // indirect - go.opentelemetry.io/collector/consumer/consumertest v0.110.0 // indirect - go.opentelemetry.io/collector/exporter/exporterprofiles v0.110.0 // indirect - go.opentelemetry.io/collector/extension v0.110.0 // indirect - go.opentelemetry.io/collector/extension/experimental/storage v0.110.0 // indirect - go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect - go.opentelemetry.io/collector/pdata/pprofile v0.110.0 // indirect - go.opentelemetry.io/collector/pipeline v0.110.0 // indirect - go.opentelemetry.io/collector/receiver v0.110.0 // indirect - go.opentelemetry.io/collector/receiver/receiverprofiles v0.110.0 // indirect - go.opentelemetry.io/otel v1.30.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - go.opentelemetry.io/otel/sdk v1.30.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect - google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - -replace go.opentelemetry.io/collector/component => ../../component - -replace go.opentelemetry.io/collector/confmap => ../../confmap - -replace go.opentelemetry.io/collector/consumer => ../../consumer - -replace go.opentelemetry.io/collector/exporter => ../ - -replace go.opentelemetry.io/collector/extension => ../../extension - -replace go.opentelemetry.io/collector/extension/experimental/storage => ../../extension/experimental/storage - -replace go.opentelemetry.io/collector/pdata => ../../pdata - -replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata - -replace go.opentelemetry.io/collector/receiver => ../../receiver - -retract ( - v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 - v0.69.0 // Release failed, use v0.69.1 -) - -replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry - -replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry - -replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile - -replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles - -replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest - -replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles - -replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles - -replace go.opentelemetry.io/collector/pipeline => ../../pipeline - -replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/exporter/loggingexporter/go.sum b/exporter/loggingexporter/go.sum deleted file mode 100644 index 0c99067a705..00000000000 --- a/exporter/loggingexporter/go.sum +++ /dev/null @@ -1,110 +0,0 @@ -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -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.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.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/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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -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/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= -go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= -go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/sdk/metric v1.30.0 h1:QJLT8Pe11jyHBHfSAgYH7kEmT24eX792jZO1bo4BXkM= -go.opentelemetry.io/otel/sdk/metric v1.30.0/go.mod h1:waS6P3YqFNzeP01kuo/MBBYqaoBJl7efRQHOaydhy1Y= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= -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.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -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.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.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.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -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-20240822170219-fc7c04adadcd h1:6TEm2ZxXoQmFWFlt1vNxvVOa1Q0dXFQD1m/rYjXmS0E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -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/exporter/loggingexporter/internal/metadata/generated_status.go b/exporter/loggingexporter/internal/metadata/generated_status.go deleted file mode 100644 index 7c415b23aae..00000000000 --- a/exporter/loggingexporter/internal/metadata/generated_status.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by mdatagen. DO NOT EDIT. - -package metadata - -import ( - "go.opentelemetry.io/collector/component" -) - -var ( - Type = component.MustNewType("logging") - ScopeName = "go.opentelemetry.io/collector/exporter/loggingexporter" -) - -const ( - TracesStability = component.StabilityLevelDeprecated - MetricsStability = component.StabilityLevelDeprecated - LogsStability = component.StabilityLevelDeprecated -) diff --git a/exporter/loggingexporter/metadata.yaml b/exporter/loggingexporter/metadata.yaml deleted file mode 100644 index 135c1749611..00000000000 --- a/exporter/loggingexporter/metadata.yaml +++ /dev/null @@ -1,8 +0,0 @@ -type: logging -github_project: open-telemetry/opentelemetry-collector - -status: - class: exporter - stability: - deprecated: [traces, metrics, logs] - distributions: [core, contrib] diff --git a/exporter/loggingexporter/testdata/config_loglevel.yaml b/exporter/loggingexporter/testdata/config_loglevel.yaml deleted file mode 100644 index ffe8a0df593..00000000000 --- a/exporter/loggingexporter/testdata/config_loglevel.yaml +++ /dev/null @@ -1,3 +0,0 @@ -loglevel: debug -sampling_initial: 10 -sampling_thereafter: 50 diff --git a/exporter/loggingexporter/testdata/config_loglevel_typo.yaml b/exporter/loggingexporter/testdata/config_loglevel_typo.yaml deleted file mode 100644 index 59222127eb7..00000000000 --- a/exporter/loggingexporter/testdata/config_loglevel_typo.yaml +++ /dev/null @@ -1,2 +0,0 @@ -# Typo in the configuration that assumes that this property is camelcase -logLevel: debug diff --git a/exporter/loggingexporter/testdata/config_verbosity.yaml b/exporter/loggingexporter/testdata/config_verbosity.yaml deleted file mode 100644 index 4ea62997627..00000000000 --- a/exporter/loggingexporter/testdata/config_verbosity.yaml +++ /dev/null @@ -1,3 +0,0 @@ -verbosity: detailed -sampling_initial: 10 -sampling_thereafter: 50 diff --git a/exporter/loggingexporter/testdata/invalid_verbosity_loglevel.yaml b/exporter/loggingexporter/testdata/invalid_verbosity_loglevel.yaml deleted file mode 100644 index 37f8f16b24f..00000000000 --- a/exporter/loggingexporter/testdata/invalid_verbosity_loglevel.yaml +++ /dev/null @@ -1,2 +0,0 @@ -loglevel: info -verbosity: detailed diff --git a/exporter/loggingexporter/testdata/loglevel_info.yaml b/exporter/loggingexporter/testdata/loglevel_info.yaml deleted file mode 100644 index 63506faefb4..00000000000 --- a/exporter/loggingexporter/testdata/loglevel_info.yaml +++ /dev/null @@ -1 +0,0 @@ -loglevel: info diff --git a/otelcol/internal/configunmarshaler/configs.go b/otelcol/internal/configunmarshaler/configs.go index 341c6fcad9d..e60ab5d29b4 100644 --- a/otelcol/internal/configunmarshaler/configs.go +++ b/otelcol/internal/configunmarshaler/configs.go @@ -4,6 +4,7 @@ package configunmarshaler // import "go.opentelemetry.io/collector/otelcol/internal/configunmarshaler" import ( + "errors" "fmt" "golang.org/x/exp/maps" @@ -64,6 +65,9 @@ func (c *Configs[F]) Configs() map[component.ID]component.Config { } func errorUnknownType(id component.ID, factories []component.Type) error { + if id.Type().String() == "logging" { + return errors.New("the logging exporter has been deprecated, use the debug exporter instead") + } return fmt.Errorf("unknown type: %q for id: %q (valid values: %v)", id.Type(), id, factories) } diff --git a/otelcol/internal/configunmarshaler/configs_test.go b/otelcol/internal/configunmarshaler/configs_test.go index c9cbdd9dba2..efbf97194b0 100644 --- a/otelcol/internal/configunmarshaler/configs_test.go +++ b/otelcol/internal/configunmarshaler/configs_test.go @@ -142,3 +142,15 @@ func TestUnmarshalError(t *testing.T) { }) } } + +func TestUnmarshal_LoggingExporter(t *testing.T) { + conf := confmap.NewFromStringMap(map[string]any{ + "logging": nil, + }) + factories := map[component.Type]component.Factory{ + nopType: exportertest.NewNopFactory(), + } + cfgs := NewConfigs(factories) + err := cfgs.Unmarshal(conf) + assert.ErrorContains(t, err, "the logging exporter has been deprecated, use the debug exporter instead") +} diff --git a/versions.yaml b/versions.yaml index 07b55e355a2..0ea5a162060 100644 --- a/versions.yaml +++ b/versions.yaml @@ -45,7 +45,6 @@ module-sets: - go.opentelemetry.io/collector/exporter - go.opentelemetry.io/collector/exporter/debugexporter - go.opentelemetry.io/collector/exporter/exporterprofiles - - go.opentelemetry.io/collector/exporter/loggingexporter - go.opentelemetry.io/collector/exporter/nopexporter - go.opentelemetry.io/collector/exporter/otlpexporter - go.opentelemetry.io/collector/exporter/otlphttpexporter From 2d25853c5f186585c626b183c7f169c4527d853d Mon Sep 17 00:00:00 2001 From: Damien Mathieu <42@dmathieu.com> Date: Thu, 3 Oct 2024 16:54:55 +0200 Subject: [PATCH 2/2] Use slices of pointers in pprofile (#11339) #### Description All these slices of values have a potential to store large amounts of data, and should therefore be slices of pointers. #### Link to tracking issue Fixes #11281 cc @mx-psi @bogdandrutu --- .chloggen/pprofile-slice-ptrs.yaml | 20 ++ .../cmd/pdatagen/internal/pprofile_package.go | 18 +- .../v1experimental/pprofextended.pb.go | 242 +++++++++--------- .../pprofile/generated_attributeunitslice.go | 34 ++- .../generated_attributeunitslice_test.go | 27 +- pdata/pprofile/generated_functionslice.go | 34 ++- .../pprofile/generated_functionslice_test.go | 27 +- pdata/pprofile/generated_labelslice.go | 34 ++- pdata/pprofile/generated_labelslice_test.go | 27 +- pdata/pprofile/generated_lineslice.go | 34 ++- pdata/pprofile/generated_lineslice_test.go | 27 +- pdata/pprofile/generated_linkslice.go | 34 ++- pdata/pprofile/generated_linkslice_test.go | 27 +- pdata/pprofile/generated_locationslice.go | 34 ++- .../pprofile/generated_locationslice_test.go | 27 +- pdata/pprofile/generated_mappingslice.go | 34 ++- pdata/pprofile/generated_mappingslice_test.go | 27 +- pdata/pprofile/generated_sampleslice.go | 34 ++- pdata/pprofile/generated_sampleslice_test.go | 27 +- pdata/pprofile/generated_valuetypeslice.go | 34 ++- .../pprofile/generated_valuetypeslice_test.go | 27 +- pdata/pprofile/profiles_test.go | 2 +- proto_patch.sed | 27 -- 23 files changed, 574 insertions(+), 284 deletions(-) create mode 100644 .chloggen/pprofile-slice-ptrs.yaml diff --git a/.chloggen/pprofile-slice-ptrs.yaml b/.chloggen/pprofile-slice-ptrs.yaml new file mode 100644 index 00000000000..5c4fcb8eb94 --- /dev/null +++ b/.chloggen/pprofile-slice-ptrs.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'breaking' + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: pdata/pprofile + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Replace slices of values to slices of pointers for the `Mapping`, `Location`, `Line`, `Function`, `AttributeUnit`, `Link`, `Value`, `Sample` and `Labels` attributes. + +# One or more tracking issues or pull requests related to the change +issues: [11339] + +# 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: [api] diff --git a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go index 875410c9e51..2e740137749 100644 --- a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go +++ b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go @@ -230,7 +230,7 @@ var profile = &messageValueStruct{ }, } -var valueTypeSlice = &sliceOfValues{ +var valueTypeSlice = &sliceOfPtrs{ structName: "ValueTypeSlice", element: valueType, } @@ -261,7 +261,7 @@ var valueType = &messageValueStruct{ }, } -var sampleSlice = &sliceOfValues{ +var sampleSlice = &sliceOfPtrs{ structName: "SampleSlice", element: sample, } @@ -318,7 +318,7 @@ var sample = &messageValueStruct{ }, } -var labelSlice = &sliceOfValues{ +var labelSlice = &sliceOfPtrs{ structName: "LabelSlice", element: label, } @@ -355,7 +355,7 @@ var label = &messageValueStruct{ }, } -var mappingSlice = &sliceOfValues{ +var mappingSlice = &sliceOfPtrs{ structName: "MappingSlice", element: mapping, } @@ -441,7 +441,7 @@ var mapping = &messageValueStruct{ }, } -var locationSlice = &sliceOfValues{ +var locationSlice = &sliceOfPtrs{ structName: "LocationSlice", element: location, } @@ -492,7 +492,7 @@ var location = &messageValueStruct{ }, } -var lineSlice = &sliceOfValues{ +var lineSlice = &sliceOfPtrs{ structName: "LineSlice", element: line, } @@ -523,7 +523,7 @@ var line = &messageValueStruct{ }, } -var functionSlice = &sliceOfValues{ +var functionSlice = &sliceOfPtrs{ structName: "FunctionSlice", element: function, } @@ -567,7 +567,7 @@ var function = &messageValueStruct{ }, } -var attributeUnitSlice = &sliceOfValues{ +var attributeUnitSlice = &sliceOfPtrs{ structName: "AttributeUnitSlice", element: attributeUnit, } @@ -592,7 +592,7 @@ var attributeUnit = &messageValueStruct{ }, } -var linkSlice = &sliceOfValues{ +var linkSlice = &sliceOfPtrs{ structName: "LinkSlice", element: link, } diff --git a/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go b/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go index 64c91b3221e..7b90b35373f 100644 --- a/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go +++ b/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go @@ -157,24 +157,24 @@ type Profile struct { // If one of the values represents the number of events represented // by the sample, by convention it should be at index 0 and use // sample_type.unit == "count". - SampleType []ValueType `protobuf:"bytes,1,rep,name=sample_type,json=sampleType,proto3" json:"sample_type"` + SampleType []*ValueType `protobuf:"bytes,1,rep,name=sample_type,json=sampleType,proto3" json:"sample_type,omitempty"` // The set of samples recorded in this profile. - Sample []Sample `protobuf:"bytes,2,rep,name=sample,proto3" json:"sample"` + Sample []*Sample `protobuf:"bytes,2,rep,name=sample,proto3" json:"sample,omitempty"` // Mapping from address ranges to the image/binary/library mapped // into that address range. mapping[0] will be the main binary. - Mapping []Mapping `protobuf:"bytes,3,rep,name=mapping,proto3" json:"mapping"` + Mapping []*Mapping `protobuf:"bytes,3,rep,name=mapping,proto3" json:"mapping,omitempty"` // Locations referenced by samples via location_indices. - Location []Location `protobuf:"bytes,4,rep,name=location,proto3" json:"location"` + Location []*Location `protobuf:"bytes,4,rep,name=location,proto3" json:"location,omitempty"` // Array of locations referenced by samples. LocationIndices []int64 `protobuf:"varint,15,rep,packed,name=location_indices,json=locationIndices,proto3" json:"location_indices,omitempty"` // Functions referenced by locations. - Function []Function `protobuf:"bytes,5,rep,name=function,proto3" json:"function"` + Function []*Function `protobuf:"bytes,5,rep,name=function,proto3" json:"function,omitempty"` // Lookup table for attributes. AttributeTable []v1.KeyValue `protobuf:"bytes,16,rep,name=attribute_table,json=attributeTable,proto3" json:"attribute_table"` // Represents a mapping between Attribute Keys and Units. - AttributeUnits []AttributeUnit `protobuf:"bytes,17,rep,name=attribute_units,json=attributeUnits,proto3" json:"attribute_units"` + AttributeUnits []*AttributeUnit `protobuf:"bytes,17,rep,name=attribute_units,json=attributeUnits,proto3" json:"attribute_units,omitempty"` // Lookup table for links. - LinkTable []Link `protobuf:"bytes,18,rep,name=link_table,json=linkTable,proto3" json:"link_table"` + LinkTable []*Link `protobuf:"bytes,18,rep,name=link_table,json=linkTable,proto3" json:"link_table,omitempty"` // A common table for strings referenced by various messages. // string_table[0] must always be "". StringTable []string `protobuf:"bytes,6,rep,name=string_table,json=stringTable,proto3" json:"string_table,omitempty"` @@ -237,28 +237,28 @@ func (m *Profile) XXX_DiscardUnknown() { var xxx_messageInfo_Profile proto.InternalMessageInfo -func (m *Profile) GetSampleType() []ValueType { +func (m *Profile) GetSampleType() []*ValueType { if m != nil { return m.SampleType } return nil } -func (m *Profile) GetSample() []Sample { +func (m *Profile) GetSample() []*Sample { if m != nil { return m.Sample } return nil } -func (m *Profile) GetMapping() []Mapping { +func (m *Profile) GetMapping() []*Mapping { if m != nil { return m.Mapping } return nil } -func (m *Profile) GetLocation() []Location { +func (m *Profile) GetLocation() []*Location { if m != nil { return m.Location } @@ -272,7 +272,7 @@ func (m *Profile) GetLocationIndices() []int64 { return nil } -func (m *Profile) GetFunction() []Function { +func (m *Profile) GetFunction() []*Function { if m != nil { return m.Function } @@ -286,14 +286,14 @@ func (m *Profile) GetAttributeTable() []v1.KeyValue { return nil } -func (m *Profile) GetAttributeUnits() []AttributeUnit { +func (m *Profile) GetAttributeUnits() []*AttributeUnit { if m != nil { return m.AttributeUnits } return nil } -func (m *Profile) GetLinkTable() []Link { +func (m *Profile) GetLinkTable() []*Link { if m != nil { return m.LinkTable } @@ -554,7 +554,7 @@ type Sample struct { // discouraged case is having a string label and a numeric label of the same // name on a sample. Again, possible to express, but should not be used. // [deprecated, superseded by attributes] - Label []Label `protobuf:"bytes,3,rep,name=label,proto3" json:"label"` + Label []*Label `protobuf:"bytes,3,rep,name=label,proto3" json:"label,omitempty"` // References to attributes in Profile.attribute_table. [optional] Attributes []uint64 `protobuf:"varint,10,rep,packed,name=attributes,proto3" json:"attributes,omitempty"` // Reference to link in Profile.link_table. [optional] @@ -632,7 +632,7 @@ func (m *Sample) GetValue() []int64 { return nil } -func (m *Sample) GetLabel() []Label { +func (m *Sample) GetLabel() []*Label { if m != nil { return m.Label } @@ -907,7 +907,7 @@ type Location struct { // E.g., if memcpy() is inlined into printf: // line[0].function_name == "memcpy" // line[1].function_name == "printf" - Line []Line `protobuf:"bytes,4,rep,name=line,proto3" json:"line"` + Line []*Line `protobuf:"bytes,4,rep,name=line,proto3" json:"line,omitempty"` // Provides an indication that multiple symbols map to this location's // address, for example due to identical code folding by the linker. In that // case the line information above represents one of the multiple @@ -974,7 +974,7 @@ func (m *Location) GetAddress() uint64 { return 0 } -func (m *Location) GetLine() []Line { +func (m *Location) GetLine() []*Line { if m != nil { return m.Line } @@ -1170,100 +1170,100 @@ func init() { } var fileDescriptor_05f9ce3fdbeb046f = []byte{ - // 1483 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcd, 0x4f, 0x1b, 0x47, - 0x1b, 0xc7, 0x1f, 0xf8, 0xe3, 0x31, 0x06, 0x33, 0xe1, 0xe5, 0xdd, 0x37, 0xaf, 0x02, 0xc4, 0xa8, - 0x0d, 0x25, 0x92, 0x29, 0xa4, 0xad, 0xd2, 0xaa, 0x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0x5e, 0x84, 0x18, 0x3f, 0xd3, 0xe2, 0x45, 0x29, 0xa5, 0x9e, 0x70, 0x17, - 0xa6, 0x62, 0x11, 0x31, 0xde, 0xd5, 0xca, 0xb9, 0xa5, 0xcc, 0x4a, 0xd1, 0x2a, 0x29, 0x4c, 0x51, - 0x16, 0xa1, 0xe4, 0x46, 0x41, 0x68, 0x9f, 0x44, 0x8e, 0x4f, 0x63, 0x23, 0xbf, 0x94, 0x5a, 0xc9, - 0x58, 0x20, 0xa1, 0x6d, 0x44, 0x24, 0xe1, 0x8c, 0xd2, 0x01, 0xa1, 0xa0, 0x08, 0x12, 0xd2, 0x84, - 0x3b, 0x00, 0x82, 0xf9, 0xd4, 0xe6, 0x0e, 0x0f, 0x62, 0xa3, 0x88, 0xfb, 0x45, 0x89, 0xb4, 0x24, - 0x40, 0xde, 0x83, 0x69, 0xb7, 0x17, 0xa9, 0x14, 0x51, 0x14, 0x40, 0x4a, 0x39, 0x41, 0x15, 0xed, - 0x39, 0x94, 0xe4, 0x73, 0x02, 0x57, 0x95, 0x6a, 0x69, 0x29, 0xf5, 0xef, 0x4b, 0x55, 0x09, 0x62, - 0xa9, 0xce, 0x43, 0x4e, 0x59, 0xc6, 0x14, 0xde, 0xae, 0x2d, 0x62, 0x40, 0x5e, 0x26, 0x04, 0xe5, - 0xc2, 0x28, 0x63, 0xde, 0x26, 0x26, 0xa9, 0xc1, 0x2d, 0x97, 0x9e, 0x38, 0x3d, 0x4f, 0xd8, 0xa3, - 0x3d, 0x64, 0x1a, 0x8f, 0xcf, 0xea, 0xad, 0xfd, 0x41, 0x33, 0xa8, 0x3e, 0x81, 0xf2, 0xa5, 0x50, - 0x93, 0x65, 0x28, 0x0f, 0xf3, 0xe7, 0x8c, 0xf6, 0x8d, 0x14, 0x1e, 0x9d, 0x1a, 0x80, 0x3b, 0xb4, - 0x4f, 0x08, 0x64, 0x65, 0x6a, 0x19, 0x69, 0xdc, 0xc3, 0x75, 0xf5, 0xd7, 0x14, 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 0x3b, 0xb2, 0x56, 0x49, 0x61, - 0x18, 0xc4, 0x11, 0x8a, 0xc7, 0x7c, 0x26, 0xf0, 0xd2, 0x01, 0xa5, 0x29, 0x21, 0xd9, 0x30, 0xe5, - 0xc7, 0xb4, 0x83, 0x93, 0x93, 0x98, 0xaa, 0xfb, 0xb3, 0x16, 0x48, 0x68, 0x17, 0x11, 0x72, 0x1b, - 0x0a, 0xd2, 0xe2, 0x8e, 0x4f, 0x8d, 0x49, 0xf4, 0x6e, 0x60, 0x4b, 0xcf, 0x8f, 0x7b, 0xcc, 0x73, - 0x65, 0x55, 0xe6, 0x94, 0xe7, 0x68, 0x9b, 0x2e, 0x79, 0x06, 0xe5, 0x64, 0xcb, 0x3e, 0x63, 0xdc, - 0xc5, 0x1e, 0x39, 0xbd, 0xf1, 0x70, 0xac, 0x88, 0x6e, 0x2a, 0xb1, 0x1d, 0xc6, 0x5d, 0xab, 0x74, - 0x3c, 0x34, 0xae, 0xc4, 0x75, 0xea, 0x5a, 0x5c, 0x97, 0xa1, 0x7c, 0xea, 0xc4, 0x76, 0x32, 0x75, - 0xd5, 0xa4, 0x28, 0x58, 0x53, 0xa7, 0x4e, 0x9c, 0x4c, 0xe6, 0x21, 0x49, 0xbf, 0x46, 0x4d, 0x0b, - 0x4d, 0x4a, 0x30, 0xb2, 0x02, 0x15, 0x49, 0xf2, 0x18, 0xa7, 0x36, 0xef, 0xf9, 0xc7, 0x34, 0x52, - 0x53, 0xa3, 0x60, 0x4d, 0x9f, 0x3a, 0x71, 0x93, 0x71, 0xda, 0x52, 0x28, 0x59, 0x85, 0x59, 0xc9, - 0x64, 0x1c, 0xb9, 0x7a, 0x00, 0x01, 0x52, 0x67, 0x4e, 0x9d, 0xd8, 0x44, 0x5c, 0x4d, 0xa1, 0xea, - 0xf7, 0x69, 0x28, 0x24, 0x3f, 0x53, 0xae, 0x05, 0x76, 0x19, 0xca, 0xfa, 0xa7, 0x90, 0x2e, 0x22, - 0x15, 0xd9, 0x29,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0xd0, 0xda, 0xdf, 0x6b, 0x3c, 0x32, 0xb7, - 0xcd, 0xc6, 0x56, 0x65, 0x82, 0xdc, 0x85, 0x3b, 0xef, 0x22, 0x6e, 0x35, 0x9a, 0xed, 0x7a, 0x25, - 0x45, 0xde, 0x87, 0xea, 0xbb, 0x28, 0x8f, 0x0e, 0x9e, 0x1e, 0x34, 0xeb, 0x6d, 0xf3, 0xb0, 0x51, - 0x49, 0xaf, 0x7e, 0x0e, 0xa5, 0x91, 0xba, 0x22, 0xb7, 0x60, 0x66, 0xf3, 0xc0, 0x6c, 0x6e, 0xd9, - 0xe6, 0x96, 0xdd, 0x34, 0x5b, 0x3b, 0x0d, 0xab, 0x32, 0x41, 0x0c, 0x98, 0x1b, 0x80, 0x9b, 0x66, - 0xab, 0x6e, 0x1d, 0xd9, 0x4f, 0xea, 0xfb, 0x4f, 0x2a, 0xa9, 0xcd, 0x9f, 0x52, 0x2f, 0xdf, 0x2c, - 0xa4, 0x5e, 0xbd, 0x59, 0x48, 0xfd, 0xf9, 0x66, 0x21, 0xf5, 0xe3, 0xdb, 0x85, 0x89, 0x57, 0x6f, - 0x17, 0x26, 0x7e, 0x7f, 0xbb, 0x30, 0xf1, 0xad, 0x35, 0xf6, 0x24, 0x56, 0xff, 0x1b, 0x75, 0x29, - 0x7f, 0xd7, 0xbf, 0x68, 0x3f, 0xa7, 0xef, 0xef, 0x86, 0x94, 0xb7, 0x07, 0x8a, 0x7b, 0x98, 0xbe, - 0x7b, 0x49, 0xfa, 0x1e, 0xae, 0x37, 0x46, 0xd8, 0xc7, 0x39, 0xd4, 0x7b, 0xf0, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xef, 0x03, 0x47, 0x6d, 0x06, 0x0e, 0x00, 0x00, + // 1480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4f, 0x4f, 0x23, 0x47, + 0x16, 0x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 0x39, 0x8e, 0xb8, 0x27, 0x46, 0x2e, 0x91, 0x66, 0x42, 0x0e, 0x00, 0x7c, 0x8f, 0x5f, 0xe8, 0xb8, + 0x09, 0xf2, 0x6f, 0x8c, 0x97, 0x0f, 0x8f, 0x5f, 0xd0, 0xa2, 0x24, 0x51, 0x61, 0xdf, 0x87, 0xe9, + 0x44, 0xc4, 0x1e, 0xef, 0x6a, 0xce, 0xdc, 0x72, 0x66, 0xb5, 0x48, 0x4b, 0x0a, 0x53, 0x2e, 0x4b, + 0x50, 0x72, 0xe3, 0x30, 0xb2, 0xcf, 0x62, 0x27, 0x60, 0x89, 0x99, 0x5f, 0x36, 0x56, 0x33, 0x14, + 0x24, 0xb4, 0x83, 0x88, 0x74, 0xb8, 0x60, 0x6c, 0xe0, 0x50, 0x50, 0x0e, 0x12, 0xd2, 0x0e, 0xf7, + 0x00, 0x84, 0x17, 0x30, 0x9b, 0x3b, 0x3c, 0x4c, 0xcc, 0x22, 0xee, 0x17, 0x25, 0xd2, 0x92, 0x00, + 0xf9, 0x17, 0xcc, 0xb8, 0xbd, 0x58, 0x15, 0x84, 0x72, 0x01, 0x74, 0x29, 0xa7, 0xa8, 0x72, 0xfb, + 0x0a, 0x4a, 0xf2, 0x21, 0xa1, 0xab, 0x04, 0x58, 0x5a, 0x36, 0xde, 0x5f, 0x80, 0x3a, 0x89, 0xa0, + 0x08, 0x51, 0x86, 0x0b, 0x90, 0x53, 0x96, 0x39, 0x8d, 0xb7, 0x6b, 0x8b, 0x98, 0x90, 0x97, 0x45, + 0xc0, 0xb8, 0x30, 0xcb, 0x58, 0xa5, 0xa9, 0x49, 0x6a, 0x70, 0xc7, 0x65, 0x67, 0x4e, 0xcf, 0x17, + 0xf6, 0x68, 0x67, 0x98, 0xc1, 0xe3, 0x73, 0x7a, 0xeb, 0x70, 0x20, 0xf4, 0xea, 0x2e, 0x94, 0xaf, + 0xa5, 0x97, 0xac, 0x40, 0x79, 0x58, 0x33, 0x17, 0xac, 0x6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x8c, 0x5d, 0x91, + 0x4d, 0xf8, 0x5b, 0x0a, 0x24, 0x76, 0x22, 0x9c, 0x58, 0x68, 0x6f, 0x29, 0xa2, 0x2c, 0xbd, 0x33, + 0xd8, 0x3c, 0x94, 0x7b, 0xea, 0xcc, 0x48, 0x7b, 0x4c, 0x6c, 0x9f, 0xf1, 0xae, 0x38, 0x47, 0x49, + 0x65, 0x87, 0xed, 0x31, 0x69, 0x22, 0x2c, 0x0b, 0x30, 0x11, 0x4e, 0xe7, 0x22, 0x2d, 0x01, 0x4d, + 0x2e, 0x05, 0x56, 0xa6, 0x73, 0xc3, 0x2d, 0xcb, 0x55, 0xd4, 0xf3, 0x30, 0x75, 0x29, 0xbf, 0x39, + 0x0e, 0x9a, 0x0c, 0x55, 0x06, 0xd9, 0x85, 0x29, 0xdf, 0x39, 0x65, 0xbe, 0x1e, 0x18, 0x9b, 0xe3, + 0xf5, 0x13, 0x79, 0x92, 0x2a, 0x02, 0xb2, 0x08, 0x30, 0x28, 0x5d, 0x29, 0x62, 0xf9, 0x45, 0x46, + 0x10, 0x99, 0x52, 0xd9, 0x79, 0x50, 0x60, 0x59, 0x8a, 0x6b, 0xf2, 0x5f, 0x98, 0x97, 0x9d, 0x20, + 0x11, 0x4e, 0x10, 0x25, 0xb2, 0x71, 0x5e, 0x61, 0x0f, 0x40, 0xad, 0x65, 0x29, 0x19, 0xee, 0x1d, + 0x71, 0xef, 0x4a, 0x36, 0x82, 0xea, 0x17, 0x30, 0x85, 0xb7, 0x92, 0x0a, 0x64, 0x86, 0xa2, 0x91, + 0x4b, 0x89, 0x24, 0x22, 0xd6, 0x25, 0x23, 0x97, 0x12, 0xe1, 0xbd, 0x00, 0xab, 0x23, 0x43, 0xe5, + 0x92, 0xfc, 0x03, 0x0a, 0xbc, 0x17, 0x60, 0x8b, 0x36, 0xb3, 0x08, 0xe7, 0x79, 0x2f, 0x90, 0x7a, + 0xac, 0xfe, 0x9a, 0x81, 0xbc, 0x9e, 0x80, 0x64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2, 0xc6, 0xd3, 0x7a, 0xdb, 0xda, 0x6f, 0xd9, 0xed, 0xc6, 0xb3, 0x83, + 0x7d, 0x5a, 0x6f, 0x5a, 0xed, 0x13, 0xfb, 0xa8, 0x75, 0x78, 0xd0, 0x78, 0x62, 0xed, 0x58, 0x8d, + 0xed, 0xca, 0x04, 0xb9, 0x0f, 0xf7, 0xde, 0xe5, 0xb8, 0xdd, 0x68, 0xb6, 0xeb, 0x15, 0x83, 0xfc, + 0x1b, 0xaa, 0xef, 0x72, 0x79, 0x72, 0xf4, 0xec, 0xa8, 0x59, 0x6f, 0x5b, 0xc7, 0x8d, 0xca, 0xe4, + 0xda, 0xc7, 0x50, 0x1a, 0x51, 0x14, 0xb9, 0x03, 0xb3, 0x5b, 0x47, 0x56, 0x73, 0xdb, 0xb6, 0xb6, + 0xed, 0xa6, 0xd5, 0xda, 0x6b, 0xd0, 0xca, 0x04, 0x31, 0x61, 0x7e, 0x00, 0x6e, 0x59, 0xad, 0x3a, + 0x3d, 0xb1, 0x77, 0xeb, 0x87, 0xbb, 0x15, 0x63, 0xeb, 0x07, 0xe3, 0xc5, 0xeb, 0x45, 0xe3, 0xe5, + 0xeb, 0x45, 0xe3, 0x8f, 0xd7, 0x8b, 0xc6, 0xf7, 0x6f, 0x16, 0x27, 0x5e, 0xbe, 0x59, 0x9c, 0xf8, + 0xed, 0xcd, 0xe2, 0xc4, 0x97, 0x74, 0xec, 0xe9, 0xab, 0xfe, 0xcb, 0xe9, 0x32, 0xfe, 0xae, 0x7f, + 0xb6, 0x7e, 0x9c, 0x7c, 0xb8, 0x1f, 0x31, 0xde, 0x1e, 0x30, 0x1e, 0x60, 0xe1, 0x1e, 0xa4, 0x85, + 0x7b, 0xbc, 0xd1, 0x18, 0xf1, 0x3e, 0xcd, 0x21, 0xdf, 0xa3, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x92, 0x79, 0x01, 0x14, 0xd0, 0x0d, 0x00, 0x00, } func (m *Profile) Marshal() (dAtA []byte, err error) { @@ -2490,7 +2490,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SampleType = append(m.SampleType, ValueType{}) + m.SampleType = append(m.SampleType, &ValueType{}) if err := m.SampleType[len(m.SampleType)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2524,7 +2524,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sample = append(m.Sample, Sample{}) + m.Sample = append(m.Sample, &Sample{}) if err := m.Sample[len(m.Sample)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2558,7 +2558,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Mapping = append(m.Mapping, Mapping{}) + m.Mapping = append(m.Mapping, &Mapping{}) if err := m.Mapping[len(m.Mapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2592,7 +2592,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Location = append(m.Location, Location{}) + m.Location = append(m.Location, &Location{}) if err := m.Location[len(m.Location)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2626,7 +2626,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Function = append(m.Function, Function{}) + m.Function = append(m.Function, &Function{}) if err := m.Function[len(m.Function)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3025,7 +3025,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AttributeUnits = append(m.AttributeUnits, AttributeUnit{}) + m.AttributeUnits = append(m.AttributeUnits, &AttributeUnit{}) if err := m.AttributeUnits[len(m.AttributeUnits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3059,7 +3059,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LinkTable = append(m.LinkTable, Link{}) + m.LinkTable = append(m.LinkTable, &Link{}) if err := m.LinkTable[len(m.LinkTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3606,7 +3606,7 @@ func (m *Sample) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Label = append(m.Label, Label{}) + m.Label = append(m.Label, &Label{}) if err := m.Label[len(m.Label)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4440,7 +4440,7 @@ func (m *Location) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Line = append(m.Line, Line{}) + m.Line = append(m.Line, &Line{}) if err := m.Line[len(m.Line)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pdata/pprofile/generated_attributeunitslice.go b/pdata/pprofile/generated_attributeunitslice.go index 95274cfe446..eaf8baf57ed 100644 --- a/pdata/pprofile/generated_attributeunitslice.go +++ b/pdata/pprofile/generated_attributeunitslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewAttributeUnitSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type AttributeUnitSlice struct { - orig *[]otlpprofiles.AttributeUnit + orig *[]*otlpprofiles.AttributeUnit state *internal.State } -func newAttributeUnitSlice(orig *[]otlpprofiles.AttributeUnit, state *internal.State) AttributeUnitSlice { +func newAttributeUnitSlice(orig *[]*otlpprofiles.AttributeUnit, state *internal.State) AttributeUnitSlice { return AttributeUnitSlice{orig: orig, state: state} } // NewAttributeUnitSlice creates a AttributeUnitSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewAttributeUnitSlice() AttributeUnitSlice { - orig := []otlpprofiles.AttributeUnit(nil) + orig := []*otlpprofiles.AttributeUnit(nil) state := internal.StateMutable return newAttributeUnitSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es AttributeUnitSlice) Len() int { // ... // Do something with the element // } func (es AttributeUnitSlice) At(i int) AttributeUnit { - return newAttributeUnit(&(*es.orig)[i], es.state) + return newAttributeUnit((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es AttributeUnitSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.AttributeUnit, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.AttributeUnit, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es AttributeUnitSlice) EnsureCapacity(newCap int) { // It returns the newly added AttributeUnit. func (es AttributeUnitSlice) AppendEmpty() AttributeUnit { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.AttributeUnit{}) + *es.orig = append(*es.orig, &otlpprofiles.AttributeUnit{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es AttributeUnitSlice) CopyTo(dest AttributeUnitSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.AttributeUnit, srcLen) + for i := range *es.orig { + newAttributeUnit((*es.orig)[i], es.state).CopyTo(newAttributeUnit((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.AttributeUnit, srcLen) + wrappers := make([]*otlpprofiles.AttributeUnit, srcLen) for i := range *es.orig { - newAttributeUnit(&(*es.orig)[i], es.state).CopyTo(newAttributeUnit(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newAttributeUnit((*es.orig)[i], es.state).CopyTo(newAttributeUnit(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the AttributeUnit elements within AttributeUnitSlice given the +// provided less function so that two instances of AttributeUnitSlice +// can be compared. +func (es AttributeUnitSlice) Sort(less func(a, b AttributeUnit) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_attributeunitslice_test.go b/pdata/pprofile/generated_attributeunitslice_test.go index 0dd3420015a..6fa007bca75 100644 --- a/pdata/pprofile/generated_attributeunitslice_test.go +++ b/pdata/pprofile/generated_attributeunitslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestAttributeUnitSlice(t *testing.T) { es := NewAttributeUnitSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newAttributeUnitSlice(&[]otlpprofiles.AttributeUnit{}, &state) + es = newAttributeUnitSlice(&[]*otlpprofiles.AttributeUnit{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewAttributeUnit() @@ -35,7 +36,7 @@ func TestAttributeUnitSlice(t *testing.T) { func TestAttributeUnitSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newAttributeUnitSlice(&[]otlpprofiles.AttributeUnit{}, &sharedState) + es := newAttributeUnitSlice(&[]*otlpprofiles.AttributeUnit{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestAttributeUnitSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestAttributeUnitSlice_Sort(t *testing.T) { + es := generateTestAttributeUnitSlice() + es.Sort(func(a, b AttributeUnit) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b AttributeUnit) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestAttributeUnitSlice() AttributeUnitSlice { es := NewAttributeUnitSlice() fillTestAttributeUnitSlice(es) @@ -129,9 +146,9 @@ func generateTestAttributeUnitSlice() AttributeUnitSlice { } func fillTestAttributeUnitSlice(es AttributeUnitSlice) { - *es.orig = make([]otlpprofiles.AttributeUnit, 7) + *es.orig = make([]*otlpprofiles.AttributeUnit, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.AttributeUnit{} - fillTestAttributeUnit(newAttributeUnit(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.AttributeUnit{} + fillTestAttributeUnit(newAttributeUnit((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_functionslice.go b/pdata/pprofile/generated_functionslice.go index 171ba345b01..9c295899efd 100644 --- a/pdata/pprofile/generated_functionslice.go +++ b/pdata/pprofile/generated_functionslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewFunctionSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type FunctionSlice struct { - orig *[]otlpprofiles.Function + orig *[]*otlpprofiles.Function state *internal.State } -func newFunctionSlice(orig *[]otlpprofiles.Function, state *internal.State) FunctionSlice { +func newFunctionSlice(orig *[]*otlpprofiles.Function, state *internal.State) FunctionSlice { return FunctionSlice{orig: orig, state: state} } // NewFunctionSlice creates a FunctionSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewFunctionSlice() FunctionSlice { - orig := []otlpprofiles.Function(nil) + orig := []*otlpprofiles.Function(nil) state := internal.StateMutable return newFunctionSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es FunctionSlice) Len() int { // ... // Do something with the element // } func (es FunctionSlice) At(i int) Function { - return newFunction(&(*es.orig)[i], es.state) + return newFunction((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Function, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Function, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { // It returns the newly added Function. func (es FunctionSlice) AppendEmpty() Function { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Function{}) + *es.orig = append(*es.orig, &otlpprofiles.Function{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es FunctionSlice) CopyTo(dest FunctionSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Function, srcLen) + for i := range *es.orig { + newFunction((*es.orig)[i], es.state).CopyTo(newFunction((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Function, srcLen) + wrappers := make([]*otlpprofiles.Function, srcLen) for i := range *es.orig { - newFunction(&(*es.orig)[i], es.state).CopyTo(newFunction(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newFunction((*es.orig)[i], es.state).CopyTo(newFunction(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Function elements within FunctionSlice given the +// provided less function so that two instances of FunctionSlice +// can be compared. +func (es FunctionSlice) Sort(less func(a, b Function) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_functionslice_test.go b/pdata/pprofile/generated_functionslice_test.go index c4311bf52d9..e83a4d9a530 100644 --- a/pdata/pprofile/generated_functionslice_test.go +++ b/pdata/pprofile/generated_functionslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestFunctionSlice(t *testing.T) { es := NewFunctionSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newFunctionSlice(&[]otlpprofiles.Function{}, &state) + es = newFunctionSlice(&[]*otlpprofiles.Function{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewFunction() @@ -35,7 +36,7 @@ func TestFunctionSlice(t *testing.T) { func TestFunctionSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newFunctionSlice(&[]otlpprofiles.Function{}, &sharedState) + es := newFunctionSlice(&[]*otlpprofiles.Function{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestFunctionSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestFunctionSlice_Sort(t *testing.T) { + es := generateTestFunctionSlice() + es.Sort(func(a, b Function) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Function) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestFunctionSlice() FunctionSlice { es := NewFunctionSlice() fillTestFunctionSlice(es) @@ -129,9 +146,9 @@ func generateTestFunctionSlice() FunctionSlice { } func fillTestFunctionSlice(es FunctionSlice) { - *es.orig = make([]otlpprofiles.Function, 7) + *es.orig = make([]*otlpprofiles.Function, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Function{} - fillTestFunction(newFunction(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Function{} + fillTestFunction(newFunction((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_labelslice.go b/pdata/pprofile/generated_labelslice.go index 5f865bfcbae..0296d634da0 100644 --- a/pdata/pprofile/generated_labelslice.go +++ b/pdata/pprofile/generated_labelslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLabelSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LabelSlice struct { - orig *[]otlpprofiles.Label + orig *[]*otlpprofiles.Label state *internal.State } -func newLabelSlice(orig *[]otlpprofiles.Label, state *internal.State) LabelSlice { +func newLabelSlice(orig *[]*otlpprofiles.Label, state *internal.State) LabelSlice { return LabelSlice{orig: orig, state: state} } // NewLabelSlice creates a LabelSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLabelSlice() LabelSlice { - orig := []otlpprofiles.Label(nil) + orig := []*otlpprofiles.Label(nil) state := internal.StateMutable return newLabelSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LabelSlice) Len() int { // ... // Do something with the element // } func (es LabelSlice) At(i int) Label { - return newLabel(&(*es.orig)[i], es.state) + return newLabel((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LabelSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Label, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Label, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LabelSlice) EnsureCapacity(newCap int) { // It returns the newly added Label. func (es LabelSlice) AppendEmpty() Label { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Label{}) + *es.orig = append(*es.orig, &otlpprofiles.Label{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LabelSlice) CopyTo(dest LabelSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Label, srcLen) + for i := range *es.orig { + newLabel((*es.orig)[i], es.state).CopyTo(newLabel((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Label, srcLen) + wrappers := make([]*otlpprofiles.Label, srcLen) for i := range *es.orig { - newLabel(&(*es.orig)[i], es.state).CopyTo(newLabel(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLabel((*es.orig)[i], es.state).CopyTo(newLabel(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Label elements within LabelSlice given the +// provided less function so that two instances of LabelSlice +// can be compared. +func (es LabelSlice) Sort(less func(a, b Label) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_labelslice_test.go b/pdata/pprofile/generated_labelslice_test.go index c399046f92e..4ae3f7a6cbd 100644 --- a/pdata/pprofile/generated_labelslice_test.go +++ b/pdata/pprofile/generated_labelslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLabelSlice(t *testing.T) { es := NewLabelSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLabelSlice(&[]otlpprofiles.Label{}, &state) + es = newLabelSlice(&[]*otlpprofiles.Label{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLabel() @@ -35,7 +36,7 @@ func TestLabelSlice(t *testing.T) { func TestLabelSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLabelSlice(&[]otlpprofiles.Label{}, &sharedState) + es := newLabelSlice(&[]*otlpprofiles.Label{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLabelSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLabelSlice_Sort(t *testing.T) { + es := generateTestLabelSlice() + es.Sort(func(a, b Label) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Label) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLabelSlice() LabelSlice { es := NewLabelSlice() fillTestLabelSlice(es) @@ -129,9 +146,9 @@ func generateTestLabelSlice() LabelSlice { } func fillTestLabelSlice(es LabelSlice) { - *es.orig = make([]otlpprofiles.Label, 7) + *es.orig = make([]*otlpprofiles.Label, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Label{} - fillTestLabel(newLabel(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Label{} + fillTestLabel(newLabel((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_lineslice.go b/pdata/pprofile/generated_lineslice.go index b354560d090..3f8daed79e9 100644 --- a/pdata/pprofile/generated_lineslice.go +++ b/pdata/pprofile/generated_lineslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLineSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LineSlice struct { - orig *[]otlpprofiles.Line + orig *[]*otlpprofiles.Line state *internal.State } -func newLineSlice(orig *[]otlpprofiles.Line, state *internal.State) LineSlice { +func newLineSlice(orig *[]*otlpprofiles.Line, state *internal.State) LineSlice { return LineSlice{orig: orig, state: state} } // NewLineSlice creates a LineSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLineSlice() LineSlice { - orig := []otlpprofiles.Line(nil) + orig := []*otlpprofiles.Line(nil) state := internal.StateMutable return newLineSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LineSlice) Len() int { // ... // Do something with the element // } func (es LineSlice) At(i int) Line { - return newLine(&(*es.orig)[i], es.state) + return newLine((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Line, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Line, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { // It returns the newly added Line. func (es LineSlice) AppendEmpty() Line { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Line{}) + *es.orig = append(*es.orig, &otlpprofiles.Line{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LineSlice) CopyTo(dest LineSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Line, srcLen) + for i := range *es.orig { + newLine((*es.orig)[i], es.state).CopyTo(newLine((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Line, srcLen) + wrappers := make([]*otlpprofiles.Line, srcLen) for i := range *es.orig { - newLine(&(*es.orig)[i], es.state).CopyTo(newLine(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLine((*es.orig)[i], es.state).CopyTo(newLine(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Line elements within LineSlice given the +// provided less function so that two instances of LineSlice +// can be compared. +func (es LineSlice) Sort(less func(a, b Line) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_lineslice_test.go b/pdata/pprofile/generated_lineslice_test.go index 1f5a69ca3f4..fd53c0237a0 100644 --- a/pdata/pprofile/generated_lineslice_test.go +++ b/pdata/pprofile/generated_lineslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLineSlice(t *testing.T) { es := NewLineSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLineSlice(&[]otlpprofiles.Line{}, &state) + es = newLineSlice(&[]*otlpprofiles.Line{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLine() @@ -35,7 +36,7 @@ func TestLineSlice(t *testing.T) { func TestLineSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLineSlice(&[]otlpprofiles.Line{}, &sharedState) + es := newLineSlice(&[]*otlpprofiles.Line{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLineSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLineSlice_Sort(t *testing.T) { + es := generateTestLineSlice() + es.Sort(func(a, b Line) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Line) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLineSlice() LineSlice { es := NewLineSlice() fillTestLineSlice(es) @@ -129,9 +146,9 @@ func generateTestLineSlice() LineSlice { } func fillTestLineSlice(es LineSlice) { - *es.orig = make([]otlpprofiles.Line, 7) + *es.orig = make([]*otlpprofiles.Line, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Line{} - fillTestLine(newLine(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Line{} + fillTestLine(newLine((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_linkslice.go b/pdata/pprofile/generated_linkslice.go index 3ae925ac09c..dca0febad1b 100644 --- a/pdata/pprofile/generated_linkslice.go +++ b/pdata/pprofile/generated_linkslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLinkSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LinkSlice struct { - orig *[]otlpprofiles.Link + orig *[]*otlpprofiles.Link state *internal.State } -func newLinkSlice(orig *[]otlpprofiles.Link, state *internal.State) LinkSlice { +func newLinkSlice(orig *[]*otlpprofiles.Link, state *internal.State) LinkSlice { return LinkSlice{orig: orig, state: state} } // NewLinkSlice creates a LinkSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLinkSlice() LinkSlice { - orig := []otlpprofiles.Link(nil) + orig := []*otlpprofiles.Link(nil) state := internal.StateMutable return newLinkSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LinkSlice) Len() int { // ... // Do something with the element // } func (es LinkSlice) At(i int) Link { - return newLink(&(*es.orig)[i], es.state) + return newLink((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Link, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Link, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { // It returns the newly added Link. func (es LinkSlice) AppendEmpty() Link { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Link{}) + *es.orig = append(*es.orig, &otlpprofiles.Link{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LinkSlice) CopyTo(dest LinkSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Link, srcLen) + for i := range *es.orig { + newLink((*es.orig)[i], es.state).CopyTo(newLink((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Link, srcLen) + wrappers := make([]*otlpprofiles.Link, srcLen) for i := range *es.orig { - newLink(&(*es.orig)[i], es.state).CopyTo(newLink(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLink((*es.orig)[i], es.state).CopyTo(newLink(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Link elements within LinkSlice given the +// provided less function so that two instances of LinkSlice +// can be compared. +func (es LinkSlice) Sort(less func(a, b Link) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_linkslice_test.go b/pdata/pprofile/generated_linkslice_test.go index 5d22fcd69ca..bec39e870c8 100644 --- a/pdata/pprofile/generated_linkslice_test.go +++ b/pdata/pprofile/generated_linkslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLinkSlice(t *testing.T) { es := NewLinkSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLinkSlice(&[]otlpprofiles.Link{}, &state) + es = newLinkSlice(&[]*otlpprofiles.Link{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLink() @@ -35,7 +36,7 @@ func TestLinkSlice(t *testing.T) { func TestLinkSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLinkSlice(&[]otlpprofiles.Link{}, &sharedState) + es := newLinkSlice(&[]*otlpprofiles.Link{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLinkSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLinkSlice_Sort(t *testing.T) { + es := generateTestLinkSlice() + es.Sort(func(a, b Link) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Link) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLinkSlice() LinkSlice { es := NewLinkSlice() fillTestLinkSlice(es) @@ -129,9 +146,9 @@ func generateTestLinkSlice() LinkSlice { } func fillTestLinkSlice(es LinkSlice) { - *es.orig = make([]otlpprofiles.Link, 7) + *es.orig = make([]*otlpprofiles.Link, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Link{} - fillTestLink(newLink(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Link{} + fillTestLink(newLink((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_locationslice.go b/pdata/pprofile/generated_locationslice.go index e5751c4dcb6..4848a46d925 100644 --- a/pdata/pprofile/generated_locationslice.go +++ b/pdata/pprofile/generated_locationslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLocationSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LocationSlice struct { - orig *[]otlpprofiles.Location + orig *[]*otlpprofiles.Location state *internal.State } -func newLocationSlice(orig *[]otlpprofiles.Location, state *internal.State) LocationSlice { +func newLocationSlice(orig *[]*otlpprofiles.Location, state *internal.State) LocationSlice { return LocationSlice{orig: orig, state: state} } // NewLocationSlice creates a LocationSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLocationSlice() LocationSlice { - orig := []otlpprofiles.Location(nil) + orig := []*otlpprofiles.Location(nil) state := internal.StateMutable return newLocationSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LocationSlice) Len() int { // ... // Do something with the element // } func (es LocationSlice) At(i int) Location { - return newLocation(&(*es.orig)[i], es.state) + return newLocation((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Location, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Location, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { // It returns the newly added Location. func (es LocationSlice) AppendEmpty() Location { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Location{}) + *es.orig = append(*es.orig, &otlpprofiles.Location{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LocationSlice) CopyTo(dest LocationSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Location, srcLen) + for i := range *es.orig { + newLocation((*es.orig)[i], es.state).CopyTo(newLocation((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Location, srcLen) + wrappers := make([]*otlpprofiles.Location, srcLen) for i := range *es.orig { - newLocation(&(*es.orig)[i], es.state).CopyTo(newLocation(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLocation((*es.orig)[i], es.state).CopyTo(newLocation(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Location elements within LocationSlice given the +// provided less function so that two instances of LocationSlice +// can be compared. +func (es LocationSlice) Sort(less func(a, b Location) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_locationslice_test.go b/pdata/pprofile/generated_locationslice_test.go index 06d6946279f..e654bb88a1d 100644 --- a/pdata/pprofile/generated_locationslice_test.go +++ b/pdata/pprofile/generated_locationslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLocationSlice(t *testing.T) { es := NewLocationSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLocationSlice(&[]otlpprofiles.Location{}, &state) + es = newLocationSlice(&[]*otlpprofiles.Location{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLocation() @@ -35,7 +36,7 @@ func TestLocationSlice(t *testing.T) { func TestLocationSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLocationSlice(&[]otlpprofiles.Location{}, &sharedState) + es := newLocationSlice(&[]*otlpprofiles.Location{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLocationSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLocationSlice_Sort(t *testing.T) { + es := generateTestLocationSlice() + es.Sort(func(a, b Location) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Location) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLocationSlice() LocationSlice { es := NewLocationSlice() fillTestLocationSlice(es) @@ -129,9 +146,9 @@ func generateTestLocationSlice() LocationSlice { } func fillTestLocationSlice(es LocationSlice) { - *es.orig = make([]otlpprofiles.Location, 7) + *es.orig = make([]*otlpprofiles.Location, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Location{} - fillTestLocation(newLocation(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Location{} + fillTestLocation(newLocation((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_mappingslice.go b/pdata/pprofile/generated_mappingslice.go index cf0f1361483..140d76f4854 100644 --- a/pdata/pprofile/generated_mappingslice.go +++ b/pdata/pprofile/generated_mappingslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewMappingSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type MappingSlice struct { - orig *[]otlpprofiles.Mapping + orig *[]*otlpprofiles.Mapping state *internal.State } -func newMappingSlice(orig *[]otlpprofiles.Mapping, state *internal.State) MappingSlice { +func newMappingSlice(orig *[]*otlpprofiles.Mapping, state *internal.State) MappingSlice { return MappingSlice{orig: orig, state: state} } // NewMappingSlice creates a MappingSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewMappingSlice() MappingSlice { - orig := []otlpprofiles.Mapping(nil) + orig := []*otlpprofiles.Mapping(nil) state := internal.StateMutable return newMappingSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es MappingSlice) Len() int { // ... // Do something with the element // } func (es MappingSlice) At(i int) Mapping { - return newMapping(&(*es.orig)[i], es.state) + return newMapping((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Mapping, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Mapping, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { // It returns the newly added Mapping. func (es MappingSlice) AppendEmpty() Mapping { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Mapping{}) + *es.orig = append(*es.orig, &otlpprofiles.Mapping{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es MappingSlice) CopyTo(dest MappingSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Mapping, srcLen) + for i := range *es.orig { + newMapping((*es.orig)[i], es.state).CopyTo(newMapping((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Mapping, srcLen) + wrappers := make([]*otlpprofiles.Mapping, srcLen) for i := range *es.orig { - newMapping(&(*es.orig)[i], es.state).CopyTo(newMapping(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newMapping((*es.orig)[i], es.state).CopyTo(newMapping(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Mapping elements within MappingSlice given the +// provided less function so that two instances of MappingSlice +// can be compared. +func (es MappingSlice) Sort(less func(a, b Mapping) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_mappingslice_test.go b/pdata/pprofile/generated_mappingslice_test.go index b25cb952ce1..a1c46aa0b9b 100644 --- a/pdata/pprofile/generated_mappingslice_test.go +++ b/pdata/pprofile/generated_mappingslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestMappingSlice(t *testing.T) { es := NewMappingSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newMappingSlice(&[]otlpprofiles.Mapping{}, &state) + es = newMappingSlice(&[]*otlpprofiles.Mapping{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewMapping() @@ -35,7 +36,7 @@ func TestMappingSlice(t *testing.T) { func TestMappingSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newMappingSlice(&[]otlpprofiles.Mapping{}, &sharedState) + es := newMappingSlice(&[]*otlpprofiles.Mapping{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestMappingSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestMappingSlice_Sort(t *testing.T) { + es := generateTestMappingSlice() + es.Sort(func(a, b Mapping) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Mapping) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestMappingSlice() MappingSlice { es := NewMappingSlice() fillTestMappingSlice(es) @@ -129,9 +146,9 @@ func generateTestMappingSlice() MappingSlice { } func fillTestMappingSlice(es MappingSlice) { - *es.orig = make([]otlpprofiles.Mapping, 7) + *es.orig = make([]*otlpprofiles.Mapping, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Mapping{} - fillTestMapping(newMapping(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Mapping{} + fillTestMapping(newMapping((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_sampleslice.go b/pdata/pprofile/generated_sampleslice.go index da2a128cd6f..64065c10757 100644 --- a/pdata/pprofile/generated_sampleslice.go +++ b/pdata/pprofile/generated_sampleslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewSampleSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SampleSlice struct { - orig *[]otlpprofiles.Sample + orig *[]*otlpprofiles.Sample state *internal.State } -func newSampleSlice(orig *[]otlpprofiles.Sample, state *internal.State) SampleSlice { +func newSampleSlice(orig *[]*otlpprofiles.Sample, state *internal.State) SampleSlice { return SampleSlice{orig: orig, state: state} } // NewSampleSlice creates a SampleSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSampleSlice() SampleSlice { - orig := []otlpprofiles.Sample(nil) + orig := []*otlpprofiles.Sample(nil) state := internal.StateMutable return newSampleSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es SampleSlice) Len() int { // ... // Do something with the element // } func (es SampleSlice) At(i int) Sample { - return newSample(&(*es.orig)[i], es.state) + return newSample((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Sample, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Sample, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { // It returns the newly added Sample. func (es SampleSlice) AppendEmpty() Sample { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Sample{}) + *es.orig = append(*es.orig, &otlpprofiles.Sample{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es SampleSlice) CopyTo(dest SampleSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Sample, srcLen) + for i := range *es.orig { + newSample((*es.orig)[i], es.state).CopyTo(newSample((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Sample, srcLen) + wrappers := make([]*otlpprofiles.Sample, srcLen) for i := range *es.orig { - newSample(&(*es.orig)[i], es.state).CopyTo(newSample(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newSample((*es.orig)[i], es.state).CopyTo(newSample(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Sample elements within SampleSlice given the +// provided less function so that two instances of SampleSlice +// can be compared. +func (es SampleSlice) Sort(less func(a, b Sample) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_sampleslice_test.go b/pdata/pprofile/generated_sampleslice_test.go index 7533e51cc45..9c758e0dc02 100644 --- a/pdata/pprofile/generated_sampleslice_test.go +++ b/pdata/pprofile/generated_sampleslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestSampleSlice(t *testing.T) { es := NewSampleSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newSampleSlice(&[]otlpprofiles.Sample{}, &state) + es = newSampleSlice(&[]*otlpprofiles.Sample{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewSample() @@ -35,7 +36,7 @@ func TestSampleSlice(t *testing.T) { func TestSampleSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newSampleSlice(&[]otlpprofiles.Sample{}, &sharedState) + es := newSampleSlice(&[]*otlpprofiles.Sample{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestSampleSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestSampleSlice_Sort(t *testing.T) { + es := generateTestSampleSlice() + es.Sort(func(a, b Sample) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Sample) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestSampleSlice() SampleSlice { es := NewSampleSlice() fillTestSampleSlice(es) @@ -129,9 +146,9 @@ func generateTestSampleSlice() SampleSlice { } func fillTestSampleSlice(es SampleSlice) { - *es.orig = make([]otlpprofiles.Sample, 7) + *es.orig = make([]*otlpprofiles.Sample, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Sample{} - fillTestSample(newSample(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Sample{} + fillTestSample(newSample((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_valuetypeslice.go b/pdata/pprofile/generated_valuetypeslice.go index 4049bbd2e16..dcbe574a3cc 100644 --- a/pdata/pprofile/generated_valuetypeslice.go +++ b/pdata/pprofile/generated_valuetypeslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewValueTypeSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ValueTypeSlice struct { - orig *[]otlpprofiles.ValueType + orig *[]*otlpprofiles.ValueType state *internal.State } -func newValueTypeSlice(orig *[]otlpprofiles.ValueType, state *internal.State) ValueTypeSlice { +func newValueTypeSlice(orig *[]*otlpprofiles.ValueType, state *internal.State) ValueTypeSlice { return ValueTypeSlice{orig: orig, state: state} } // NewValueTypeSlice creates a ValueTypeSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewValueTypeSlice() ValueTypeSlice { - orig := []otlpprofiles.ValueType(nil) + orig := []*otlpprofiles.ValueType(nil) state := internal.StateMutable return newValueTypeSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es ValueTypeSlice) Len() int { // ... // Do something with the element // } func (es ValueTypeSlice) At(i int) ValueType { - return newValueType(&(*es.orig)[i], es.state) + return newValueType((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.ValueType, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.ValueType, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { // It returns the newly added ValueType. func (es ValueTypeSlice) AppendEmpty() ValueType { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.ValueType{}) + *es.orig = append(*es.orig, &otlpprofiles.ValueType{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es ValueTypeSlice) CopyTo(dest ValueTypeSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.ValueType, srcLen) + for i := range *es.orig { + newValueType((*es.orig)[i], es.state).CopyTo(newValueType((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.ValueType, srcLen) + wrappers := make([]*otlpprofiles.ValueType, srcLen) for i := range *es.orig { - newValueType(&(*es.orig)[i], es.state).CopyTo(newValueType(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newValueType((*es.orig)[i], es.state).CopyTo(newValueType(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the ValueType elements within ValueTypeSlice given the +// provided less function so that two instances of ValueTypeSlice +// can be compared. +func (es ValueTypeSlice) Sort(less func(a, b ValueType) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_valuetypeslice_test.go b/pdata/pprofile/generated_valuetypeslice_test.go index ac4ab1d7dab..79b380a8897 100644 --- a/pdata/pprofile/generated_valuetypeslice_test.go +++ b/pdata/pprofile/generated_valuetypeslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestValueTypeSlice(t *testing.T) { es := NewValueTypeSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newValueTypeSlice(&[]otlpprofiles.ValueType{}, &state) + es = newValueTypeSlice(&[]*otlpprofiles.ValueType{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewValueType() @@ -35,7 +36,7 @@ func TestValueTypeSlice(t *testing.T) { func TestValueTypeSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newValueTypeSlice(&[]otlpprofiles.ValueType{}, &sharedState) + es := newValueTypeSlice(&[]*otlpprofiles.ValueType{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestValueTypeSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestValueTypeSlice_Sort(t *testing.T) { + es := generateTestValueTypeSlice() + es.Sort(func(a, b ValueType) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b ValueType) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestValueTypeSlice() ValueTypeSlice { es := NewValueTypeSlice() fillTestValueTypeSlice(es) @@ -129,9 +146,9 @@ func generateTestValueTypeSlice() ValueTypeSlice { } func fillTestValueTypeSlice(es ValueTypeSlice) { - *es.orig = make([]otlpprofiles.ValueType, 7) + *es.orig = make([]*otlpprofiles.ValueType, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.ValueType{} - fillTestValueType(newValueType(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.ValueType{} + fillTestValueType(newValueType((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/profiles_test.go b/pdata/pprofile/profiles_test.go index a03398967c3..1ed16739155 100644 --- a/pdata/pprofile/profiles_test.go +++ b/pdata/pprofile/profiles_test.go @@ -71,7 +71,7 @@ func TestSampleCountWithEmpty(t *testing.T) { Profiles: []*otlpprofile.ProfileContainer{ { Profile: otlpprofile.Profile{ - Sample: []otlpprofile.Sample{ + Sample: []*otlpprofile.Sample{ {}, }, }, diff --git a/proto_patch.sed b/proto_patch.sed index 50cb2f862fa..831f9a6bad2 100644 --- a/proto_patch.sed +++ b/proto_patch.sed @@ -61,32 +61,5 @@ s+bytes profile_id = \(.*\);+bytes profile_id = \1\ (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.ProfileID"\ ];+g -s+repeated ValueType \(.*\);+repeated ValueType \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Sample \(.*\);+repeated Sample \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Mapping \(.*\);+repeated Mapping \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Location \(.*\);+repeated Location \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Label \(.*\);+repeated Label \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Function \(.*\);+repeated Function \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated AttributeUnit \(.*\);+repeated AttributeUnit \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Link link_table \(.*\);+repeated Link link_table \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Line \(.*\);+repeated Line \1\ - [ (gogoproto.nullable) = false ];+g - s+ValueType period_type \(.*\);+ValueType period_type \1\ [ (gogoproto.nullable) = false ];+g