Skip to content
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
6 changes: 0 additions & 6 deletions cmd/mdatagen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ replace go.opentelemetry.io/collector/receiver => ../../receiver

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

replace go.opentelemetry.io/collector/featuregate => ../../featuregate

replace go.opentelemetry.io/collector/consumer => ../../consumer

replace go.opentelemetry.io/collector => ../..

replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry

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

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

replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus

replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles
7 changes: 0 additions & 7 deletions exporter/debugexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
go.opentelemetry.io/collector v0.109.0 // indirect
go.opentelemetry.io/collector/config/configretry v1.15.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect
go.opentelemetry.io/collector/consumer/consumertest v0.109.0 // indirect
Expand All @@ -66,8 +65,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace go.opentelemetry.io/collector => ../../

replace go.opentelemetry.io/collector/component => ../../component

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

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

replace go.opentelemetry.io/collector/featuregate => ../../featuregate

replace go.opentelemetry.io/collector/pdata => ../../pdata

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

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

replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus

replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles

replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles
4 changes: 2 additions & 2 deletions exporter/debugexporter/go.sum

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

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package obsmetrics // import "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
package internal // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal"

const (
// spanNameSep is duplicate between receiver and exporter.
spanNameSep = "/"

// ExporterKey used to identify exporters in metrics and traces.
ExporterKey = "exporter"

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

var (
ExporterPrefix = ExporterKey + SpanNameSep
ExporterMetricPrefix = ExporterKey + MetricNameSep
ExportTraceDataOperationSuffix = SpanNameSep + "traces"
ExportMetricsOperationSuffix = SpanNameSep + "metrics"
ExportLogsOperationSuffix = SpanNameSep + "logs"
ExporterPrefix = ExporterKey + spanNameSep
ExportTraceDataOperationSuffix = spanNameSep + "traces"
ExportMetricsOperationSuffix = spanNameSep + "metrics"
ExportLogsOperationSuffix = spanNameSep + "logs"
)
6 changes: 3 additions & 3 deletions exporter/exporterhelper/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/exporter/internal/queue"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/testdata"
)
Expand Down Expand Up @@ -432,7 +432,7 @@ func checkWrapSpanForLogsExporter(t *testing.T, sr *tracetest.SpanRecorder, trac
sentLogRecords = 0
failedToSendLogRecords = numLogRecords
}
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(sentLogRecords)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(failedToSendLogRecords)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(sentLogRecords)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(failedToSendLogRecords)}, "SpanData %v", sd)
}
}
6 changes: 3 additions & 3 deletions exporter/exporterhelper/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/exporter/internal/queue"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/testdata"
)
Expand Down Expand Up @@ -438,7 +438,7 @@ func checkWrapSpanForMetricsExporter(t *testing.T, sr *tracetest.SpanRecorder, t
sentMetricPoints = 0
failedToSendMetricPoints = numMetricPoints
}
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(sentMetricPoints)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(failedToSendMetricPoints)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(sentMetricPoints)}, "SpanData %v", sd)
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(failedToSendMetricPoints)}, "SpanData %v", sd)
}
}
18 changes: 9 additions & 9 deletions exporter/exporterhelper/obsexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/metadata"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

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

return &obsReport{
spanNamePrefix: obsmetrics.ExporterPrefix + cfg.exporterID.String(),
spanNamePrefix: internal.ExporterPrefix + cfg.exporterID.String(),
tracer: cfg.exporterCreateSettings.TracerProvider.Tracer(cfg.exporterID.String()),
dataType: cfg.dataType,
otelAttrs: []attribute.KeyValue{
attribute.String(obsmetrics.ExporterKey, cfg.exporterID.String()),
attribute.String(internal.ExporterKey, cfg.exporterID.String()),
},
telemetryBuilder: telemetryBuilder,
}, nil
Expand All @@ -55,21 +55,21 @@ func newExporter(cfg obsReportSettings) (*obsReport, error) {
// The returned context should be used in other calls to the Exporter functions
// dealing with the same export operation.
func (or *obsReport) startTracesOp(ctx context.Context) context.Context {
return or.startOp(ctx, obsmetrics.ExportTraceDataOperationSuffix)
return or.startOp(ctx, internal.ExportTraceDataOperationSuffix)
}

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

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

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

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

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

// startOp creates the span used to trace the operation. Returning
Expand Down
26 changes: 13 additions & 13 deletions exporter/exporterhelper/obsexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
)

var (
Expand Down Expand Up @@ -55,13 +55,13 @@ func TestExportTraceDataOp(t *testing.T) {
switch {
case params[i].err == nil:
sentSpans += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendSpansKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendSpansKey, Value: attribute.Int64Value(0)})
assert.Equal(t, codes.Unset, span.Status().Code)
case errors.Is(params[i].err, errFake):
failedToSendSpans += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentSpansKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentSpansKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendSpansKey, Value: attribute.Int64Value(int64(params[i].items))})
assert.Equal(t, codes.Error, span.Status().Code)
assert.Equal(t, params[i].err.Error(), span.Status().Description)
default:
Expand Down Expand Up @@ -104,13 +104,13 @@ func TestExportMetricsOp(t *testing.T) {
switch {
case params[i].err == nil:
sentMetricPoints += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(0)})
assert.Equal(t, codes.Unset, span.Status().Code)
case errors.Is(params[i].err, errFake):
failedToSendMetricPoints += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentMetricPointsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentMetricPointsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendMetricPointsKey, Value: attribute.Int64Value(int64(params[i].items))})
assert.Equal(t, codes.Error, span.Status().Code)
assert.Equal(t, params[i].err.Error(), span.Status().Description)
default:
Expand Down Expand Up @@ -153,13 +153,13 @@ func TestExportLogsOp(t *testing.T) {
switch {
case params[i].err == nil:
sentLogRecords += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(0)})
assert.Equal(t, codes.Unset, span.Status().Code)
case errors.Is(params[i].err, errFake):
failedToSendLogRecords += params[i].items
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.SentLogRecordsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: obsmetrics.FailedToSendLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.SentLogRecordsKey, Value: attribute.Int64Value(0)})
require.Contains(t, span.Attributes(), attribute.KeyValue{Key: internal.FailedToSendLogRecordsKey, Value: attribute.Int64Value(int64(params[i].items))})
assert.Equal(t, codes.Error, span.Status().Code)
assert.Equal(t, params[i].err.Error(), span.Status().Description)
default:
Expand Down
6 changes: 3 additions & 3 deletions exporter/exporterhelper/queue_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exporterqueue"
"go.opentelemetry.io/collector/exporter/internal/queue"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

const defaultQueueSize = 1000
Expand Down Expand Up @@ -82,7 +82,7 @@ func newQueueSender(q exporterqueue.Queue[Request], set exporter.Settings, numCo
qs := &queueSender{
queue: q,
numConsumers: numConsumers,
traceAttribute: attribute.String(obsmetrics.ExporterKey, set.ID.String()),
traceAttribute: attribute.String(internal.ExporterKey, set.ID.String()),
obsrep: obsrep,
exporterID: set.ID,
}
Expand All @@ -104,7 +104,7 @@ func (qs *queueSender) Start(ctx context.Context, host component.Host) error {
return err
}

dataTypeAttr := attribute.String(obsmetrics.DataTypeKey, qs.obsrep.dataType.String())
dataTypeAttr := attribute.String(internal.DataTypeKey, qs.obsrep.dataType.String())
return multierr.Append(
qs.obsrep.telemetryBuilder.InitExporterQueueSize(func() int64 { return int64(qs.queue.Size()) },
metric.WithAttributeSet(attribute.NewSet(qs.traceAttribute, dataTypeAttr))),
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/queue_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exporterqueue"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/exporter/internal/queue"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

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

assert.NoError(t, be.Shutdown(context.Background()))
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/retry_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/internal/experr"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

// TODO: Clean this by forcing all exporters to return an internal error type that always include the information about retries.
Expand Down Expand Up @@ -53,7 +53,7 @@ type retrySender struct {

func newRetrySender(config configretry.BackOffConfig, set exporter.Settings) *retrySender {
return &retrySender{
traceAttribute: attribute.String(obsmetrics.ExporterKey, set.ID.String()),
traceAttribute: attribute.String(internal.ExporterKey, set.ID.String()),
cfg: config,
stopCh: make(chan struct{}),
logger: set.Logger,
Expand Down
Loading