Skip to content

Commit 5848f4d

Browse files
committed
Hide OpenCensus reference from public APIs in obsreport package
1 parent 565d4b9 commit 5848f4d

File tree

21 files changed

+687
-518
lines changed

21 files changed

+687
-518
lines changed

exporter/exporterhelper/logs_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"go.opentelemetry.io/collector/consumer/consumererror"
3131
"go.opentelemetry.io/collector/consumer/consumerhelper"
3232
"go.opentelemetry.io/collector/consumer/pdata"
33+
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3334
"go.opentelemetry.io/collector/internal/testdata"
34-
"go.opentelemetry.io/collector/obsreport"
3535
"go.opentelemetry.io/collector/obsreport/obsreporttest"
3636
)
3737

@@ -222,7 +222,7 @@ func checkWrapSpanForLogsExporter(t *testing.T, le component.LogsExporter, wantE
222222
sentLogRecords = 0
223223
failedToSendLogRecords = numLogRecords
224224
}
225-
require.Equalf(t, sentLogRecords, sd.Attributes[obsreport.SentLogRecordsKey], "SpanData %v", sd)
226-
require.Equalf(t, failedToSendLogRecords, sd.Attributes[obsreport.FailedToSendLogRecordsKey], "SpanData %v", sd)
225+
require.Equalf(t, sentLogRecords, sd.Attributes[obsmetrics.SentLogRecordsKey], "SpanData %v", sd)
226+
require.Equalf(t, failedToSendLogRecords, sd.Attributes[obsmetrics.FailedToSendLogRecordsKey], "SpanData %v", sd)
227227
}
228228
}

exporter/exporterhelper/metrics_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"go.opentelemetry.io/collector/consumer/consumererror"
3131
"go.opentelemetry.io/collector/consumer/consumerhelper"
3232
"go.opentelemetry.io/collector/consumer/pdata"
33+
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3334
"go.opentelemetry.io/collector/internal/testdata"
34-
"go.opentelemetry.io/collector/obsreport"
3535
"go.opentelemetry.io/collector/obsreport/obsreporttest"
3636
)
3737

@@ -246,7 +246,7 @@ func checkWrapSpanForMetricsExporter(t *testing.T, me component.MetricsExporter,
246246
sentMetricPoints = 0
247247
failedToSendMetricPoints = numMetricPoints
248248
}
249-
require.Equalf(t, sentMetricPoints, sd.Attributes[obsreport.SentMetricPointsKey], "SpanData %v", sd)
250-
require.Equalf(t, failedToSendMetricPoints, sd.Attributes[obsreport.FailedToSendMetricPointsKey], "SpanData %v", sd)
249+
require.Equalf(t, sentMetricPoints, sd.Attributes[obsmetrics.SentMetricPointsKey], "SpanData %v", sd)
250+
require.Equalf(t, failedToSendMetricPoints, sd.Attributes[obsmetrics.FailedToSendMetricPointsKey], "SpanData %v", sd)
251251
}
252252
}

exporter/exporterhelper/queued_retry.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ import (
3030
"go.uber.org/zap/zapcore"
3131

3232
"go.opentelemetry.io/collector/consumer/consumererror"
33-
"go.opentelemetry.io/collector/obsreport"
33+
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3434
)
3535

3636
var (
3737
r = metric.NewRegistry()
3838

3939
queueSizeGauge, _ = r.AddInt64DerivedGauge(
40-
obsreport.ExporterKey+"/queue_size",
40+
obsmetrics.ExporterKey+"/queue_size",
4141
metric.WithDescription("Current size of the retry queue (in batches)"),
42-
metric.WithLabelKeys(obsreport.ExporterKey),
42+
metric.WithLabelKeys(obsmetrics.ExporterKey),
4343
metric.WithUnit(metricdata.UnitDimensionless))
4444
)
4545

@@ -127,7 +127,7 @@ func createSampledLogger(logger *zap.Logger) *zap.Logger {
127127
func newQueuedRetrySender(fullName string, qCfg QueueSettings, rCfg RetrySettings, nextSender requestSender, logger *zap.Logger) *queuedRetrySender {
128128
retryStopCh := make(chan struct{})
129129
sampledLogger := createSampledLogger(logger)
130-
traceAttr := trace.StringAttribute(obsreport.ExporterKey, fullName)
130+
traceAttr := trace.StringAttribute(obsmetrics.ExporterKey, fullName)
131131
return &queuedRetrySender{
132132
fullName: fullName,
133133
cfg: qCfg,

exporter/exporterhelper/traces_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import (
3131
"go.opentelemetry.io/collector/consumer/consumererror"
3232
"go.opentelemetry.io/collector/consumer/consumerhelper"
3333
"go.opentelemetry.io/collector/consumer/pdata"
34+
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
3435
"go.opentelemetry.io/collector/internal/testdata"
35-
"go.opentelemetry.io/collector/obsreport"
3636
"go.opentelemetry.io/collector/obsreport/obsreporttest"
3737
)
3838

@@ -239,7 +239,7 @@ func checkWrapSpanForTracesExporter(t *testing.T, te component.TracesExporter, w
239239
failedToSendSpans = numSpans
240240
}
241241

242-
require.Equalf(t, sentSpans, sd.Attributes[obsreport.SentSpansKey], "SpanData %v", sd)
243-
require.Equalf(t, failedToSendSpans, sd.Attributes[obsreport.FailedToSendSpansKey], "SpanData %v", sd)
242+
require.Equalf(t, sentSpans, sd.Attributes[obsmetrics.SentSpansKey], "SpanData %v", sd)
243+
require.Equalf(t, failedToSendSpans, sd.Attributes[obsmetrics.FailedToSendSpansKey], "SpanData %v", sd)
244244
}
245245
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package obsmetrics
16+
17+
import (
18+
"go.opencensus.io/stats"
19+
"go.opencensus.io/tag"
20+
)
21+
22+
const (
23+
// ExporterKey used to identify exporters in metrics and traces.
24+
ExporterKey = "exporter"
25+
26+
// SentSpansKey used to track spans sent by exporters.
27+
SentSpansKey = "sent_spans"
28+
// FailedToSendSpansKey used to track spans that failed to be sent by exporters.
29+
FailedToSendSpansKey = "send_failed_spans"
30+
31+
// SentMetricPointsKey used to track metric points sent by exporters.
32+
SentMetricPointsKey = "sent_metric_points"
33+
// FailedToSendMetricPointsKey used to track metric points that failed to be sent by exporters.
34+
FailedToSendMetricPointsKey = "send_failed_metric_points"
35+
36+
// SentLogRecordsKey used to track logs sent by exporters.
37+
SentLogRecordsKey = "sent_log_records"
38+
// FailedToSendLogRecordsKey used to track logs that failed to be sent by exporters.
39+
FailedToSendLogRecordsKey = "send_failed_log_records"
40+
)
41+
42+
var (
43+
TagKeyExporter, _ = tag.NewKey(ExporterKey)
44+
45+
ExporterPrefix = ExporterKey + NameSep
46+
ExportTraceDataOperationSuffix = NameSep + "traces"
47+
ExportMetricsOperationSuffix = NameSep + "metrics"
48+
ExportLogsOperationSuffix = NameSep + "logs"
49+
50+
// Exporter metrics. Any count of data items below is in the final format
51+
// that they were sent, reasoning: reconciliation is easier if measurements
52+
// on backend and exporter are expected to be the same. Translation issues
53+
// that result in a different number of elements should be reported in a
54+
// separate way.
55+
ExporterSentSpans = stats.Int64(
56+
ExporterPrefix+SentSpansKey,
57+
"Number of spans successfully sent to destination.",
58+
stats.UnitDimensionless)
59+
ExporterFailedToSendSpans = stats.Int64(
60+
ExporterPrefix+FailedToSendSpansKey,
61+
"Number of spans in failed attempts to send to destination.",
62+
stats.UnitDimensionless)
63+
ExporterSentMetricPoints = stats.Int64(
64+
ExporterPrefix+SentMetricPointsKey,
65+
"Number of metric points successfully sent to destination.",
66+
stats.UnitDimensionless)
67+
ExporterFailedToSendMetricPoints = stats.Int64(
68+
ExporterPrefix+FailedToSendMetricPointsKey,
69+
"Number of metric points in failed attempts to send to destination.",
70+
stats.UnitDimensionless)
71+
ExporterSentLogRecords = stats.Int64(
72+
ExporterPrefix+SentLogRecordsKey,
73+
"Number of log record successfully sent to destination.",
74+
stats.UnitDimensionless)
75+
ExporterFailedToSendLogRecords = stats.Int64(
76+
ExporterPrefix+FailedToSendLogRecordsKey,
77+
"Number of log records in failed attempts to send to destination.",
78+
stats.UnitDimensionless)
79+
)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package obsmetrics
16+
17+
import (
18+
"go.opencensus.io/stats"
19+
"go.opencensus.io/tag"
20+
)
21+
22+
const (
23+
// ProcessorKey is the key used to identify processors in metrics and traces.
24+
ProcessorKey = "processor"
25+
26+
// DroppedSpansKey is the key used to identify spans dropped by the Collector.
27+
DroppedSpansKey = "dropped_spans"
28+
29+
// DroppedMetricPointsKey is the key used to identify metric points dropped by the Collector.
30+
DroppedMetricPointsKey = "dropped_metric_points"
31+
32+
// DroppedLogRecordsKey is the key used to identify log records dropped by the Collector.
33+
DroppedLogRecordsKey = "dropped_log_records"
34+
)
35+
36+
var (
37+
TagKeyProcessor, _ = tag.NewKey(ProcessorKey)
38+
39+
ProcessorPrefix = ProcessorKey + NameSep
40+
41+
// Processor metrics. Any count of data items below is in the internal format
42+
// of the collector since processors only deal with internal format.
43+
ProcessorAcceptedSpans = stats.Int64(
44+
ProcessorPrefix+AcceptedSpansKey,
45+
"Number of spans successfully pushed into the next component in the pipeline.",
46+
stats.UnitDimensionless)
47+
ProcessorRefusedSpans = stats.Int64(
48+
ProcessorPrefix+RefusedSpansKey,
49+
"Number of spans that were rejected by the next component in the pipeline.",
50+
stats.UnitDimensionless)
51+
ProcessorDroppedSpans = stats.Int64(
52+
ProcessorPrefix+DroppedSpansKey,
53+
"Number of spans that were dropped.",
54+
stats.UnitDimensionless)
55+
ProcessorAcceptedMetricPoints = stats.Int64(
56+
ProcessorPrefix+AcceptedMetricPointsKey,
57+
"Number of metric points successfully pushed into the next component in the pipeline.",
58+
stats.UnitDimensionless)
59+
ProcessorRefusedMetricPoints = stats.Int64(
60+
ProcessorPrefix+RefusedMetricPointsKey,
61+
"Number of metric points that were rejected by the next component in the pipeline.",
62+
stats.UnitDimensionless)
63+
ProcessorDroppedMetricPoints = stats.Int64(
64+
ProcessorPrefix+DroppedMetricPointsKey,
65+
"Number of metric points that were dropped.",
66+
stats.UnitDimensionless)
67+
ProcessorAcceptedLogRecords = stats.Int64(
68+
ProcessorPrefix+AcceptedLogRecordsKey,
69+
"Number of log records successfully pushed into the next component in the pipeline.",
70+
stats.UnitDimensionless)
71+
ProcessorRefusedLogRecords = stats.Int64(
72+
ProcessorPrefix+RefusedLogRecordsKey,
73+
"Number of log records that were rejected by the next component in the pipeline.",
74+
stats.UnitDimensionless)
75+
ProcessorDroppedLogRecords = stats.Int64(
76+
ProcessorPrefix+DroppedLogRecordsKey,
77+
"Number of log records that were dropped.",
78+
stats.UnitDimensionless)
79+
)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package obsmetrics
16+
17+
import (
18+
"go.opencensus.io/stats"
19+
"go.opencensus.io/tag"
20+
)
21+
22+
const (
23+
// ReceiverKey used to identify receivers in metrics and traces.
24+
ReceiverKey = "receiver"
25+
// TransportKey used to identify the transport used to received the data.
26+
TransportKey = "transport"
27+
// FormatKey used to identify the format of the data received.
28+
FormatKey = "format"
29+
30+
// AcceptedSpansKey used to identify spans accepted by the Collector.
31+
AcceptedSpansKey = "accepted_spans"
32+
// RefusedSpansKey used to identify spans refused (ie.: not ingested) by the Collector.
33+
RefusedSpansKey = "refused_spans"
34+
35+
// AcceptedMetricPointsKey used to identify metric points accepted by the Collector.
36+
AcceptedMetricPointsKey = "accepted_metric_points"
37+
// RefusedMetricPointsKey used to identify metric points refused (ie.: not ingested) by the
38+
// Collector.
39+
RefusedMetricPointsKey = "refused_metric_points"
40+
41+
// AcceptedLogRecordsKey used to identify log records accepted by the Collector.
42+
AcceptedLogRecordsKey = "accepted_log_records"
43+
// RefusedLogRecordsKey used to identify log records refused (ie.: not ingested) by the
44+
// Collector.
45+
RefusedLogRecordsKey = "refused_log_records"
46+
)
47+
48+
var (
49+
TagKeyReceiver, _ = tag.NewKey(ReceiverKey)
50+
TagKeyTransport, _ = tag.NewKey(TransportKey)
51+
52+
ReceiverPrefix = ReceiverKey + NameSep
53+
ReceiveTraceDataOperationSuffix = NameSep + "TraceDataReceived"
54+
ReceiverMetricsOperationSuffix = NameSep + "MetricsReceived"
55+
ReceiverLogsOperationSuffix = NameSep + "LogsReceived"
56+
57+
// Receiver metrics. Any count of data items below is in the original format
58+
// that they were received, reasoning: reconciliation is easier if measurement
59+
// on clients and receiver are expected to be the same. Translation issues
60+
// that result in a different number of elements should be reported in a
61+
// separate way.
62+
ReceiverAcceptedSpans = stats.Int64(
63+
ReceiverPrefix+AcceptedSpansKey,
64+
"Number of spans successfully pushed into the pipeline.",
65+
stats.UnitDimensionless)
66+
ReceiverRefusedSpans = stats.Int64(
67+
ReceiverPrefix+RefusedSpansKey,
68+
"Number of spans that could not be pushed into the pipeline.",
69+
stats.UnitDimensionless)
70+
ReceiverAcceptedMetricPoints = stats.Int64(
71+
ReceiverPrefix+AcceptedMetricPointsKey,
72+
"Number of metric points successfully pushed into the pipeline.",
73+
stats.UnitDimensionless)
74+
ReceiverRefusedMetricPoints = stats.Int64(
75+
ReceiverPrefix+RefusedMetricPointsKey,
76+
"Number of metric points that could not be pushed into the pipeline.",
77+
stats.UnitDimensionless)
78+
ReceiverAcceptedLogRecords = stats.Int64(
79+
ReceiverPrefix+AcceptedLogRecordsKey,
80+
"Number of log records successfully pushed into the pipeline.",
81+
stats.UnitDimensionless)
82+
ReceiverRefusedLogRecords = stats.Int64(
83+
ReceiverPrefix+RefusedLogRecordsKey,
84+
"Number of log records that could not be pushed into the pipeline.",
85+
stats.UnitDimensionless)
86+
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package obsmetrics
16+
17+
import (
18+
"go.opencensus.io/stats"
19+
"go.opencensus.io/tag"
20+
)
21+
22+
const (
23+
// ScraperKey used to identify scrapers in metrics and traces.
24+
ScraperKey = "scraper"
25+
26+
// ScrapedMetricPointsKey used to identify metric points scraped by the
27+
// Collector.
28+
ScrapedMetricPointsKey = "scraped_metric_points"
29+
// ErroredMetricPointsKey used to identify metric points errored (i.e.
30+
// unable to be scraped) by the Collector.
31+
ErroredMetricPointsKey = "errored_metric_points"
32+
)
33+
34+
const (
35+
ScraperPrefix = ScraperKey + NameSep
36+
ScraperMetricsOperationSuffix = NameSep + "MetricsScraped"
37+
)
38+
39+
var (
40+
TagKeyScraper, _ = tag.NewKey(ScraperKey)
41+
42+
ScraperScrapedMetricPoints = stats.Int64(
43+
ScraperPrefix+ScrapedMetricPointsKey,
44+
"Number of metric points successfully scraped.",
45+
stats.UnitDimensionless)
46+
ScraperErroredMetricPoints = stats.Int64(
47+
ScraperPrefix+ErroredMetricPointsKey,
48+
"Number of metric points that were unable to be scraped.",
49+
stats.UnitDimensionless)
50+
)

0 commit comments

Comments
 (0)