Skip to content

Commit

Permalink
[chore] update solace receiver to use mdatagen (open-telemetry#33582)
Browse files Browse the repository at this point in the history
This updates the code that was using OpenCensus to use mdatagen + otel

Fixes open-telemetry#33468

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten authored and martin-majlis-s1 committed Jun 24, 2024
1 parent 0cf9240 commit ca91220
Show file tree
Hide file tree
Showing 19 changed files with 1,410 additions and 588 deletions.
111 changes: 111 additions & 0 deletions receiver/solacereceiver/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# solace

## Internal Telemetry

The following telemetry is emitted by this component.

### solacereceiver_dropped_egress_spans

Number of dropped egress spans

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_dropped_span_messages

Number of dropped span messages

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_failed_reconnections

Number of failed broker reconnections

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_fatal_unmarshalling_errors

Number of fatal message unmarshalling errors

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_need_upgrade

Indicates with value 1 that receiver requires an upgrade and is not compatible with messages received from a broker

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Int |

### solacereceiver_received_span_messages

Number of received span messages

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_receiver_flow_control_recent_retries

Most recent/current retry count when flow controlled

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Int |

### solacereceiver_receiver_flow_control_status

Indicates the flow control status of the receiver. 0 = not flow controlled, 1 = currently flow controlled

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Int |

### solacereceiver_receiver_flow_control_total

Number of times the receiver instance became flow controlled

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_receiver_flow_control_with_single_successful_retry

Number of times the receiver instance became flow controlled and resolved situations after the first retry

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_receiver_status

Indicates the status of the receiver as an enum. 0 = starting, 1 = connecting, 2 = connected, 3 = disabled (often paired with needs_upgrade), 4 = terminating, 5 = terminated

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Int |

### solacereceiver_recoverable_unmarshalling_errors

Number of recoverable message unmarshalling errors

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |

### solacereceiver_reported_spans

Number of reported spans

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |
36 changes: 22 additions & 14 deletions receiver/solacereceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
sdkmetric "go.opentelemetry.io/otel/sdk/metric"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/solacereceiver/internal/metadata"
)
Expand Down Expand Up @@ -68,17 +68,27 @@ func TestCreateTracesReceiverBadConfigIncompleteAuth(t *testing.T) {
}

func TestCreateTracesReceiverBadMetrics(t *testing.T) {
// register a metric first with the same name
statName := "solacereceiver/primary/failed_reconnections"
stat := stats.Int64(statName, "", stats.UnitDimensionless)
err := view.Register(&view.View{
Name: buildReceiverCustomMetricName(statName),
Description: "some description",
Measure: stat,
Aggregation: view.Sum(),
})
set := receivertest.NewNopSettings()
set.ID = component.MustNewIDWithName("solace", "factory")
// the code here sets up a custom meter provider
// to trigger the error condition required for this test
metricExp, err := stdoutmetric.New()
require.NoError(t, err)

provider := sdkmetric.NewMeterProvider(
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(metricExp)),
sdkmetric.WithView(sdkmetric.NewView(
sdkmetric.Instrument{
Name: "solacereceiver_failed_reconnections",
},
sdkmetric.Stream{
Aggregation: sdkmetric.AggregationLastValue{},
},
)),
)
defer func() {
require.NoError(t, provider.Shutdown(context.Background()))
}()
set.TelemetrySettings.MeterProvider = provider
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
factory := NewFactory()
Expand All @@ -87,8 +97,6 @@ func TestCreateTracesReceiverBadMetrics(t *testing.T) {
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "primary").String())
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))
set := receivertest.NewNopSettings()
set.ID = component.MustNewIDWithName("solace", "factory")
receiver, err := factory.CreateTracesReceiver(
context.Background(),
set,
Expand Down
76 changes: 76 additions & 0 deletions receiver/solacereceiver/generated_component_telemetry_test.go

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

2 changes: 1 addition & 1 deletion receiver/solacereceiver/generated_package_test.go

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

7 changes: 3 additions & 4 deletions receiver/solacereceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ go 1.21.0
require (
github.com/Azure/go-amqp v1.0.5
github.com/stretchr/testify v1.9.0
go.opencensus.io v0.24.0
go.opentelemetry.io/collector/component v0.103.0
go.opentelemetry.io/collector/config/configopaque v1.10.0
go.opentelemetry.io/collector/config/configtelemetry v0.103.0
go.opentelemetry.io/collector/config/configtls v0.103.0
go.opentelemetry.io/collector/confmap v0.103.0
go.opentelemetry.io/collector/consumer v0.103.0
go.opentelemetry.io/collector/pdata v1.10.0
go.opentelemetry.io/collector/receiver v0.103.0
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.27.0
go.opentelemetry.io/otel/metric v1.27.0
go.opentelemetry.io/otel/sdk/metric v1.27.0
go.opentelemetry.io/otel/trace v1.27.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
Expand All @@ -33,7 +35,6 @@ require (
github.com/go-logr/stdr v1.2.2 // 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/hashicorp/go-version v1.7.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -49,11 +50,9 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.103.0 // indirect
go.opentelemetry.io/collector/featuregate v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.27.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
Expand Down
Loading

0 comments on commit ca91220

Please sign in to comment.