Skip to content

Commit 1245955

Browse files
authored
Remove obsreportconfig package, reduce dependencies (#11148)
Small issue that the `SpanNameSep` is duplicated, but is a very small duplicate. Signed-off-by: Bogdan Drutu <[email protected]>
1 parent eb0a4b6 commit 1245955

File tree

42 files changed

+163
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+163
-300
lines changed

cmd/mdatagen/go.mod

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ replace go.opentelemetry.io/collector/receiver => ../../receiver
7878

7979
replace go.opentelemetry.io/collector/semconv => ../../semconv
8080

81-
replace go.opentelemetry.io/collector/featuregate => ../../featuregate
82-
8381
replace go.opentelemetry.io/collector/consumer => ../../consumer
8482

85-
replace go.opentelemetry.io/collector => ../..
86-
8783
replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry
8884

8985
retract (
@@ -98,6 +94,4 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume
9894

9995
replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest
10096

101-
replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus
102-
10397
replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles

exporter/debugexporter/go.mod

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ require (
4040
github.com/prometheus/client_model v0.6.1 // indirect
4141
github.com/prometheus/common v0.59.1 // indirect
4242
github.com/prometheus/procfs v0.15.1 // indirect
43-
go.opentelemetry.io/collector v0.109.0 // indirect
4443
go.opentelemetry.io/collector/config/configretry v1.15.0 // indirect
4544
go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect
4645
go.opentelemetry.io/collector/consumer/consumertest v0.109.0 // indirect
@@ -66,8 +65,6 @@ require (
6665
gopkg.in/yaml.v3 v3.0.1 // indirect
6766
)
6867

69-
replace go.opentelemetry.io/collector => ../../
70-
7168
replace go.opentelemetry.io/collector/component => ../../component
7269

7370
replace go.opentelemetry.io/collector/confmap => ../../confmap
@@ -76,8 +73,6 @@ replace go.opentelemetry.io/collector/consumer => ../../consumer
7673

7774
replace go.opentelemetry.io/collector/exporter => ../
7875

79-
replace go.opentelemetry.io/collector/featuregate => ../../featuregate
80-
8176
replace go.opentelemetry.io/collector/pdata => ../../pdata
8277

8378
replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata
@@ -98,8 +93,6 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume
9893

9994
replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest
10095

101-
replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus
102-
10396
replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles
10497

10598
replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles

exporter/debugexporter/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/obsreportconfig/obsmetrics/obs_exporter.go renamed to exporter/exporterhelper/internal/obsmetrics.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package obsmetrics // import "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
4+
package internal // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal"
55

66
const (
7+
// spanNameSep is duplicate between receiver and exporter.
8+
spanNameSep = "/"
9+
710
// ExporterKey used to identify exporters in metrics and traces.
811
ExporterKey = "exporter"
912

@@ -24,12 +27,9 @@ const (
2427
SentLogRecordsKey = "sent_log_records"
2528
// FailedToSendLogRecordsKey used to track logs that failed to be sent by exporters.
2629
FailedToSendLogRecordsKey = "send_failed_log_records"
27-
)
2830

29-
var (
30-
ExporterPrefix = ExporterKey + SpanNameSep
31-
ExporterMetricPrefix = ExporterKey + MetricNameSep
32-
ExportTraceDataOperationSuffix = SpanNameSep + "traces"
33-
ExportMetricsOperationSuffix = SpanNameSep + "metrics"
34-
ExportLogsOperationSuffix = SpanNameSep + "logs"
31+
ExporterPrefix = ExporterKey + spanNameSep
32+
ExportTraceDataOperationSuffix = spanNameSep + "traces"
33+
ExportMetricsOperationSuffix = spanNameSep + "metrics"
34+
ExportLogsOperationSuffix = spanNameSep + "logs"
3535
)

exporter/exporterhelper/logs_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"go.opentelemetry.io/collector/consumer/consumererror"
2626
"go.opentelemetry.io/collector/consumer/consumertest"
2727
"go.opentelemetry.io/collector/exporter"
28+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
2829
"go.opentelemetry.io/collector/exporter/exportertest"
2930
"go.opentelemetry.io/collector/exporter/internal/queue"
30-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3131
"go.opentelemetry.io/collector/pdata/plog"
3232
"go.opentelemetry.io/collector/pdata/testdata"
3333
)
@@ -432,7 +432,7 @@ func checkWrapSpanForLogsExporter(t *testing.T, sr *tracetest.SpanRecorder, trac
432432
sentLogRecords = 0
433433
failedToSendLogRecords = numLogRecords
434434
}
435-
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(sentLogRecords)}, "SpanData %v", sd)
436-
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(failedToSendLogRecords)}, "SpanData %v", sd)
435+
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(sentLogRecords)}, "SpanData %v", sd)
436+
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(failedToSendLogRecords)}, "SpanData %v", sd)
437437
}
438438
}

exporter/exporterhelper/metrics_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"go.opentelemetry.io/collector/consumer/consumererror"
2626
"go.opentelemetry.io/collector/consumer/consumertest"
2727
"go.opentelemetry.io/collector/exporter"
28+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
2829
"go.opentelemetry.io/collector/exporter/exportertest"
2930
"go.opentelemetry.io/collector/exporter/internal/queue"
30-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3131
"go.opentelemetry.io/collector/pdata/pmetric"
3232
"go.opentelemetry.io/collector/pdata/testdata"
3333
)
@@ -438,7 +438,7 @@ func checkWrapSpanForMetricsExporter(t *testing.T, sr *tracetest.SpanRecorder, t
438438
sentMetricPoints = 0
439439
failedToSendMetricPoints = numMetricPoints
440440
}
441-
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(sentMetricPoints)}, "SpanData %v", sd)
442-
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(failedToSendMetricPoints)}, "SpanData %v", sd)
441+
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(sentMetricPoints)}, "SpanData %v", sd)
442+
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(failedToSendMetricPoints)}, "SpanData %v", sd)
443443
}
444444
}

exporter/exporterhelper/obsexporter.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"go.opentelemetry.io/collector/component"
1515
"go.opentelemetry.io/collector/exporter"
16+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
1617
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/metadata"
17-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
1818
)
1919

2020
// obsReport is a helper to add observability to an exporter.
@@ -41,11 +41,11 @@ func newExporter(cfg obsReportSettings) (*obsReport, error) {
4141
}
4242

4343
return &obsReport{
44-
spanNamePrefix: obsmetrics.ExporterPrefix + cfg.exporterID.String(),
44+
spanNamePrefix: internal.ExporterPrefix + cfg.exporterID.String(),
4545
tracer: cfg.exporterCreateSettings.TracerProvider.Tracer(cfg.exporterID.String()),
4646
dataType: cfg.dataType,
4747
otelAttrs: []attribute.KeyValue{
48-
attribute.String(obsmetrics.ExporterKey, cfg.exporterID.String()),
48+
attribute.String(internal.ExporterKey, cfg.exporterID.String()),
4949
},
5050
telemetryBuilder: telemetryBuilder,
5151
}, nil
@@ -55,21 +55,21 @@ func newExporter(cfg obsReportSettings) (*obsReport, error) {
5555
// The returned context should be used in other calls to the Exporter functions
5656
// dealing with the same export operation.
5757
func (or *obsReport) startTracesOp(ctx context.Context) context.Context {
58-
return or.startOp(ctx, obsmetrics.ExportTraceDataOperationSuffix)
58+
return or.startOp(ctx, internal.ExportTraceDataOperationSuffix)
5959
}
6060

6161
// endTracesOp completes the export operation that was started with startTracesOp.
6262
func (or *obsReport) endTracesOp(ctx context.Context, numSpans int, err error) {
6363
numSent, numFailedToSend := toNumItems(numSpans, err)
6464
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeTraces, numSent, numFailedToSend)
65-
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentSpansKey, obsmetrics.FailedToSendSpansKey)
65+
endSpan(ctx, err, numSent, numFailedToSend, internal.SentSpansKey, internal.FailedToSendSpansKey)
6666
}
6767

6868
// startMetricsOp is called at the start of an Export operation.
6969
// The returned context should be used in other calls to the Exporter functions
7070
// dealing with the same export operation.
7171
func (or *obsReport) startMetricsOp(ctx context.Context) context.Context {
72-
return or.startOp(ctx, obsmetrics.ExportMetricsOperationSuffix)
72+
return or.startOp(ctx, internal.ExportMetricsOperationSuffix)
7373
}
7474

7575
// endMetricsOp completes the export operation that was started with
@@ -79,21 +79,21 @@ func (or *obsReport) startMetricsOp(ctx context.Context) context.Context {
7979
func (or *obsReport) endMetricsOp(ctx context.Context, numMetricPoints int, err error) {
8080
numSent, numFailedToSend := toNumItems(numMetricPoints, err)
8181
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeMetrics, numSent, numFailedToSend)
82-
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentMetricPointsKey, obsmetrics.FailedToSendMetricPointsKey)
82+
endSpan(ctx, err, numSent, numFailedToSend, internal.SentMetricPointsKey, internal.FailedToSendMetricPointsKey)
8383
}
8484

8585
// startLogsOp is called at the start of an Export operation.
8686
// The returned context should be used in other calls to the Exporter functions
8787
// dealing with the same export operation.
8888
func (or *obsReport) startLogsOp(ctx context.Context) context.Context {
89-
return or.startOp(ctx, obsmetrics.ExportLogsOperationSuffix)
89+
return or.startOp(ctx, internal.ExportLogsOperationSuffix)
9090
}
9191

9292
// endLogsOp completes the export operation that was started with startLogsOp.
9393
func (or *obsReport) endLogsOp(ctx context.Context, numLogRecords int, err error) {
9494
numSent, numFailedToSend := toNumItems(numLogRecords, err)
9595
or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeLogs, numSent, numFailedToSend)
96-
endSpan(ctx, err, numSent, numFailedToSend, obsmetrics.SentLogRecordsKey, obsmetrics.FailedToSendLogRecordsKey)
96+
endSpan(ctx, err, numSent, numFailedToSend, internal.SentLogRecordsKey, internal.FailedToSendLogRecordsKey)
9797
}
9898

9999
// startOp creates the span used to trace the operation. Returning

exporter/exporterhelper/obsexporter_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"go.opentelemetry.io/collector/component"
1717
"go.opentelemetry.io/collector/component/componenttest"
1818
"go.opentelemetry.io/collector/exporter"
19-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
19+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
2020
)
2121

2222
var (
@@ -55,13 +55,13 @@ func TestExportTraceDataOp(t *testing.T) {
5555
switch {
5656
case params[i].err == nil:
5757
sentSpans += params[i].items
58-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
59-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendSpansKey, Value: attribute.Int64Value(0)})
58+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
59+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendSpansKey, Value: attribute.Int64Value(0)})
6060
assert.Equal(t, codes.Unset, span.Status().Code)
6161
case errors.Is(params[i].err, errFake):
6262
failedToSendSpans += params[i].items
63-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentSpansKey, Value: attribute.Int64Value(0)})
64-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
63+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentSpansKey, Value: attribute.Int64Value(0)})
64+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
6565
assert.Equal(t, codes.Error, span.Status().Code)
6666
assert.Equal(t, params[i].err.Error(), span.Status().Description)
6767
default:
@@ -104,13 +104,13 @@ func TestExportMetricsOp(t *testing.T) {
104104
switch {
105105
case params[i].err == nil:
106106
sentMetricPoints += params[i].items
107-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
108-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(0)})
107+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
108+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(0)})
109109
assert.Equal(t, codes.Unset, span.Status().Code)
110110
case errors.Is(params[i].err, errFake):
111111
failedToSendMetricPoints += params[i].items
112-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(0)})
113-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
112+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(0)})
113+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
114114
assert.Equal(t, codes.Error, span.Status().Code)
115115
assert.Equal(t, params[i].err.Error(), span.Status().Description)
116116
default:
@@ -153,13 +153,13 @@ func TestExportLogsOp(t *testing.T) {
153153
switch {
154154
case params[i].err == nil:
155155
sentLogRecords += params[i].items
156-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
157-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(0)})
156+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
157+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(0)})
158158
assert.Equal(t, codes.Unset, span.Status().Code)
159159
case errors.Is(params[i].err, errFake):
160160
failedToSendLogRecords += params[i].items
161-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(0)})
162-
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
161+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(0)})
162+
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
163163
assert.Equal(t, codes.Error, span.Status().Code)
164164
assert.Equal(t, params[i].err.Error(), span.Status().Description)
165165
default:

exporter/exporterhelper/queue_sender.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515

1616
"go.opentelemetry.io/collector/component"
1717
"go.opentelemetry.io/collector/exporter"
18+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
1819
"go.opentelemetry.io/collector/exporter/exporterqueue"
1920
"go.opentelemetry.io/collector/exporter/internal/queue"
20-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
2121
)
2222

2323
const defaultQueueSize = 1000
@@ -90,7 +90,7 @@ func newQueueSender(q exporterqueue.Queue[Request], set exporter.Settings, numCo
9090
qs := &queueSender{
9191
queue: q,
9292
numConsumers: numConsumers,
93-
traceAttribute: attribute.String(obsmetrics.ExporterKey, set.ID.String()),
93+
traceAttribute: attribute.String(internal.ExporterKey, set.ID.String()),
9494
obsrep: obsrep,
9595
exporterID: set.ID,
9696
}
@@ -112,7 +112,7 @@ func (qs *queueSender) Start(ctx context.Context, host component.Host) error {
112112
return err
113113
}
114114

115-
dataTypeAttr := attribute.String(obsmetrics.DataTypeKey, qs.obsrep.dataType.String())
115+
dataTypeAttr := attribute.String(internal.DataTypeKey, qs.obsrep.dataType.String())
116116
return multierr.Append(
117117
qs.obsrep.telemetryBuilder.InitExporterQueueSize(func() int64 { return int64(qs.queue.Size()) },
118118
metric.WithAttributeSet(attribute.NewSet(qs.traceAttribute, dataTypeAttr))),

exporter/exporterhelper/queue_sender_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import (
1919
"go.opentelemetry.io/collector/component/componenttest"
2020
"go.opentelemetry.io/collector/config/configretry"
2121
"go.opentelemetry.io/collector/exporter"
22+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
2223
"go.opentelemetry.io/collector/exporter/exporterqueue"
2324
"go.opentelemetry.io/collector/exporter/exportertest"
2425
"go.opentelemetry.io/collector/exporter/internal/queue"
25-
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
2626
)
2727

2828
func TestQueuedRetry_StopWhileWaiting(t *testing.T) {
@@ -226,7 +226,7 @@ func TestQueuedRetry_QueueMetricsReported(t *testing.T) {
226226
require.NoError(t, be.send(context.Background(), newErrorRequest()))
227227
}
228228
require.NoError(t, tt.CheckExporterMetricGauge("otelcol_exporter_queue_size", int64(7),
229-
attribute.String(obsmetrics.DataTypeKey, dataType.String())))
229+
attribute.String(internal.DataTypeKey, dataType.String())))
230230

231231
assert.NoError(t, be.Shutdown(context.Background()))
232232
}

0 commit comments

Comments
 (0)