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

Deprecate unused and empty struct processorhelper.ObsReport #11293

Merged
merged 1 commit into from
Sep 28, 2024
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
25 changes: 25 additions & 0 deletions .chloggen/dep-processorhelper.yaml
Original file line number Diff line number Diff line change
@@ -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: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate unused and empty struct processorhelper.ObsReport

# One or more tracking issues or pull requests related to the change
issues: [11293]

# (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: [api]
8 changes: 2 additions & 6 deletions processor/processorhelper/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"context"
"errors"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/processor"
)

Expand Down Expand Up @@ -40,14 +40,10 @@ func NewLogsProcessor(
return nil, errors.New("nil logsFunc")
}

obs, err := newObsReport(ObsReportSettings{
ProcessorID: set.ID,
ProcessorCreateSettings: set,
})
obs, err := newObsReport(set, pipeline.SignalLogs)
if err != nil {
return nil, err
}
obs.otelAttrs = append(obs.otelAttrs, attribute.String("otel.signal", "logs"))

eventOptions := spanAttributes(set.ID)
bs := fromOptions(options)
Expand Down
8 changes: 2 additions & 6 deletions processor/processorhelper/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"context"
"errors"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/processor"
)

Expand Down Expand Up @@ -40,14 +40,10 @@ func NewMetricsProcessor(
return nil, errors.New("nil metricsFunc")
}

obs, err := newObsReport(ObsReportSettings{
ProcessorID: set.ID,
ProcessorCreateSettings: set,
})
obs, err := newObsReport(set, pipeline.SignalMetrics)
if err != nil {
return nil, err
}
obs.otelAttrs = append(obs.otelAttrs, attribute.String("otel.signal", "metrics"))

eventOptions := spanAttributes(set.ID)
bs := fromOptions(options)
Expand Down
32 changes: 18 additions & 14 deletions processor/processorhelper/obsreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"go.opentelemetry.io/otel/metric"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/internal"
"go.opentelemetry.io/collector/processor/processorhelper/internal/metadata"
Expand All @@ -30,37 +31,40 @@
return componentPrefix + configType + internal.MetricNameSep + metric
}

// ObsReport is a helper to add observability to a processor.
type ObsReport struct {
otelAttrs []attribute.KeyValue
telemetryBuilder *metadata.TelemetryBuilder
}
// Deprecated: [v0.111.0] not used.
type ObsReport struct{}

// ObsReportSettings are settings for creating an ObsReport.
// Deprecated: [v0.111.0] not used.
type ObsReportSettings struct {
ProcessorID component.ID
ProcessorCreateSettings processor.Settings
}

// NewObsReport creates a new Processor.
func NewObsReport(cfg ObsReportSettings) (*ObsReport, error) {
return newObsReport(cfg)
// Deprecated: [v0.111.0] not used.
func NewObsReport(_ ObsReportSettings) (*ObsReport, error) {
return &ObsReport{}, nil

Check warning on line 45 in processor/processorhelper/obsreport.go

View check run for this annotation

Codecov / codecov/patch

processor/processorhelper/obsreport.go#L44-L45

Added lines #L44 - L45 were not covered by tests
}

type obsReport struct {
otelAttrs []attribute.KeyValue
telemetryBuilder *metadata.TelemetryBuilder
}

func newObsReport(cfg ObsReportSettings) (*ObsReport, error) {
telemetryBuilder, err := metadata.NewTelemetryBuilder(cfg.ProcessorCreateSettings.TelemetrySettings)
func newObsReport(set processor.Settings, signal pipeline.Signal) (*obsReport, error) {
telemetryBuilder, err := metadata.NewTelemetryBuilder(set.TelemetrySettings)
if err != nil {
return nil, err
}
return &ObsReport{
return &obsReport{
otelAttrs: []attribute.KeyValue{
attribute.String(internal.ProcessorKey, cfg.ProcessorID.String()),
attribute.String(internal.ProcessorKey, set.ID.String()),
attribute.String("otel.signal", signal.String()),
},
telemetryBuilder: telemetryBuilder,
}, nil
}

func (or *ObsReport) recordInOut(ctx context.Context, incoming, outgoing int) {
func (or *obsReport) recordInOut(ctx context.Context, incoming, outgoing int) {
or.telemetryBuilder.ProcessorIncomingItems.Add(ctx, int64(incoming), metric.WithAttributes(or.otelAttrs...))
or.telemetryBuilder.ProcessorOutgoingItems.Add(ctx, int64(outgoing), metric.WithAttributes(or.otelAttrs...))
}
8 changes: 2 additions & 6 deletions processor/processorhelper/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"context"
"errors"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/processor"
)

Expand Down Expand Up @@ -40,14 +40,10 @@ func NewTracesProcessor(
return nil, errors.New("nil tracesFunc")
}

obs, err := newObsReport(ObsReportSettings{
ProcessorID: set.ID,
ProcessorCreateSettings: set,
})
obs, err := newObsReport(set, pipeline.SignalTraces)
if err != nil {
return nil, err
}
obs.otelAttrs = append(obs.otelAttrs, attribute.String("otel.signal", "traces"))

eventOptions := spanAttributes(set.ID)
bs := fromOptions(options)
Expand Down
Loading