Skip to content

Commit

Permalink
update unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten committed Jul 31, 2024
1 parent 7432fc8 commit a7c14f4
Showing 1 changed file with 5 additions and 55 deletions.
60 changes: 5 additions & 55 deletions service/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/internal/globalgates"
"go.opentelemetry.io/collector/internal/testutil"
semconv "go.opentelemetry.io/collector/semconv/v1.18.0"
"go.opentelemetry.io/collector/service/internal/proctelemetry"
Expand All @@ -41,12 +39,11 @@ func TestTelemetryInit(t *testing.T) {
}

for _, tc := range []struct {
name string
disableHighCard bool
disableCensusBridge bool
expectedMetrics map[string]metricValue
extendedConfig bool
cfg *telemetry.Config
name string
disableHighCard bool
expectedMetrics map[string]metricValue
extendedConfig bool
cfg *telemetry.Config
}{
{
name: "UseOpenTelemetryForInternalMetrics",
Expand Down Expand Up @@ -190,55 +187,8 @@ func TestTelemetryInit(t *testing.T) {
},
},
},
{
name: "DisableOpenCensusBridge",
expectedMetrics: map[string]metricValue{
metricPrefix + otelPrefix + counterName: {
value: 13,
labels: map[string]string{
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
metricPrefix + grpcPrefix + counterName: {
value: 11,
labels: map[string]string{
"net_sock_peer_addr": "",
"net_sock_peer_name": "",
"net_sock_peer_port": "",
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
metricPrefix + httpPrefix + counterName: {
value: 10,
labels: map[string]string{
"net_host_name": "",
"net_host_port": "",
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
"target_info": {
value: 0,
labels: map[string]string{
"service_name": "otelcol",
"service_version": "latest",
"service_instance_id": testInstanceID,
},
},
},
disableCensusBridge: true,
},
} {
t.Run(tc.name, func(t *testing.T) {
require.NoError(t, featuregate.GlobalRegistry().Set(globalgates.DisableOpenCensusBridge.ID(), tc.disableCensusBridge))
t.Cleanup(func() {
require.NoError(t, featuregate.GlobalRegistry().Set(globalgates.DisableOpenCensusBridge.ID(), true))
})
if tc.extendedConfig {
tc.cfg.Metrics.Readers = []config.MetricReader{
{
Expand Down

0 comments on commit a7c14f4

Please sign in to comment.