Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/collectd] remove opencensus #28657

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/use-meter-collectd.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: breaking

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Stop using opencensus metrics, use the obsrecv format

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

# (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: []
6 changes: 3 additions & 3 deletions receiver/collectdreceiver/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/sanitize"
)
Expand Down Expand Up @@ -57,14 +58,13 @@ func (cdr *collectDRecord) startTimestamp(metricType string) pcommon.Timestamp {
return pcommon.NewTimestampFromTime(time.Unix(0, 0))
}

func (cdr *collectDRecord) appendToMetrics(scopeMetrics pmetric.ScopeMetrics, defaultLabels map[string]string) error {
func (cdr *collectDRecord) appendToMetrics(logger *zap.Logger, scopeMetrics pmetric.ScopeMetrics, defaultLabels map[string]string) error {
// Ignore if record is an event instead of data point
if cdr.isEvent() {
recordEventsReceived()
logger.Debug("ignoring log event", zap.String("message", *cdr.Message))
return nil
}

recordMetricsReceived()
labels := make(map[string]string, len(defaultLabels))
for k, v := range defaultLabels {
labels[k] = v
Expand Down
5 changes: 3 additions & 2 deletions receiver/collectdreceiver/collectd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest"
Expand All @@ -30,7 +31,7 @@ func TestDecodeEvent(t *testing.T) {
require.NoError(t, err)

for _, cdr := range records {
err := cdr.appendToMetrics(scopeMetrics, map[string]string{})
err := cdr.appendToMetrics(zap.NewNop(), scopeMetrics, map[string]string{})
assert.NoError(t, err)
assert.Equal(t, 0, metrics.MetricCount())
}
Expand All @@ -47,7 +48,7 @@ func TestDecodeMetrics(t *testing.T) {
require.NoError(t, err)

for _, cdr := range records {
err = cdr.appendToMetrics(scopeMemtrics, map[string]string{})
err = cdr.appendToMetrics(zap.NewNop(), scopeMemtrics, map[string]string{})
assert.NoError(t, err)
}
assert.Equal(t, 10, metrics.MetricCount())
Expand Down
4 changes: 2 additions & 2 deletions receiver/collectdreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func createDefaultConfig() component.Config {

func createMetricsReceiver(
_ context.Context,
params receiver.CreateSettings,
cs receiver.CreateSettings,
cfg component.Config,
nextConsumer consumer.Metrics,
) (receiver.Metrics, error) {
Expand All @@ -58,5 +58,5 @@ func createMetricsReceiver(
c.Encoding,
)
}
return newCollectdReceiver(params.Logger, c.Endpoint, c.Timeout, c.AttributesPrefix, nextConsumer)
return newCollectdReceiver(cs.Logger, c.Endpoint, c.Timeout, c.AttributesPrefix, nextConsumer, cs)
}
3 changes: 2 additions & 1 deletion receiver/collectdreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.88.0
github.com/stretchr/testify v1.8.4
go.opencensus.io v0.24.0
go.opentelemetry.io/collector/component v0.88.1-0.20231026220224-6405e152a2d9
go.opentelemetry.io/collector/config/confignet v0.88.1-0.20231026220224-6405e152a2d9
go.opentelemetry.io/collector/confmap v0.88.1-0.20231026220224-6405e152a2d9
Expand All @@ -33,6 +32,8 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.88.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0017.0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
Expand Down
19 changes: 17 additions & 2 deletions receiver/collectdreceiver/go.sum

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

84 changes: 0 additions & 84 deletions receiver/collectdreceiver/observability.go

This file was deleted.

Loading