Skip to content

Commit

Permalink
remove opencensus bridge support
Browse files Browse the repository at this point in the history
This removes the configuration of the OpenCensus bridge from the Collector. This
means that any metric still relying on it will no longer be emitting metrics.

This is blocked until open-telemetry/opentelemetry-collector-contrib#29867 is completed.

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten committed Jun 17, 2024
1 parent 7a3c35c commit eb21f31
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 304 deletions.
3 changes: 0 additions & 3 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
Expand Down Expand Up @@ -78,7 +77,6 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.102.1 // indirect
go.opentelemetry.io/collector/config/configauth v0.102.1 // indirect
go.opentelemetry.io/collector/config/configcompression v1.9.0 // indirect
Expand All @@ -102,7 +100,6 @@ require (
go.opentelemetry.io/contrib/propagators/b3 v1.27.0 // indirect
go.opentelemetry.io/contrib/zpages v0.52.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/bridge/opencensus v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
Expand Down
79 changes: 0 additions & 79 deletions cmd/otelcorecol/go.sum

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions otelcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
Expand All @@ -67,15 +66,14 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.102.1 // indirect
go.opentelemetry.io/collector/consumer v0.102.1 // indirect
go.opentelemetry.io/collector/pdata v1.9.0 // indirect
go.opentelemetry.io/collector/pdata/testdata v0.102.1 // indirect
go.opentelemetry.io/collector/semconv v0.102.1 // indirect
go.opentelemetry.io/contrib/config v0.7.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.27.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/bridge/opencensus v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
Expand Down
79 changes: 0 additions & 79 deletions otelcol/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion service/generated_package_test.go

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

3 changes: 0 additions & 3 deletions service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/prometheus/common v0.54.0
github.com/shirou/gopsutil/v4 v4.24.5
github.com/stretchr/testify v1.9.0
go.opencensus.io v0.24.0
go.opentelemetry.io/collector v0.102.1
go.opentelemetry.io/collector/component v0.102.1
go.opentelemetry.io/collector/config/confighttp v0.102.1
Expand All @@ -29,7 +28,6 @@ require (
go.opentelemetry.io/contrib/config v0.7.0
go.opentelemetry.io/contrib/propagators/b3 v1.27.0
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/bridge/opencensus v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0
go.opentelemetry.io/otel/exporters/prometheus v0.49.0
Expand All @@ -56,7 +54,6 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
Expand Down
79 changes: 0 additions & 79 deletions service/go.sum

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions service/internal/proctelemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/contrib/config"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/bridge/opencensus"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
otelprom "go.opentelemetry.io/otel/exporters/prometheus"
Expand Down Expand Up @@ -66,9 +65,7 @@ func InitMetricReader(ctx context.Context, reader config.MetricReader, asyncErro
return initPullExporter(reader.Pull.Exporter, asyncErrorChannel)
}
if reader.Periodic != nil {
opts := []sdkmetric.PeriodicReaderOption{
sdkmetric.WithProducer(opencensus.NewMetricProducer()),
}
var opts []sdkmetric.PeriodicReaderOption
if reader.Periodic.Interval != nil {
opts = append(opts, sdkmetric.WithInterval(time.Duration(*reader.Periodic.Interval)*time.Millisecond))
}
Expand Down Expand Up @@ -165,7 +162,6 @@ func initPrometheusExporter(prometheusConfig *config.Prometheus, asyncErrorChann
otelprom.WithoutUnits(),
// Disabled for the moment until this becomes stable, and we are ready to break backwards compatibility.
otelprom.WithoutScopeInfo(),
otelprom.WithProducer(opencensus.NewMetricProducer()),
// This allows us to produce metrics that are backwards compatible w/ opencensus
otelprom.WithoutCounterSuffixes(),
otelprom.WithNamespace("otelcol"),
Expand Down
2 changes: 0 additions & 2 deletions service/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ tests:
goleak:
ignore:
top:
# See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
- "go.opencensus.io/stats/view.(*worker).start"
- "go.opentelemetry.io/collector/service/internal/proctelemetry.InitPrometheusServer.func1"

telemetry:
Expand Down
52 changes: 2 additions & 50 deletions service/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
io_prometheus_client "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/stretchr/testify/require"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opentelemetry.io/contrib/config"
"go.opentelemetry.io/otel/metric"

Expand All @@ -29,7 +27,6 @@ import (
const (
metricPrefix = "otelcol_"
otelPrefix = "otel_sdk_"
ocPrefix = "oc_sdk_"
grpcPrefix = "gprc_"
httpPrefix = "http_"
counterName = "test_counter"
Expand All @@ -51,14 +48,6 @@ func TestTelemetryInit(t *testing.T) {
{
name: "UseOpenTelemetryForInternalMetrics",
expectedMetrics: map[string]metricValue{
metricPrefix + ocPrefix + counterName: {
value: 13,
labels: map[string]string{
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
metricPrefix + otelPrefix + counterName: {
value: 13,
labels: map[string]string{
Expand Down Expand Up @@ -102,14 +91,6 @@ func TestTelemetryInit(t *testing.T) {
name: "DisableHighCardinalityWithOtel",
disableHighCard: true,
expectedMetrics: map[string]metricValue{
metricPrefix + ocPrefix + counterName: {
value: 13,
labels: map[string]string{
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
metricPrefix + otelPrefix + counterName: {
value: 13,
labels: map[string]string{
Expand Down Expand Up @@ -167,14 +148,6 @@ func TestTelemetryInit(t *testing.T) {
},
},
expectedMetrics: map[string]metricValue{
metricPrefix + ocPrefix + counterName: {
value: 13,
labels: map[string]string{
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
metricPrefix + otelPrefix + counterName: {
value: 13,
labels: map[string]string{
Expand Down Expand Up @@ -251,10 +224,7 @@ func TestTelemetryInit(t *testing.T) {
}
}()

v := createTestMetrics(t, mp)
defer func() {
view.Unregister(v)
}()
createTestMetrics(t, mp)

metrics := getMetricsFromPrometheus(t, mp.(*meterProvider).servers[0].Handler)
require.Equal(t, len(tc.expectedMetrics), len(metrics))
Expand All @@ -277,7 +247,7 @@ func TestTelemetryInit(t *testing.T) {
}
}

func createTestMetrics(t *testing.T, mp metric.MeterProvider) *view.View {
func createTestMetrics(t *testing.T, mp metric.MeterProvider) {
// Creates a OTel Go counter
counter, err := mp.Meter("collector_test").Int64Counter(otelPrefix+counterName, metric.WithUnit("ms"))
require.NoError(t, err)
Expand All @@ -290,24 +260,6 @@ func createTestMetrics(t *testing.T, mp metric.MeterProvider) *view.View {
httpExampleCounter, err := mp.Meter(proctelemetry.HTTPInstrumentation).Int64Counter(httpPrefix + counterName)
require.NoError(t, err)
httpExampleCounter.Add(context.Background(), 10, metric.WithAttributes(proctelemetry.HTTPUnacceptableKeyValues...))

// Creates a OpenCensus measure
ocCounter := stats.Int64(ocPrefix+counterName, counterName, stats.UnitDimensionless)
v := &view.View{
Name: ocPrefix + counterName,
Description: ocCounter.Description(),
Measure: ocCounter,
Aggregation: view.Sum(),
}
err = view.Register(v)
require.NoError(t, err)

stats.Record(context.Background(), stats.Int64(ocPrefix+counterName, counterName, stats.UnitDimensionless).M(13))

// Forces a flush for the view data.
_, _ = view.RetrieveData(ocPrefix + counterName)

return v
}

func getMetricsFromPrometheus(t *testing.T, handler http.Handler) map[string]*io_prometheus_client.MetricFamily {
Expand Down

0 comments on commit eb21f31

Please sign in to comment.