Skip to content

Commit

Permalink
Update after PR
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Mirabella <[email protected]>
  • Loading branch information
alexvanboxel and Aneurysm9 committed Jun 2, 2021
1 parent 6169930 commit 7e4963e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions receiver/googlecloudpubsubreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This receiver gets OTLP messages from a Google Cloud [Pubsub](https://cloud.goog

The following configuration options are supported:

* `project` (Required): The Google Cloud Project of the client connects to.
* `project` (Optional): The Google Cloud Project of the client connects to.
* `subscription` (Required): The subscription name to receive OTLP data from. The subscription name should be a
fully qualified resource name (eg: `projects/otel-project/subscriptions/otlp`).
* `encoding` (Options): The encoding that will be used to received data from the subscription. This can either be
* `encoding` (Optional): The encoding that will be used to received data from the subscription. This can either be
`otlp_proto_trace`, `otlp_proto_metric`, `otlp_proto_log`, or `raw_text` (see `encoding`)

```yaml
Expand All @@ -23,8 +23,8 @@ receivers:
## Encoding

You should not need to set the encoding of the subscription as the receiver will try to discover the type of the data
by looking at the `ce-type` as `ce-datacontenttype` attributes of the message. Only when those attributes are not set
the `encoding` field in the configuration should be set.
by looking at the `ce-type` and `ce-datacontenttype` attributes of the message. Only when those attributes are not set
must the `encoding` field in the configuration be set.

| ce-type] | ce-datacontenttype | encoding | description |
| --- | --- | --- | --- |
Expand All @@ -43,7 +43,7 @@ message, making it a convenient way to ingest log lines from Pubsub.

## Pubsub subscription

The Google Cloud [Pubsub](https://cloud.google.com/pubsub) receiver doesn't automatic create subscriptions,
The Google Cloud [Pubsub](https://cloud.google.com/pubsub) receiver doesn't automatically create subscriptions,
it expects the subscription to be created upfront. Security wise it's best to give the collector its own
service account and give the subscription `Pub/Sub Subscriber` permission.

Expand Down
8 changes: 4 additions & 4 deletions receiver/googlecloudpubsubreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

var subscriptionMatcher = regexp.MustCompile(`projects/[a-z][a-z0-9\-]*/subscriptions/.*`)
var subscriptionMatcher = regexp.MustCompile(`projects/[a-z][a-z0-9\-]*/subscriptions/`)

type Config struct {
config.ReceiverSettings `mapstructure:",squash"`
Expand All @@ -34,7 +34,7 @@ type Config struct {
// Override of the Pubsub endpoint
Endpoint string `mapstructure:"endpoint"`
// Only has effect if Endpoint is not ""
UseInsecure bool `mapstructure:"use_insecure"`
Insecure bool `mapstructure:"insecure"`
// Timeout for all API calls. If not set, defaults to 12 seconds.
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.

Expand Down Expand Up @@ -72,7 +72,7 @@ func (config *Config) validateForTrace() error {
case "":
case "otlp_proto_trace":
default:
return fmt.Errorf("log format should be either otlp_proto, raw_string or raw_json")
return fmt.Errorf("if specified, trace encoding can be be only otlp_proto_trace")
}
return nil
}
Expand All @@ -86,7 +86,7 @@ func (config *Config) validateForMetric() error {
case "":
case "otlp_proto_metric":
default:
return fmt.Errorf("log format should be either otlp_proto, raw_string or raw_json")
return fmt.Errorf("if specified, trace encoding can be be only otlp_proto_metric")
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/googlecloudpubsubreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestLoadConfig(t *testing.T) {
customConfig.ProjectID = "my-project"
customConfig.UserAgent = "opentelemetry-collector-contrib {{version}}"
customConfig.Endpoint = "test-endpoint"
customConfig.UseInsecure = true
customConfig.Insecure = true
customConfig.TimeoutSettings = exporterhelper.TimeoutSettings{
Timeout: 20 * time.Second,
}
Expand Down
1 change: 0 additions & 1 deletion receiver/googlecloudpubsubreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"go.uber.org/zap"
)

// https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#streamingpullrequest
type pubsubReceiver struct {
logger *zap.Logger
tracesConsumer consumer.Traces
Expand Down
2 changes: 1 addition & 1 deletion receiver/googlecloudpubsubreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ receivers:
project: my-project
endpoint: test-endpoint
user_agent: opentelemetry-collector-contrib {{version}}
use_insecure: true
insecure: true
timeout: 20s
subscription: projects/my-project/subscriptions/otlp-subscription

Expand Down

0 comments on commit 7e4963e

Please sign in to comment.