Skip to content

Commit

Permalink
Merge branch 'main' into balance-metrics-by-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
SHaaD94 authored Mar 31, 2024
2 parents 7802c17 + e867aa8 commit fb81f66
Show file tree
Hide file tree
Showing 34 changed files with 204 additions and 82 deletions.
27 changes: 27 additions & 0 deletions .chloggen/resdetproc_check_enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Only attempt to detect Kubernetes node resource attributes when they're enabled.

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

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exporter/azuredataexplorerexporter/ @open-telemetry/collect
exporter/azuremonitorexporter/ @open-telemetry/collector-contrib-approvers @pcwiese
exporter/carbonexporter/ @open-telemetry/collector-contrib-approvers @aboguszewski-sumo
exporter/cassandraexporter/ @open-telemetry/collector-contrib-approvers @atoulme @emreyalvac
exporter/clickhouseexporter/ @open-telemetry/collector-contrib-approvers @hanjm @dmitryax @Frapschen
exporter/clickhouseexporter/ @open-telemetry/collector-contrib-approvers @hanjm @dmitryax @Frapschen @SpencerTorres
exporter/coralogixexporter/ @open-telemetry/collector-contrib-approvers @povilasv @matej-g
exporter/datadogexporter/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @liustanley @songy23 @mackjmr
exporter/datasetexporter/ @open-telemetry/collector-contrib-approvers @atoulme @martin-majlis-s1 @zdaratom-s1 @tomaz-s1
Expand Down
2 changes: 1 addition & 1 deletion exporter/clickhouseexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| Stability | [alpha]: traces, metrics, logs |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Fclickhouse%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fclickhouse) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Fclickhouse%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fclickhouse) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@hanjm](https://www.github.com/hanjm), [@dmitryax](https://www.github.com/dmitryax), [@Frapschen](https://www.github.com/Frapschen) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@hanjm](https://www.github.com/hanjm), [@dmitryax](https://www.github.com/dmitryax), [@Frapschen](https://www.github.com/Frapschen), [@SpencerTorres](https://www.github.com/SpencerTorres) |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
Expand Down
2 changes: 1 addition & 1 deletion exporter/clickhouseexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
alpha: [traces, metrics, logs]
distributions: [contrib]
codeowners:
active: [hanjm, dmitryax, Frapschen]
active: [hanjm, dmitryax, Frapschen, SpencerTorres]

# TODO: Update the exporter to pass the tests
tests:
Expand Down
3 changes: 1 addition & 2 deletions exporter/lokiexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
| Status | |
| ------------- |-----------|
| Stability | [beta]: logs |
| Distributions | [contrib], [observiq] |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Floki%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Floki) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Floki%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Floki) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@gramidt](https://www.github.com/gramidt), [@gouthamve](https://www.github.com/gouthamve), [@jpkrohling](https://www.github.com/jpkrohling), [@mar4uk](https://www.github.com/mar4uk) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[observiq]: https://github.com/observIQ/observiq-otel-collector
<!-- end autogenerated section -->
Exports data via HTTP to [Loki](https://grafana.com/docs/loki/latest/).

Expand Down
1 change: 0 additions & 1 deletion exporter/lokiexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ status:
beta: [logs]
distributions:
- contrib
- observiq
codeowners:
active: [gramidt, gouthamve, jpkrohling, mar4uk]

Expand Down
3 changes: 1 addition & 2 deletions extension/sumologicextension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
| Status | |
| ------------- |-----------|
| Stability | [alpha] |
| Distributions | [sumo] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fsumologic%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fsumologic) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fsumologic%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fsumologic) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@astencel-sumo](https://www.github.com/astencel-sumo), [@sumo-drosiek](https://www.github.com/sumo-drosiek), [@swiatekm-sumo](https://www.github.com/swiatekm-sumo) |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[sumo]: https://github.com/SumoLogic/sumologic-otel-collector
<!-- end autogenerated section -->

This extension is to be used in conjunction with
Expand Down
2 changes: 1 addition & 1 deletion extension/sumologicextension/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ status:
class: extension
stability:
alpha: [extension]
distributions: [sumo]
distributions: []
codeowners:
active: [astencel-sumo, sumo-drosiek, swiatekm-sumo]

Expand Down
4 changes: 3 additions & 1 deletion internal/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ func TestEventLoopHandlesError(t *testing.T) {
assert.NotNil(t, cli)
assert.NoError(t, err)

go cli.ContainerEventLoop(context.Background())
ctx, cancel := context.WithCancel(context.Background())
go cli.ContainerEventLoop(ctx)
defer cancel()

assert.Eventually(t, func() bool {
for _, l := range logs.All() {
Expand Down
1 change: 1 addition & 0 deletions internal/docker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/docker/docker v25.0.5+incompatible
github.com/gobwas/glob v0.2.3
github.com/stretchr/testify v1.9.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
)

Expand Down
14 changes: 14 additions & 0 deletions internal/docker/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package docker

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
go.opentelemetry.io/build-tools/issuegenerator v0.13.0
go.opentelemetry.io/build-tools/multimod v0.13.0
go.opentelemetry.io/collector/cmd/builder v0.97.1-0.20240327181407-1038b67c85a0
go.opentelemetry.io/collector/cmd/mdatagen v0.97.1-0.20240327181407-1038b67c85a0
go.opentelemetry.io/collector/cmd/mdatagen v0.97.1-0.20240330011903-12cead60ac0d
go.uber.org/goleak v1.3.0
golang.org/x/tools v0.19.0
golang.org/x/vuln v1.0.4
Expand Down
4 changes: 2 additions & 2 deletions internal/tools/go.sum

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

22 changes: 14 additions & 8 deletions processor/resourcedetectionprocessor/internal/k8snode/k8snode.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var _ internal.Detector = (*detector)(nil)
type detector struct {
provider k8snode.Provider
logger *zap.Logger
ra *metadata.ResourceAttributesConfig
rb *metadata.ResourceBuilder
}

Expand All @@ -43,22 +44,27 @@ func NewDetector(set processor.CreateSettings, dcfg internal.DetectorConfig) (in
return &detector{
provider: k8snodeProvider,
logger: set.Logger,
ra: &cfg.ResourceAttributes,
rb: metadata.NewResourceBuilder(cfg.ResourceAttributes),
}, nil
}

func (d *detector) Detect(ctx context.Context) (resource pcommon.Resource, schemaURL string, err error) {
nodeUID, err := d.provider.NodeUID(ctx)
if err != nil {
return pcommon.NewResource(), "", fmt.Errorf("failed getting k8s node UID: %w", err)
if d.ra.K8sNodeUID.Enabled {
nodeUID, err := d.provider.NodeUID(ctx)
if err != nil {
return pcommon.NewResource(), "", fmt.Errorf("failed getting k8s node UID: %w", err)
}
d.rb.SetK8sNodeUID(nodeUID)
}
d.rb.SetK8sNodeUID(nodeUID)

nodeName, err := d.provider.NodeName(ctx)
if err != nil {
return pcommon.NewResource(), "", fmt.Errorf("failed getting k8s node name: %w", err)
if d.ra.K8sNodeName.Enabled {
nodeName, err := d.provider.NodeName(ctx)
if err != nil {
return pcommon.NewResource(), "", fmt.Errorf("failed getting k8s node name: %w", err)
}
d.rb.SetK8sNodeName(nodeName)
}
d.rb.SetK8sNodeName(nodeName)

return d.rb.Emit(), conventions.SchemaURL, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,27 @@ func TestDetect(t *testing.T) {

assert.Equal(t, expected, res.Attributes().AsRaw())
}

func TestDetectDisabledResourceAttributes(t *testing.T) {
md := &mockMetadata{}
cfg := CreateDefaultConfig()
cfg.ResourceAttributes.K8sNodeUID.Enabled = false
cfg.ResourceAttributes.K8sNodeName.Enabled = false
// set k8s cluster env variables and auth type to create a dummy API client
cfg.APIConfig.AuthType = k8sconfig.AuthTypeNone
t.Setenv("KUBERNETES_SERVICE_HOST", "127.0.0.1")
t.Setenv("KUBERNETES_SERVICE_PORT", "6443")
t.Setenv("K8S_NODE_NAME", "mainNode")

k8sDetector, err := NewDetector(processortest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
k8sDetector.(*detector).provider = md
res, schemaURL, err := k8sDetector.Detect(context.Background())
require.NoError(t, err)
assert.Equal(t, conventions.SchemaURL, schemaURL)
md.AssertExpectations(t)

expected := map[string]any{}

assert.Equal(t, expected, res.Attributes().AsRaw())
}
3 changes: 1 addition & 2 deletions processor/schemaprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
| Status | |
| ------------- |-----------|
| Stability | [development]: traces, metrics, logs |
| Distributions | [sumo] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fschema%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fschema) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fschema%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fschema) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@MovieStoreGuy](https://www.github.com/MovieStoreGuy) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[sumo]: https://github.com/SumoLogic/sumologic-otel-collector
<!-- end autogenerated section -->

The _Schema Processor_ is used to convert existing telemetry data or signals to a version of the semantic convention defined as part of the configuration.
Expand Down
2 changes: 1 addition & 1 deletion processor/schemaprocessor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ status:
class: processor
stability:
development: [traces, metrics, logs]
distributions: [sumo]
distributions: []
codeowners:
active: [MovieStoreGuy]

Expand Down
1 change: 1 addition & 0 deletions receiver/activedirectorydsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| Status | |
| ------------- |-----------|
| Stability | [beta]: metrics |
| Unsupported Platforms | darwin, linux |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Factivedirectoryds%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Factivedirectoryds) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Factivedirectoryds%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Factivedirectoryds) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@djaglowski](https://www.github.com/djaglowski), [@BinaryFissionGames](https://www.github.com/BinaryFissionGames) \| Seeking more code owners! |
Expand Down
1 change: 1 addition & 0 deletions receiver/dockerstatsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| Status | |
| ------------- |-----------|
| Stability | [alpha]: metrics |
| Unsupported Platforms | darwin, windows |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fdockerstats%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fdockerstats) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fdockerstats%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fdockerstats) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@rmfitzpatrick](https://www.github.com/rmfitzpatrick), [@jamesmoessis](https://www.github.com/jamesmoessis) |
Expand Down
3 changes: 1 addition & 2 deletions receiver/gitproviderreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
| Status | |
| ------------- |-----------|
| Stability | [development]: metrics |
| Distributions | [liatrio] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fgitprovider%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fgitprovider) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fgitprovider%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fgitprovider) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@adrielp](https://www.github.com/adrielp), [@astencel-sumo](https://www.github.com/astencel-sumo) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[liatrio]: https://github.com/liatrio/liatrio-otel-collector
<!-- end autogenerated section -->

The Git Provider receiver scrapes data from Git vendors.
Expand Down
2 changes: 1 addition & 1 deletion receiver/gitproviderreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
class: receiver
stability:
development: [metrics]
distributions: [liatrio]
distributions: []
codeowners:
active: [adrielp, astencel-sumo]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ package loadscraper // import "github.com/open-telemetry/opentelemetry-collector

import (
"context"
"time"

"github.com/shirou/gopsutil/v3/load"
"go.uber.org/zap"
)

// no sampling performed on non windows environments, nothing to do
func setSamplingFrequency(_ time.Duration) {}

// unix based systems sample & compute load averages in the kernel, so nothing to do here
func startSampling(_ context.Context, _ *zap.Logger) error {
return nil
Expand Down
Loading

0 comments on commit fb81f66

Please sign in to comment.