Skip to content

Commit

Permalink
Merge pull request #653 from solarwinds/mergeRelease340ToMain
Browse files Browse the repository at this point in the history
Merge `release/3.4.0` to `main`
  • Loading branch information
pstranak-sw authored Jul 1, 2024
2 parents e061ade + 43bc226 commit 54a0ebd
Show file tree
Hide file tree
Showing 33 changed files with 1,306 additions and 1,707 deletions.
2 changes: 1 addition & 1 deletion build/docker/structure-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ commandTests:
- name: "swi-otelcol is working in the image"
command: "/swi-otelcol"
args: ["-v"]
expectedOutput: ["swi-k8s-opentelemetry-collector version 0.11.0"]
expectedOutput: ["swi-k8s-opentelemetry-collector version 0.11.1"]
25 changes: 25 additions & 0 deletions deploy/helm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [3.4.0] - 2024-06-28

### Changed

- Upgraded collector image to `0.10.1` which brings following changes:
- See Release notes for [0.10.1](https://github.com/solarwinds/swi-k8s-opentelemetry-collector/releases/tag/0.10.1).
- Bumped 3rd party dependencies and Docker images.
- Upgraded OTEL Collector to v0.103.0.
- Upgraded SWO Agent image to `v2.8.85`

### Fixed

- Only metric `k8s.cluster.version` metric is supposed to have attribute `sw.k8s.cluster.version`

## [3.4.0-alpha.3] - 2024-06-27

### Changed

- Reverted changes from 3.4.0-alpha.2. They are available in the 4.x branch.
- Upgraded collector image to `0.10.1` which brings following changes:
- See Release notes for [0.10.1](https://github.com/solarwinds/swi-k8s-opentelemetry-collector/releases/tag/0.10.1).
- Bumped 3rd party dependencies and Docker images.
- Upgraded OTEL Collector to v0.103.0.
- Upgraded SWO Agent image to `v2.8.85`

## [4.0.0-alpha.2] - 2024-05-30

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: swo-k8s-collector
version: 4.0.0-alpha.2
appVersion: "0.10.0"
appVersion: "0.10.1"
description: SolarWinds Kubernetes Integration
keywords:
- monitoring
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/tests/swo-agent-statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tests:
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: solarwinds/swo-agent:v2.6.28
value: solarwinds/swo-agent:v2.8.85
- it: Image should be correct when overriden tag
template: swo-agent-statefulset.yaml
set:
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ swoagent:
enabled: false
image:
repository: solarwinds/swo-agent
tag: "v2.6.28"
tag: "v2.8.85"
pullPolicy: IfNotPresent
resources:
limits:
Expand Down
248 changes: 127 additions & 121 deletions src/cmd/go.mod

Large diffs are not rendered by default.

543 changes: 267 additions & 276 deletions src/cmd/go.sum

Large diffs are not rendered by default.

32 changes: 29 additions & 3 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,49 @@ import (
"log"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/converter/expandconverter"
"go.opentelemetry.io/collector/confmap/provider/envprovider"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"go.opentelemetry.io/collector/confmap/provider/httpprovider"
"go.opentelemetry.io/collector/confmap/provider/httpsprovider"
"go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/otelcol"
)

func main() {
info := component.BuildInfo{
Command: "swi-k8s-opentelemetry-collector",
Description: "SolarWinds distribution for OpenTelemetry",
Version: "0.11.0",
Version: "0.11.1",
}

if err := run(otelcol.CollectorSettings{BuildInfo: info, Factories: components}); err != nil {
set := otelcol.CollectorSettings{
BuildInfo: info,
Factories: components,
ConfigProviderSettings: otelcol.ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
ProviderFactories: []confmap.ProviderFactory{
envprovider.NewFactory(),
fileprovider.NewFactory(),
httpprovider.NewFactory(),
httpsprovider.NewFactory(),
yamlprovider.NewFactory(),
},
ConverterFactories: []confmap.ConverterFactory{
expandconverter.NewFactory(),
},
},
},
}

if err := run(set); err != nil {
log.Fatal(err)
}
}

func runInteractive(params otelcol.CollectorSettings) error {
cmd := otelcol.NewCommand(params)
cmd := otelcol.NewCommandMustSetProvider(params)
if err := cmd.Execute(); err != nil {
log.Fatalf("collector server run finished with error: %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion src/cmd/main_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

//go:build !windows
// +build !windows

package main

Expand Down
39 changes: 10 additions & 29 deletions src/cmd/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,28 @@
// limitations under the License.

//go:build windows
// +build windows

package main

import (
"errors"
"fmt"
"os"

"go.opentelemetry.io/collector/otelcol"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
)

func run(params otelcol.CollectorSettings) error {
if useInteractiveMode, err := checkUseInteractiveMode(); err != nil {
return err
} else if useInteractiveMode {
return runInteractive(params)
} else {
return runService(params)
}
}

func checkUseInteractiveMode() (bool, error) {
// If environment variable NO_WINDOWS_SERVICE is set with any value other
// than 0, use interactive mode instead of running as a service. This should
// be set in case running as a service is not possible or desired even
// though the current session is not detected to be interactive
if value, present := os.LookupEnv("NO_WINDOWS_SERVICE"); present && value != "0" {
return true, nil
}

isInteractiveSession, err := svc.IsAnInteractiveSession()
if err != nil {
return false, fmt.Errorf("failed to determine if we are running in an interactive session: %w", err)
}
return isInteractiveSession, nil
}

func runService(params otelcol.CollectorSettings) error {
// do not need to supply service name when startup is invoked through Service Control Manager directly
// No need to supply service name when startup is invoked through
// the Service Control Manager directly.
if err := svc.Run("", otelcol.NewSvcHandler(params)); err != nil {
if errors.Is(err, windows.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
// Per https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatchera#return-value
// this means that the process is not running as a service, so run interactively.
return runInteractive(params)
}

return fmt.Errorf("failed to start collector server: %w", err)
}

Expand Down
7 changes: 2 additions & 5 deletions src/processor/k8sattributesprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,5 @@ as tags.

## Timestamp Format

By default, the `k8s.pod.start_time` uses [Time.String()](https://pkg.go.dev/time#Time.String) to format the
timestamp value.

The `k8sattr.rfc3339` feature gate can be enabled to format the `k8s.pod.start_time` timestamp value with an RFC3339
compliant timestamp. See [Time.MarshalText()](https://pkg.go.dev/time#Time.MarshalText) for more information.
By default, the `k8s.pod.start_time` uses [Time.MarshalText()](https://pkg.go.dev/time#Time.MarshalText) to format the
timestamp value as an RFC3339 compliant timestamp.
4 changes: 2 additions & 2 deletions src/processor/k8sattributesprocessor/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package k8sattributesprocessor

import (
"go.uber.org/zap"
"go.opentelemetry.io/collector/component"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes/fake"
Expand Down Expand Up @@ -49,7 +49,7 @@ func selectors() (labels.Selector, fields.Selector) {

// newFakeClient instantiates a new FakeClient object and satisfies the ClientProvider type
func newFakeClient(
_ *zap.Logger,
_ component.TelemetrySettings,
apiCfg k8sconfig.APIConfig,
rules kube.ExtractionRules,
filters kube.Filters,
Expand Down
2 changes: 1 addition & 1 deletion src/processor/k8sattributesprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func TestLoadConfig(t *testing.T) {

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

if tt.expected == nil {
err = component.ValidateConfig(cfg)
Expand Down
14 changes: 7 additions & 7 deletions src/processor/k8sattributesprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func createDefaultConfig() component.Config {

func createTracesProcessor(
ctx context.Context,
params processor.CreateSettings,
params processor.Settings,
cfg component.Config,
next consumer.Traces,
) (processor.Traces, error) {
Expand All @@ -66,7 +66,7 @@ func createTracesProcessor(

func createLogsProcessor(
ctx context.Context,
params processor.CreateSettings,
params processor.Settings,
cfg component.Config,
nextLogsConsumer consumer.Logs,
) (processor.Logs, error) {
Expand All @@ -75,7 +75,7 @@ func createLogsProcessor(

func createMetricsProcessor(
ctx context.Context,
params processor.CreateSettings,
params processor.Settings,
cfg component.Config,
nextMetricsConsumer consumer.Metrics,
) (processor.Metrics, error) {
Expand All @@ -84,7 +84,7 @@ func createMetricsProcessor(

func createTracesProcessorWithOptions(
ctx context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
next consumer.Traces,
options ...option,
Expand All @@ -104,7 +104,7 @@ func createTracesProcessorWithOptions(

func createMetricsProcessorWithOptions(
ctx context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
nextMetricsConsumer consumer.Metrics,
options ...option,
Expand All @@ -124,7 +124,7 @@ func createMetricsProcessorWithOptions(

func createLogsProcessorWithOptions(
ctx context.Context,
set processor.CreateSettings,
set processor.Settings,
cfg component.Config,
nextLogsConsumer consumer.Logs,
options ...option,
Expand All @@ -143,7 +143,7 @@ func createLogsProcessorWithOptions(
}

func createKubernetesProcessor(
params processor.CreateSettings,
params processor.Settings,
cfg component.Config,
options ...option,
) *kubernetesprocessor {
Expand Down
2 changes: 1 addition & 1 deletion src/processor/k8sattributesprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestCreateProcessor(t *testing.T) {
kubeClientProvider = newFakeClient

cfg := factory.CreateDefaultConfig()
params := processortest.NewNopCreateSettings()
params := processortest.NewNopSettings()

tp, err := factory.CreateTracesProcessor(context.Background(), params, cfg, consumertest.NewNop())
assert.NotNil(t, tp)
Expand Down

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

Loading

0 comments on commit 54a0ebd

Please sign in to comment.