Skip to content

Commit

Permalink
Merge branch 'main' into netflow-receiver-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopes7 authored Dec 20, 2024
2 parents 8d07a6a + e2601fb commit f7b1512
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 405 deletions.
36 changes: 36 additions & 0 deletions .chloggen/deprecate_sapmexporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: sapmexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate SAPM exporter

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36028]

# (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: |
The SAPM exporter is being marked as deprecated. Please use the `otlphttp` exporter with the configuration shown
below. Also update your pipeline configuration for Traces accordingly.
```yaml
exporters:
otlphttp:
traces_endpoint: "${SPLUNK_INGEST_URL}/v2/trace/otlp"
headers:
"X-SF-Token": "${SPLUNK_ACCESS_TOKEN}"
```
# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
17 changes: 15 additions & 2 deletions exporter/sapmexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta]: traces |
| Stability | [deprecated]: traces |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Fsapm%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fsapm) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Fsapm%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fsapm) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dmitryax](https://www.github.com/dmitryax), [@atoulme](https://www.github.com/atoulme) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta
[deprecated]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#deprecated
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

### Deprecated

> The SAPM protocol is based on the Jaeger protocol, which is no longer the preferred approach of the community, with the advent of the OTLP protocol. The Jaeger exporters have been removed from the collector already. Jaeger itself is migrating to use the OTel data format internally.
> As a result, the SAPM exporter is being deprecated in favor of the OTLPHTTP exporter. The following configuration can be used for the OTLPHTTP exporter
```yaml
exporters:
otlphttp:
traces_endpoint: "${SPLUNK_INGEST_URL}/v2/trace/otlp"
headers:
"X-SF-Token": "${SPLUNK_ACCESS_TOKEN}"
```
The SAPM exporter builds on the Jaeger proto and adds additional batching on top. This allows
the collector to export traces from multiples nodes/services in a single batch. The SAPM proto
and some useful related utilities can be found [here](https://github.com/signalfx/sapm-proto/).
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exporter/sapmexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: sapm
status:
class: exporter
stability:
beta: [traces]
deprecated: [traces]
distributions: [contrib]
codeowners:
active: [dmitryax, atoulme]
Expand Down
217 changes: 112 additions & 105 deletions receiver/hostmetricsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/otelcol/otelcoltest"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset"
Expand All @@ -31,127 +31,134 @@ import (
)

func TestLoadConfig(t *testing.T) {
factories, err := otelcoltest.NopFactories()
require.NoError(t, err)

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
t.Parallel()

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
require.NotNil(t, cfg)

assert.Len(t, cfg.Receivers, 2)

r0 := cfg.Receivers[component.NewID(metadata.Type)]
defaultConfigCPUScraper := factory.CreateDefaultConfig()
defaultConfigCPUScraper.(*Config).Scrapers = map[string]internal.Config{
cpuscraper.TypeStr: func() internal.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
}

assert.Equal(t, defaultConfigCPUScraper, r0)

r1 := cfg.Receivers[component.NewIDWithName(metadata.Type, "customname")].(*Config)
expectedConfig := &Config{
MetadataCollectionInterval: 5 * time.Minute,
ControllerConfig: scraperhelper.ControllerConfig{
CollectionInterval: 30 * time.Second,
InitialDelay: time.Second,
},
Scrapers: map[string]internal.Config{
cpuscraper.TypeStr: func() internal.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
diskscraper.TypeStr: func() internal.Config {
cfg := (&diskscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
loadscraper.TypeStr: (func() internal.Config {
cfg := (&loadscraper.Factory{}).CreateDefaultConfig()
cfg.(*loadscraper.Config).CPUAverage = true
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
filesystemscraper.TypeStr: func() internal.Config {
cfg := (&filesystemscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
memoryscraper.TypeStr: func() internal.Config {
cfg := (&memoryscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
networkscraper.TypeStr: (func() internal.Config {
cfg := (&networkscraper.Factory{}).CreateDefaultConfig()
cfg.(*networkscraper.Config).Include = networkscraper.MatchConfig{
Interfaces: []string{"test1"},
Config: filterset.Config{MatchType: "strict"},
tests := []struct {
id component.ID
expected component.Config
}{
{
id: component.NewID(metadata.Type),
expected: func() component.Config {
cfg := createDefaultConfig().(*Config)
cfg.Scrapers = map[string]internal.Config{
cpuscraper.TypeStr: func() internal.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
}
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
processesscraper.TypeStr: func() internal.Config {
cfg := (&processesscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
pagingscraper.TypeStr: func() internal.Config {
cfg := (&pagingscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
processscraper.TypeStr: (func() internal.Config {
cfg := (&processscraper.Factory{}).CreateDefaultConfig()
cfg.(*processscraper.Config).Include = processscraper.MatchConfig{
Names: []string{"test2", "test3"},
Config: filterset.Config{MatchType: "regexp"},
}
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
systemscraper.TypeStr: (func() internal.Config {
cfg := (&systemscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
},
{
id: component.NewIDWithName(metadata.Type, "customname"),
expected: &Config{
MetadataCollectionInterval: 5 * time.Minute,
ControllerConfig: scraperhelper.ControllerConfig{
CollectionInterval: 30 * time.Second,
InitialDelay: time.Second,
},
Scrapers: map[string]internal.Config{
cpuscraper.TypeStr: func() internal.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
diskscraper.TypeStr: func() internal.Config {
cfg := (&diskscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
loadscraper.TypeStr: (func() internal.Config {
cfg := (&loadscraper.Factory{}).CreateDefaultConfig()
cfg.(*loadscraper.Config).CPUAverage = true
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
filesystemscraper.TypeStr: func() internal.Config {
cfg := (&filesystemscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
memoryscraper.TypeStr: func() internal.Config {
cfg := (&memoryscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
networkscraper.TypeStr: (func() internal.Config {
cfg := (&networkscraper.Factory{}).CreateDefaultConfig()
cfg.(*networkscraper.Config).Include = networkscraper.MatchConfig{
Interfaces: []string{"test1"},
Config: filterset.Config{MatchType: "strict"},
}
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
processesscraper.TypeStr: func() internal.Config {
cfg := (&processesscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
pagingscraper.TypeStr: func() internal.Config {
cfg := (&pagingscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
}(),
processscraper.TypeStr: (func() internal.Config {
cfg := (&processscraper.Factory{}).CreateDefaultConfig()
cfg.(*processscraper.Config).Include = processscraper.MatchConfig{
Names: []string{"test2", "test3"},
Config: filterset.Config{MatchType: "regexp"},
}
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
systemscraper.TypeStr: (func() internal.Config {
cfg := (&systemscraper.Factory{}).CreateDefaultConfig()
cfg.SetEnvMap(common.EnvMap{})
return cfg
})(),
},
},
},
}

assert.Equal(t, expectedConfig, r1)
for _, tt := range tests {
t.Run(tt.id.String(), func(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
})
}
}

func TestLoadInvalidConfig_NoScrapers(t *testing.T) {
factories, err := otelcoltest.NopFactories()
require.NoError(t, err)

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-noscrapers.yaml"), factories)
cfg := factory.CreateDefaultConfig()

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config-noscrapers.yaml"))
require.NoError(t, err)

require.ErrorContains(t, err, "must specify at least one scraper when using hostmetrics receiver")
require.NoError(t, cm.Unmarshal(cfg))
require.ErrorContains(t, component.ValidateConfig(cfg), "must specify at least one scraper when using hostmetrics receiver")
}

func TestLoadInvalidConfig_InvalidScraperKey(t *testing.T) {
factories, err := otelcoltest.NopFactories()
require.NoError(t, err)

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-invalidscraperkey.yaml"), factories)
cfg := factory.CreateDefaultConfig()

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config-invalidscraperkey.yaml"))
require.NoError(t, err)

require.ErrorContains(t, err, "error reading configuration for \"hostmetrics\": invalid scraper key: invalidscraperkey")
require.ErrorContains(t, cm.Unmarshal(cfg), "invalid scraper key: invalidscraperkey")
}
Loading

0 comments on commit f7b1512

Please sign in to comment.