Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/websocketprocessor] add websocket processor skeleton #20883

Merged
merged 4 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[processor/websocketprocessor] add skeleton and initial README
  • Loading branch information
pmcollins committed May 15, 2023
commit 7507c5cb85b169757c048af614a1c73e0ade0694
16 changes: 16 additions & 0 deletions .chloggen/websocket-processor-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: WebSocket processor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add WebSocket processor skeleton

# One or more tracking issues related to the change
issues: [19633]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ processor/spanmetricsprocessor/ @open-telemetry/collect
processor/spanprocessor/ @open-telemetry/collector-contrib-approvers @boostchicken
processor/tailsamplingprocessor/ @open-telemetry/collector-contrib-approvers @jpkrohling
processor/transformprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley
processor/websocketprocessor/ @open-telemetry/collector-contrib-approvers @pmcollins

receiver/azureeventhubreceiver/ @open-telemetry/collector-contrib-approvers @atoulme @djaglowski
receiver/activedirectorydsreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @binaryfissiongames
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ body:
- processor/spanmetrics
- processor/tailsampling
- processor/transform
- processor/websocket
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ body:
- processor/spanmetrics
- processor/tailsampling
- processor/transform
- processor/websocket
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ body:
- processor/spanmetrics
- processor/tailsampling
- processor/transform
- processor/websocket
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
Expand Down
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/processor/websocketprocessor"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/activedirectorydsreceiver"
schedule:
Expand Down
2 changes: 0 additions & 2 deletions cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ processors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor v0.71.0

receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.77.0
Expand Down Expand Up @@ -279,7 +278,6 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8seventsreceiver => ../../receiver/k8seventsreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver => ../../receiver/k8sclusterreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ../../processor/transformprocessor
- github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor => ../../processor/websocketprocessor
- github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor => ../../processor/filterprocessor
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/hostobserver => ../../extension/observer/hostobserver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver => ../../receiver/kafkareceiver
Expand Down
24 changes: 11 additions & 13 deletions cmd/otelcontribcol/components.go

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

1 change: 1 addition & 0 deletions cmd/otelcontribcol/components_test.go

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

5 changes: 1 addition & 4 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/otelcontribcol

go 1.18
go 1.19

require (
github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.77.0
Expand Down Expand Up @@ -93,7 +93,6 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor v0.71.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver v0.77.0
Expand Down Expand Up @@ -837,8 +836,6 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8scl

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ../../processor/transformprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor => ../../processor/websocketprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor => ../../processor/filterprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/hostobserver => ../../extension/observer/hostobserver
Expand Down
1 change: 1 addition & 0 deletions cmd/otelcontribcol/main.go

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

3 changes: 2 additions & 1 deletion cmd/otelcontribcol/main_windows.go

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

3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver v0.77.0
Expand Down Expand Up @@ -878,8 +877,6 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/tail

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ./processor/transformprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor => ./processor/websocketprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver => ./receiver/activedirectorydsreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver => ./receiver/aerospikereceiver
Expand Down
1 change: 1 addition & 0 deletions processor/websocketprocessor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
28 changes: 28 additions & 0 deletions processor/websocketprocessor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Websocket Processor
pmcollins marked this conversation as resolved.
Show resolved Hide resolved

The WebSocket processor, which can be positioned anywhere in a pipeline, allows
data to pass through to the next component. Simultaneously, it makes a portion
of the data accessible to WebSocket clients connecting on a configurable port.
This functionality resembles that of the Unix `tee` command, which enables data
to
flow through while duplicating and redirecting it for inspection.

To avoid overloading clients, the amount of telemetry transmitted via WebSockets
is limited and can be adjusted according to user preferences.

## Config
pmcollins marked this conversation as resolved.
Show resolved Hide resolved

The WebSocket processor has two configurable fields: `port` and `limit`:

- `port`: The port on which the WebSocket processor listens. Optional. Defaults
to `12001`.
- `limit`: The rate limit over the WebSocket in messages per second. Can be a
float or an integer. Optional. Defaults to `1`.

Example configuration:

```yaml
websocket:
port: 12001
limit: 1 # rate limit 1 msg/sec
```
61 changes: 0 additions & 61 deletions processor/websocketprocessor/channelset.go

This file was deleted.

4 changes: 2 additions & 2 deletions processor/websocketprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package websocketprocessor
package websocketprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor"

import (
"go.opentelemetry.io/collector/component"
Expand All @@ -26,7 +26,7 @@ type Config struct {
// Defaults to 12001.
Port int `mapstructure:"port"`
// Limit is a float that indicates the maximum number of messages repeated
// through the websocket by this processor in messages per second.
// through the websocket by this processor in messages per second. Defaults to 1.
Limit rate.Limit `mapstructure:"limit"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@ package websocketprocessor

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
)

func TestChannelset(t *testing.T) {
cs := newChannelSet()
ch := make(chan []byte)
key := cs.add(ch)
go func() {
cs.writeBytes([]byte("hello"))
}()
assert.Eventually(t, func() bool {
return assert.Equal(t, []byte("hello"), <-ch)
}, time.Second, time.Millisecond*10)
cs.closeAndRemove(key)
func TestCreateDefaultConfig(t *testing.T) {
cfg := createDefaultConfig().(*Config)
assert.Equal(t, 12001, cfg.Port)
assert.EqualValues(t, 1, cfg.Limit)
}
3 changes: 1 addition & 2 deletions processor/websocketprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package websocketprocessor
package websocketprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/websocketprocessor"

import (
"go.opentelemetry.io/collector/component"
Expand All @@ -28,6 +28,5 @@ func NewFactory() processor.Factory {
return processor.NewFactory(
typeStr,
createDefaultConfig,
processor.WithMetrics(newProdMetricsProcessor, stability),
)
}
Loading