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

[receiver/webhookevent] Enable component #23239

Merged
merged 12 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
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
20 changes: 20 additions & 0 deletions .chloggen/webhookevent-enable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Mark the component as Alpha and add to `component.go`

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [18101]

# (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:
6 changes: 5 additions & 1 deletion cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/fatih/structtag v1.2.0
github.com/google/uuid v1.3.0
github.com/open-telemetry/opentelemetry-collector-contrib v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver v0.79.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.79.0
Expand Down Expand Up @@ -450,6 +450,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.16.5 // indirect
Expand Down Expand Up @@ -513,6 +514,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters v0.79.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver v0.79.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver v0.79.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
Expand Down Expand Up @@ -1044,6 +1046,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcent

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver => ../../receiver/windowsperfcountersreceiver
Expand Down
1 change: 1 addition & 0 deletions cmd/configschema/go.sum

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

2 changes: 2 additions & 0 deletions cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ receivers:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snmpreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0
Expand Down Expand Up @@ -401,6 +402,7 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver => ../../receiver/cloudflarereceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusexecreceiver => ../../receiver/prometheusexecreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver => ../../receiver/windowseventlogreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver => ../../receiver/webhookeventreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver => ../../extension/observer/ecsobserver
# see https://github.com/mattn/go-ieproxy/issues/45
- github.com/mattn/go-ieproxy => github.com/mattn/go-ieproxy v0.0.1
Expand Down
2 changes: 2 additions & 0 deletions cmd/otelcontribcol/components.go

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

4 changes: 4 additions & 0 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.79.0
Expand Down Expand Up @@ -453,6 +454,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.16.5 // indirect
Expand Down Expand Up @@ -1078,6 +1080,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prome

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver => ../../extension/observer/ecsobserver

replace github.com/mattn/go-ieproxy => github.com/mattn/go-ieproxy v0.0.1
Expand Down
1 change: 1 addition & 0 deletions cmd/otelcontribcol/go.sum

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

9 changes: 9 additions & 0 deletions cmd/otelcontribcol/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver"
)

func TestDefaultReceivers(t *testing.T) {
Expand Down Expand Up @@ -400,6 +401,14 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "wavefront",
skipLifecyle: true, // Depends on carbon receiver to be running correctly
},
{
receiver: "webhookevent",
getConfigFn: func() component.Config {
cfg := rcvrFactories["webhookevent"].CreateDefaultConfig().(*webhookeventreceiver.Config)
cfg.Endpoint = "127.0.0.1:8088"
return cfg
},
},
{
receiver: "windowseventlog",
skipLifecyle: true, // Requires a running windows process
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.79.0
Expand Down Expand Up @@ -434,6 +435,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.16.5 // indirect
Expand Down Expand Up @@ -1051,6 +1053,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavef

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver => ./receiver/zipkinreceiver
Expand Down
1 change: 1 addition & 0 deletions go.sum

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

2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver"
Expand Down Expand Up @@ -291,6 +292,7 @@ func Components() (otelcol.Factories, error) {
sshcheckreceiver.NewFactory(),
statsdreceiver.NewFactory(),
wavefrontreceiver.NewFactory(),
webhookeventreceiver.NewFactory(),
windowseventlogreceiver.NewFactory(),
windowsperfcountersreceiver.NewFactory(),
zookeeperreceiver.NewFactory(),
Expand Down
32 changes: 29 additions & 3 deletions receiver/webhookeventreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,37 @@
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development]: logs |
| Stability | [alpha]: logs |
| Distributions | [] |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
<!-- end autogenerated section -->

The Webhook Event receiver is meantWebhook Event to act as a generally available push based receiver for any webhook style data source.
The Webhook Event Receiver is a push based event collector component meant to act as a generally available receiver for any webhook style data source. It is designed to work alongside other pipeline components
like the [transform processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor) to allow the ingestion of generic events as logs into the opentelemetry
collector.

## Configuration

The following settings are required:

* `endpoint` (no default): The endpoint where you may point your webhook to emit events to

The following settings are optional:

* `path` (default: '/events'): Path where the receiver instance will accept events
* `health_path` (default: '/health_check'): Path available for checking receiver status
* `read_timeout` (default: '500ms'): Maximum wait time while attempting to read a received event
* `write_timeout` (default: '500ms'): Maximum wait time while attempting to write a response

Example:
```yaml
receivers:
webhookevent:
endpoint: localhost:8088
read_timeout: "500ms"
path: "eventsource/receiver"
health_path: "eventreceiver/healthcheck"
```
The full list of settings exposed for this receiver are documented [here](./config.go) with a detailed sample configuration [here](./testdata/config.yaml)

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

4 changes: 2 additions & 2 deletions receiver/webhookeventreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ type: webhookevent
status:
class: receiver
stability:
development: [logs]
distributions:
alpha: [logs]
distributions:

8 changes: 7 additions & 1 deletion receiver/webhookeventreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ func (er *eventReceiver) Start(_ context.Context, host component.Host) error {

// Shutdown function manages receiver shutdown tasks. part of the receiver.Logs interface.
func (er *eventReceiver) Shutdown(_ context.Context) error {
err := er.server.Close()
var err error

// server must exist to be closed.
if er.server != nil {
err = er.server.Close()
}

shalper2 marked this conversation as resolved.
Show resolved Hide resolved
er.shutdownWG.Wait()
return err
}
Expand Down