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

Avoid exposing OpenCensus reference in public APIs #3253

Merged
merged 1 commit into from
May 26, 2021
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: 3 additions & 3 deletions exporter/exporterhelper/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumerhelper"
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
)

Expand Down Expand Up @@ -222,7 +222,7 @@ func checkWrapSpanForLogsExporter(t *testing.T, le component.LogsExporter, wantE
sentLogRecords = 0
failedToSendLogRecords = numLogRecords
}
require.Equalf(t, sentLogRecords, sd.Attributes[obsreport.SentLogRecordsKey], "SpanData %v", sd)
require.Equalf(t, failedToSendLogRecords, sd.Attributes[obsreport.FailedToSendLogRecordsKey], "SpanData %v", sd)
require.Equalf(t, sentLogRecords, sd.Attributes[obsmetrics.SentLogRecordsKey], "SpanData %v", sd)
require.Equalf(t, failedToSendLogRecords, sd.Attributes[obsmetrics.FailedToSendLogRecordsKey], "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 @@ -30,8 +30,8 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumerhelper"
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
)

Expand Down Expand Up @@ -246,7 +246,7 @@ func checkWrapSpanForMetricsExporter(t *testing.T, me component.MetricsExporter,
sentMetricPoints = 0
failedToSendMetricPoints = numMetricPoints
}
require.Equalf(t, sentMetricPoints, sd.Attributes[obsreport.SentMetricPointsKey], "SpanData %v", sd)
require.Equalf(t, failedToSendMetricPoints, sd.Attributes[obsreport.FailedToSendMetricPointsKey], "SpanData %v", sd)
require.Equalf(t, sentMetricPoints, sd.Attributes[obsmetrics.SentMetricPointsKey], "SpanData %v", sd)
require.Equalf(t, failedToSendMetricPoints, sd.Attributes[obsmetrics.FailedToSendMetricPointsKey], "SpanData %v", sd)
}
}
8 changes: 4 additions & 4 deletions exporter/exporterhelper/queued_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ import (
"go.uber.org/zap/zapcore"

"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

var (
r = metric.NewRegistry()

queueSizeGauge, _ = r.AddInt64DerivedGauge(
obsreport.ExporterKey+"/queue_size",
obsmetrics.ExporterKey+"/queue_size",
metric.WithDescription("Current size of the retry queue (in batches)"),
metric.WithLabelKeys(obsreport.ExporterKey),
metric.WithLabelKeys(obsmetrics.ExporterKey),
metric.WithUnit(metricdata.UnitDimensionless))
)

Expand Down Expand Up @@ -127,7 +127,7 @@ func createSampledLogger(logger *zap.Logger) *zap.Logger {
func newQueuedRetrySender(fullName string, qCfg QueueSettings, rCfg RetrySettings, nextSender requestSender, logger *zap.Logger) *queuedRetrySender {
retryStopCh := make(chan struct{})
sampledLogger := createSampledLogger(logger)
traceAttr := trace.StringAttribute(obsreport.ExporterKey, fullName)
traceAttr := trace.StringAttribute(obsmetrics.ExporterKey, fullName)
return &queuedRetrySender{
fullName: fullName,
cfg: qCfg,
Expand Down
6 changes: 3 additions & 3 deletions exporter/exporterhelper/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumerhelper"
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
)

Expand Down Expand Up @@ -239,7 +239,7 @@ func checkWrapSpanForTracesExporter(t *testing.T, te component.TracesExporter, w
failedToSendSpans = numSpans
}

require.Equalf(t, sentSpans, sd.Attributes[obsreport.SentSpansKey], "SpanData %v", sd)
require.Equalf(t, failedToSendSpans, sd.Attributes[obsreport.FailedToSendSpansKey], "SpanData %v", sd)
require.Equalf(t, sentSpans, sd.Attributes[obsmetrics.SentSpansKey], "SpanData %v", sd)
require.Equalf(t, failedToSendSpans, sd.Attributes[obsmetrics.FailedToSendSpansKey], "SpanData %v", sd)
}
}
79 changes: 79 additions & 0 deletions internal/obsreportconfig/obsmetrics/obs_exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package obsmetrics

import (
"go.opencensus.io/stats"
"go.opencensus.io/tag"
)

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

// SentSpansKey used to track spans sent by exporters.
SentSpansKey = "sent_spans"
// FailedToSendSpansKey used to track spans that failed to be sent by exporters.
FailedToSendSpansKey = "send_failed_spans"

// SentMetricPointsKey used to track metric points sent by exporters.
SentMetricPointsKey = "sent_metric_points"
// FailedToSendMetricPointsKey used to track metric points that failed to be sent by exporters.
FailedToSendMetricPointsKey = "send_failed_metric_points"

// SentLogRecordsKey used to track logs sent by exporters.
SentLogRecordsKey = "sent_log_records"
// FailedToSendLogRecordsKey used to track logs that failed to be sent by exporters.
FailedToSendLogRecordsKey = "send_failed_log_records"
)

var (
TagKeyExporter, _ = tag.NewKey(ExporterKey)

ExporterPrefix = ExporterKey + NameSep
ExportTraceDataOperationSuffix = NameSep + "traces"
ExportMetricsOperationSuffix = NameSep + "metrics"
ExportLogsOperationSuffix = NameSep + "logs"

// Exporter metrics. Any count of data items below is in the final format
// that they were sent, reasoning: reconciliation is easier if measurements
// on backend and exporter are expected to be the same. Translation issues
// that result in a different number of elements should be reported in a
// separate way.
ExporterSentSpans = stats.Int64(
ExporterPrefix+SentSpansKey,
"Number of spans successfully sent to destination.",
stats.UnitDimensionless)
ExporterFailedToSendSpans = stats.Int64(
ExporterPrefix+FailedToSendSpansKey,
"Number of spans in failed attempts to send to destination.",
stats.UnitDimensionless)
ExporterSentMetricPoints = stats.Int64(
ExporterPrefix+SentMetricPointsKey,
"Number of metric points successfully sent to destination.",
stats.UnitDimensionless)
ExporterFailedToSendMetricPoints = stats.Int64(
ExporterPrefix+FailedToSendMetricPointsKey,
"Number of metric points in failed attempts to send to destination.",
stats.UnitDimensionless)
ExporterSentLogRecords = stats.Int64(
ExporterPrefix+SentLogRecordsKey,
"Number of log record successfully sent to destination.",
stats.UnitDimensionless)
ExporterFailedToSendLogRecords = stats.Int64(
ExporterPrefix+FailedToSendLogRecordsKey,
"Number of log records in failed attempts to send to destination.",
stats.UnitDimensionless)
)
79 changes: 79 additions & 0 deletions internal/obsreportconfig/obsmetrics/obs_processor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package obsmetrics

import (
"go.opencensus.io/stats"
"go.opencensus.io/tag"
)

const (
// ProcessorKey is the key used to identify processors in metrics and traces.
ProcessorKey = "processor"

// DroppedSpansKey is the key used to identify spans dropped by the Collector.
DroppedSpansKey = "dropped_spans"

// DroppedMetricPointsKey is the key used to identify metric points dropped by the Collector.
DroppedMetricPointsKey = "dropped_metric_points"

// DroppedLogRecordsKey is the key used to identify log records dropped by the Collector.
DroppedLogRecordsKey = "dropped_log_records"
)

var (
TagKeyProcessor, _ = tag.NewKey(ProcessorKey)

ProcessorPrefix = ProcessorKey + NameSep

// Processor metrics. Any count of data items below is in the internal format
// of the collector since processors only deal with internal format.
ProcessorAcceptedSpans = stats.Int64(
ProcessorPrefix+AcceptedSpansKey,
"Number of spans successfully pushed into the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorRefusedSpans = stats.Int64(
ProcessorPrefix+RefusedSpansKey,
"Number of spans that were rejected by the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorDroppedSpans = stats.Int64(
ProcessorPrefix+DroppedSpansKey,
"Number of spans that were dropped.",
stats.UnitDimensionless)
ProcessorAcceptedMetricPoints = stats.Int64(
ProcessorPrefix+AcceptedMetricPointsKey,
"Number of metric points successfully pushed into the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorRefusedMetricPoints = stats.Int64(
ProcessorPrefix+RefusedMetricPointsKey,
"Number of metric points that were rejected by the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorDroppedMetricPoints = stats.Int64(
ProcessorPrefix+DroppedMetricPointsKey,
"Number of metric points that were dropped.",
stats.UnitDimensionless)
ProcessorAcceptedLogRecords = stats.Int64(
ProcessorPrefix+AcceptedLogRecordsKey,
"Number of log records successfully pushed into the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorRefusedLogRecords = stats.Int64(
ProcessorPrefix+RefusedLogRecordsKey,
"Number of log records that were rejected by the next component in the pipeline.",
stats.UnitDimensionless)
ProcessorDroppedLogRecords = stats.Int64(
ProcessorPrefix+DroppedLogRecordsKey,
"Number of log records that were dropped.",
stats.UnitDimensionless)
)
86 changes: 86 additions & 0 deletions internal/obsreportconfig/obsmetrics/obs_receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package obsmetrics

import (
"go.opencensus.io/stats"
"go.opencensus.io/tag"
)

const (
// ReceiverKey used to identify receivers in metrics and traces.
ReceiverKey = "receiver"
// TransportKey used to identify the transport used to received the data.
TransportKey = "transport"
// FormatKey used to identify the format of the data received.
FormatKey = "format"

// AcceptedSpansKey used to identify spans accepted by the Collector.
AcceptedSpansKey = "accepted_spans"
// RefusedSpansKey used to identify spans refused (ie.: not ingested) by the Collector.
RefusedSpansKey = "refused_spans"

// AcceptedMetricPointsKey used to identify metric points accepted by the Collector.
AcceptedMetricPointsKey = "accepted_metric_points"
// RefusedMetricPointsKey used to identify metric points refused (ie.: not ingested) by the
// Collector.
RefusedMetricPointsKey = "refused_metric_points"

// AcceptedLogRecordsKey used to identify log records accepted by the Collector.
AcceptedLogRecordsKey = "accepted_log_records"
// RefusedLogRecordsKey used to identify log records refused (ie.: not ingested) by the
// Collector.
RefusedLogRecordsKey = "refused_log_records"
)

var (
TagKeyReceiver, _ = tag.NewKey(ReceiverKey)
TagKeyTransport, _ = tag.NewKey(TransportKey)

ReceiverPrefix = ReceiverKey + NameSep
ReceiveTraceDataOperationSuffix = NameSep + "TraceDataReceived"
ReceiverMetricsOperationSuffix = NameSep + "MetricsReceived"
ReceiverLogsOperationSuffix = NameSep + "LogsReceived"

// Receiver metrics. Any count of data items below is in the original format
// that they were received, reasoning: reconciliation is easier if measurement
// on clients and receiver are expected to be the same. Translation issues
// that result in a different number of elements should be reported in a
// separate way.
ReceiverAcceptedSpans = stats.Int64(
ReceiverPrefix+AcceptedSpansKey,
"Number of spans successfully pushed into the pipeline.",
stats.UnitDimensionless)
ReceiverRefusedSpans = stats.Int64(
ReceiverPrefix+RefusedSpansKey,
"Number of spans that could not be pushed into the pipeline.",
stats.UnitDimensionless)
ReceiverAcceptedMetricPoints = stats.Int64(
ReceiverPrefix+AcceptedMetricPointsKey,
"Number of metric points successfully pushed into the pipeline.",
stats.UnitDimensionless)
ReceiverRefusedMetricPoints = stats.Int64(
ReceiverPrefix+RefusedMetricPointsKey,
"Number of metric points that could not be pushed into the pipeline.",
stats.UnitDimensionless)
ReceiverAcceptedLogRecords = stats.Int64(
ReceiverPrefix+AcceptedLogRecordsKey,
"Number of log records successfully pushed into the pipeline.",
stats.UnitDimensionless)
ReceiverRefusedLogRecords = stats.Int64(
ReceiverPrefix+RefusedLogRecordsKey,
"Number of log records that could not be pushed into the pipeline.",
stats.UnitDimensionless)
)
50 changes: 50 additions & 0 deletions internal/obsreportconfig/obsmetrics/obs_scraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package obsmetrics

import (
"go.opencensus.io/stats"
"go.opencensus.io/tag"
)

const (
// ScraperKey used to identify scrapers in metrics and traces.
ScraperKey = "scraper"

// ScrapedMetricPointsKey used to identify metric points scraped by the
// Collector.
ScrapedMetricPointsKey = "scraped_metric_points"
// ErroredMetricPointsKey used to identify metric points errored (i.e.
// unable to be scraped) by the Collector.
ErroredMetricPointsKey = "errored_metric_points"
)

const (
ScraperPrefix = ScraperKey + NameSep
ScraperMetricsOperationSuffix = NameSep + "MetricsScraped"
)

var (
TagKeyScraper, _ = tag.NewKey(ScraperKey)

ScraperScrapedMetricPoints = stats.Int64(
ScraperPrefix+ScrapedMetricPointsKey,
"Number of metric points successfully scraped.",
stats.UnitDimensionless)
ScraperErroredMetricPoints = stats.Int64(
ScraperPrefix+ErroredMetricPointsKey,
"Number of metric points that were unable to be scraped.",
stats.UnitDimensionless)
)
Loading