Skip to content

Commit

Permalink
[receiver/googlecloudpubsub] Turn noisy warn in reset metric (#37571)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanboxel committed Jan 30, 2025
1 parent 54896e7 commit 04b008d
Show file tree
Hide file tree
Showing 14 changed files with 416 additions and 179 deletions.
17 changes: 17 additions & 0 deletions .chloggen/pubsubreceiver-turn-warn-into-reset-metric.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
change_type: enhancement

component: googlecloudpubsubreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Turn noisy `warn` log about Pub/Sub servers into `debug`, and turn the reset count into a metric

issues: [37571]

subtext: |
The receiver uses the Google Cloud Pub/Sub StreamingPull API and keeps a open connection. The Pub/Sub servers
recurrently close the connection after a time period to avoid a long-running sticky connection. Before the
receiver logged `warn` log lines everytime this happened. These log lines are moved to debug so that fleets with
lots of collectors with the receiver don't span logs at warn level. To keep track of the resets, whenever a
connection reset happens a `otelcol_receiver_googlecloudpubsub_stream_restarts` metric is increased by one.
change_logs: [user]
20 changes: 20 additions & 0 deletions receiver/googlecloudpubsubreceiver/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# googlecloudpubsub

## Internal Telemetry

The following telemetry is emitted by this component.

### otelcol_receiver.googlecloudpubsub.stream_restarts

Number of times the stream (re)starts due to a Pub/Sub servers connection close

The receiver uses the Google Cloud Pub/Sub StreamingPull API and keeps a open connection. The Pub/Sub servers
recurrently close the connection after a time period to avoid a long-running sticky connection. This metric
counts the number of the resets that occurred during the lifetime of the container.


| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| 1 | Sum | Int | true |
10 changes: 5 additions & 5 deletions receiver/googlecloudpubsubreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ func (factory *pubsubReceiverFactory) CreateDefaultConfig() component.Config {
return &Config{}
}

func (factory *pubsubReceiverFactory) ensureReceiver(params receiver.Settings, config component.Config) (*pubsubReceiver, error) {
func (factory *pubsubReceiverFactory) ensureReceiver(settings receiver.Settings, config component.Config) (*pubsubReceiver, error) {
receiver := factory.receivers[config.(*Config)]
if receiver != nil {
return receiver, nil
}
rconfig := config.(*Config)
obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
ReceiverID: params.ID,
ReceiverID: settings.ID,
Transport: reportTransport,
ReceiverCreateSettings: params,
ReceiverCreateSettings: settings,
})
if err != nil {
return nil, err
}
receiver = &pubsubReceiver{
logger: params.Logger,
settings: settings,
obsrecv: obsrecv,
userAgent: strings.ReplaceAll(rconfig.UserAgent, "{{version}}", params.BuildInfo.Version),
userAgent: strings.ReplaceAll(rconfig.UserAgent, "{{version}}", settings.BuildInfo.Version),
config: rconfig,
}
factory.receivers[config.(*Config)] = receiver
Expand Down
48 changes: 23 additions & 25 deletions receiver/googlecloudpubsubreceiver/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/googlecloudpubsubreceiver

go 1.22.0
go 1.22.7

require (
cloud.google.com/go/logging v1.13.0
cloud.google.com/go/pubsub v1.45.3
cloud.google.com/go/pubsub v1.46.0
github.com/google/go-cmp v0.6.0
github.com/googleapis/gax-go/v2 v2.14.1
github.com/iancoleman/strcase v0.3.0
Expand All @@ -20,31 +20,34 @@ require (
go.opentelemetry.io/collector/pdata v1.24.1-0.20250130000211-c119b2a55eb4
go.opentelemetry.io/collector/receiver v0.118.1-0.20250130000211-c119b2a55eb4
go.opentelemetry.io/collector/receiver/receivertest v0.118.1-0.20250130000211-c119b2a55eb4
go.opentelemetry.io/otel v1.34.0
go.opentelemetry.io/otel/metric v1.34.0
go.opentelemetry.io/otel/sdk/metric v1.34.0
go.opentelemetry.io/otel/trace v1.34.0
go.uber.org/goleak v1.3.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
google.golang.org/api v0.219.0
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576
google.golang.org/genproto v0.0.0-20250127172529-29210b9bc287
google.golang.org/genproto/googleapis/api v0.0.0-20250127172529-29210b9bc287
google.golang.org/grpc v1.70.0
google.golang.org/protobuf v1.36.4
)

require (
cloud.google.com/go v0.117.0 // indirect
cloud.google.com/go/auth v0.14.0 // indirect
cloud.google.com/go v0.118.1 // indirect
cloud.google.com/go/auth v0.14.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.2.2 // indirect
cloud.google.com/go/longrunning v0.6.2 // indirect
cloud.google.com/go/iam v1.3.1 // indirect
cloud.google.com/go/longrunning v0.6.4 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
Expand All @@ -57,34 +60,29 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
go.einride.tech/aip v0.68.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.einride.tech/aip v0.68.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/collector/config/configretry v1.24.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/config/configretry v1.24.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.118.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.118.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/extension v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/extension/xextension v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/featuregate v1.24.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/extension/xextension v0.118.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/featuregate v1.24.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/pipeline v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/collector/receiver/xreceiver v0.118.1-0.20250130000211-c119b2a55eb4 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/collector/pipeline v0.118.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/collector/receiver/xreceiver v0.118.1-0.20250123125445-24f88da7b583 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250124145028-65684f501c47 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250127172529-29210b9bc287 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading

0 comments on commit 04b008d

Please sign in to comment.