Skip to content

Commit c469394

Browse files
authored
[exporterhelper] delete deprecated exporterhelper.ObsReport (#10779)
#### Description Delete deprecated `exporterhelper.ObsReport` and `exporterhelper.NewObsReport` #### Link to tracking issue Relates to #10592
1 parent 3396d0b commit c469394

File tree

12 files changed

+113
-113
lines changed

12 files changed

+113
-113
lines changed

.chloggen/obsexporter.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: exporterhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Delete deprecated `exporterhelper.ObsReport` and `exporterhelper.NewObsReport`
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10779, 10592]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

exporter/exporterhelper/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (b *baseRequestSender) setNextSender(nextSender requestSender) {
4141
b.nextSender = nextSender
4242
}
4343

44-
type obsrepSenderFactory func(obsrep *ObsReport) requestSender
44+
type obsrepSenderFactory func(obsrep *obsReport) requestSender
4545

4646
// Option apply changes to baseExporter.
4747
type Option func(*baseExporter) error
@@ -232,7 +232,7 @@ type baseExporter struct {
232232
unmarshaler exporterqueue.Unmarshaler[Request]
233233

234234
set exporter.Settings
235-
obsrep *ObsReport
235+
obsrep *obsReport
236236

237237
// Message for the user to be added with an export failure message.
238238
exportFailureMessage string
@@ -250,7 +250,7 @@ type baseExporter struct {
250250
}
251251

252252
func newBaseExporter(set exporter.Settings, signal component.DataType, osf obsrepSenderFactory, options ...Option) (*baseExporter, error) {
253-
obsReport, err := NewObsReport(ObsReportSettings{ExporterID: set.ID, ExporterCreateSettings: set, DataType: signal})
253+
obsReport, err := newObsReport(obsReportSettings{exporterID: set.ID, exporterCreateSettings: set, dataType: signal})
254254
if err != nil {
255255
return nil, err
256256
}

exporter/exporterhelper/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
}()
3434
)
3535

36-
func newNoopObsrepSender(*ObsReport) requestSender {
36+
func newNoopObsrepSender(*obsReport) requestSender {
3737
return &baseRequestSender{}
3838
}
3939

exporter/exporterhelper/logs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ func NewLogsRequestExporter(
146146

147147
type logsExporterWithObservability struct {
148148
baseRequestSender
149-
obsrep *ObsReport
149+
obsrep *obsReport
150150
}
151151

152-
func newLogsExporterWithObservability(obsrep *ObsReport) requestSender {
152+
func newLogsExporterWithObservability(obsrep *obsReport) requestSender {
153153
return &logsExporterWithObservability{obsrep: obsrep}
154154
}
155155

156156
func (lewo *logsExporterWithObservability) send(ctx context.Context, req Request) error {
157-
c := lewo.obsrep.StartLogsOp(ctx)
157+
c := lewo.obsrep.startLogsOp(ctx)
158158
numLogRecords := req.ItemsCount()
159159
err := lewo.nextSender.send(c, req)
160-
lewo.obsrep.EndLogsOp(c, numLogRecords, err)
160+
lewo.obsrep.endLogsOp(c, numLogRecords, err)
161161
return err
162162
}

exporter/exporterhelper/metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ func NewMetricsRequestExporter(
146146

147147
type metricsSenderWithObservability struct {
148148
baseRequestSender
149-
obsrep *ObsReport
149+
obsrep *obsReport
150150
}
151151

152-
func newMetricsSenderWithObservability(obsrep *ObsReport) requestSender {
152+
func newMetricsSenderWithObservability(obsrep *obsReport) requestSender {
153153
return &metricsSenderWithObservability{obsrep: obsrep}
154154
}
155155

156156
func (mewo *metricsSenderWithObservability) send(ctx context.Context, req Request) error {
157-
c := mewo.obsrep.StartMetricsOp(ctx)
157+
c := mewo.obsrep.startMetricsOp(ctx)
158158
numMetricDataPoints := req.ItemsCount()
159159
err := mewo.nextSender.send(c, req)
160-
mewo.obsrep.EndMetricsOp(c, numMetricDataPoints, err)
160+
mewo.obsrep.endMetricsOp(c, numMetricDataPoints, err)
161161
return err
162162
}

exporter/exporterhelper/obsexporter.go

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ import (
1818
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
1919
)
2020

21-
// ObsReport is a helper to add observability to an exporter.
22-
//
23-
// Deprecated: [v0.105.0] Not expected to be used directly.
24-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
25-
type ObsReport struct {
21+
// obsReport is a helper to add observability to an exporter.
22+
type obsReport struct {
2623
level configtelemetry.Level
2724
spanNamePrefix string
2825
tracer trace.Tracer
@@ -32,112 +29,90 @@ type ObsReport struct {
3229
telemetryBuilder *metadata.TelemetryBuilder
3330
}
3431

35-
// ObsReportSettings are settings for creating an ObsReport.
36-
//
37-
// Deprecated: [v0.105.0] Not expected to be used directly.
38-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
39-
type ObsReportSettings struct {
40-
ExporterID component.ID
41-
ExporterCreateSettings exporter.Settings
42-
DataType component.DataType
32+
// obsReportSettings are settings for creating an obsReport.
33+
type obsReportSettings struct {
34+
exporterID component.ID
35+
exporterCreateSettings exporter.Settings
36+
dataType component.DataType
4337
}
4438

45-
// NewObsReport creates a new Exporter.
46-
//
47-
// Deprecated: [v0.105.0] Not expected to be used directly.
48-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
49-
func NewObsReport(cfg ObsReportSettings) (*ObsReport, error) {
39+
// newObsReport creates a new Exporter.
40+
func newObsReport(cfg obsReportSettings) (*obsReport, error) {
5041
return newExporter(cfg)
5142
}
5243

53-
func newExporter(cfg ObsReportSettings) (*ObsReport, error) {
54-
telemetryBuilder, err := metadata.NewTelemetryBuilder(cfg.ExporterCreateSettings.TelemetrySettings)
44+
func newExporter(cfg obsReportSettings) (*obsReport, error) {
45+
telemetryBuilder, err := metadata.NewTelemetryBuilder(cfg.exporterCreateSettings.TelemetrySettings)
5546
if err != nil {
5647
return nil, err
5748
}
5849

59-
return &ObsReport{
60-
level: cfg.ExporterCreateSettings.TelemetrySettings.MetricsLevel,
61-
spanNamePrefix: obsmetrics.ExporterPrefix + cfg.ExporterID.String(),
62-
tracer: cfg.ExporterCreateSettings.TracerProvider.Tracer(cfg.ExporterID.String()),
63-
dataType: cfg.DataType,
50+
return &obsReport{
51+
level: cfg.exporterCreateSettings.TelemetrySettings.MetricsLevel,
52+
spanNamePrefix: obsmetrics.ExporterPrefix + cfg.exporterID.String(),
53+
tracer: cfg.exporterCreateSettings.TracerProvider.Tracer(cfg.exporterID.String()),
54+
dataType: cfg.dataType,
6455
otelAttrs: []attribute.KeyValue{
65-
attribute.String(obsmetrics.ExporterKey, cfg.ExporterID.String()),
56+
attribute.String(obsmetrics.ExporterKey, cfg.exporterID.String()),
6657
},
6758
telemetryBuilder: telemetryBuilder,
6859
}, nil
6960
}
7061

71-
// StartTracesOp is called at the start of an Export operation.
62+
// startTracesOp is called at the start of an Export operation.
7263
// The returned context should be used in other calls to the Exporter functions
7364
// dealing with the same export operation.
74-
//
75-
// Deprecated: [v0.105.0] Not expected to be used directly.
76-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
77-
func (or *ObsReport) StartTracesOp(ctx context.Context) context.Context {
65+
func (or *obsReport) startTracesOp(ctx context.Context) context.Context {
7866
return or.startOp(ctx, obsmetrics.ExportTraceDataOperationSuffix)
7967
}
8068

81-
// EndTracesOp completes the export operation that was started with StartTracesOp.
82-
//
83-
// Deprecated: [v0.105.0] Not expected to be used directly.
84-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
85-
func (or *ObsReport) EndTracesOp(ctx context.Context, numSpans int, err error) {
69+
// endTracesOp completes the export operation that was started with startTracesOp.
70+
func (or *obsReport) endTracesOp(ctx context.Context, numSpans int, err error) {
8671
numSent, numFailedToSend := toNumItems(numSpans, err)
8772
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeTraces, numSent, numFailedToSend)
8873
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentSpansKey, obsmetrics.FailedToSendSpansKey)
8974
}
9075

91-
// StartMetricsOp is called at the start of an Export operation.
76+
// startMetricsOp is called at the start of an Export operation.
9277
// The returned context should be used in other calls to the Exporter functions
9378
// dealing with the same export operation.
94-
//
95-
// Deprecated: [v0.105.0] Not expected to be used directly.
96-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
97-
func (or *ObsReport) StartMetricsOp(ctx context.Context) context.Context {
79+
func (or *obsReport) startMetricsOp(ctx context.Context) context.Context {
9880
return or.startOp(ctx, obsmetrics.ExportMetricsOperationSuffix)
9981
}
10082

101-
// EndMetricsOp completes the export operation that was started with
102-
// StartMetricsOp.
83+
// endMetricsOp completes the export operation that was started with
84+
// startMetricsOp.
10385
//
104-
// Deprecated: [v0.105.0] Not expected to be used directly.
10586
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
106-
func (or *ObsReport) EndMetricsOp(ctx context.Context, numMetricPoints int, err error) {
87+
func (or *obsReport) endMetricsOp(ctx context.Context, numMetricPoints int, err error) {
10788
numSent, numFailedToSend := toNumItems(numMetricPoints, err)
10889
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeMetrics, numSent, numFailedToSend)
10990
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentMetricPointsKey, obsmetrics.FailedToSendMetricPointsKey)
11091
}
11192

112-
// StartLogsOp is called at the start of an Export operation.
93+
// startLogsOp is called at the start of an Export operation.
11394
// The returned context should be used in other calls to the Exporter functions
11495
// dealing with the same export operation.
115-
//
116-
// Deprecated: [v0.105.0] Not expected to be used directly.
117-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
118-
func (or *ObsReport) StartLogsOp(ctx context.Context) context.Context {
96+
func (or *obsReport) startLogsOp(ctx context.Context) context.Context {
11997
return or.startOp(ctx, obsmetrics.ExportLogsOperationSuffix)
12098
}
12199

122-
// EndLogsOp completes the export operation that was started with StartLogsOp.
123-
//
124-
// Deprecated: [v0.105.0] Not expected to be used directly.
125-
// If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.
126-
func (or *ObsReport) EndLogsOp(ctx context.Context, numLogRecords int, err error) {
100+
// endLogsOp completes the export operation that was started with startLogsOp.
101+
func (or *obsReport) endLogsOp(ctx context.Context, numLogRecords int, err error) {
127102
numSent, numFailedToSend := toNumItems(numLogRecords, err)
128103
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeLogs, numSent, numFailedToSend)
129104
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentLogRecordsKey, obsmetrics.FailedToSendLogRecordsKey)
130105
}
131106

132107
// startOp creates the span used to trace the operation. Returning
133108
// the updated context and the created span.
134-
func (or *ObsReport) startOp(ctx context.Context, operationSuffix string) context.Context {
109+
func (or *obsReport) startOp(ctx context.Context, operationSuffix string) context.Context {
135110
spanName := or.spanNamePrefix + operationSuffix
136111
ctx, _ = or.tracer.Start(ctx, spanName)
137112
return ctx
138113
}
139114

140-
func (or *ObsReport) recordMetrics(ctx context.Context, dataType component.DataType, sent, failed int64) {
115+
func (or *obsReport) recordMetrics(ctx context.Context, dataType component.DataType, sent, failed int64) {
141116
if or.level == configtelemetry.LevelNone {
142117
return
143118
}
@@ -180,7 +155,7 @@ func toNumItems(numExportedItems int, err error) (int64, int64) {
180155
return int64(numExportedItems), 0
181156
}
182157

183-
func (or *ObsReport) recordEnqueueFailure(ctx context.Context, dataType component.DataType, failed int64) {
158+
func (or *obsReport) recordEnqueueFailure(ctx context.Context, dataType component.DataType, failed int64) {
184159
var enqueueFailedMeasure metric.Int64Counter
185160
switch dataType {
186161
case component.DataTypeTraces:

0 commit comments

Comments
 (0)