Skip to content

Commit

Permalink
Add namedpipereceiver (#29320)
Browse files Browse the repository at this point in the history
**Description:**

This adds a new receiver that reads from a named pipe, using the
previously created namedpipeinput stanza operator (#28841). Because that
operator does the majority of the work, this is mostly boilerplate + a
few tests to confirm that it works e2e.

Link to tracking Issue: #27234

**Testing:**

Added a few tests, loading the config, and actually creating a receiver
to verify that it can read logs from the pipe.

**Documentation:**

None, yet.

/cc @djaglowski - where should I add docs for this if any?
  • Loading branch information
sinkingpoint authored Dec 13, 2023
1 parent 447468f commit 97a920d
Show file tree
Hide file tree
Showing 17 changed files with 577 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/namedpipe_receiver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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: namedpipereceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add "namedpipereceiver" that allows ingesting logs over a Named Pipe

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

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ receiver/memcachedreceiver/ @open-telemetry/collect
receiver/mongodbatlasreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/mongodbreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/mysqlreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/namedpipereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/nginxreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/nsxtreceiver/ @open-telemetry/collector-contrib-approvers @dashpole @schmikei
receiver/opencensusreceiver/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers
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 @@ -221,6 +221,7 @@ body:
- receiver/mongodb
- receiver/mongodbatlas
- receiver/mysql
- receiver/namedpipe
- receiver/nginx
- receiver/nsxt
- receiver/opencensus
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 @@ -215,6 +215,7 @@ body:
- receiver/mongodb
- receiver/mongodbatlas
- receiver/mysql
- receiver/namedpipe
- receiver/nginx
- receiver/nsxt
- receiver/opencensus
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 @@ -215,6 +215,7 @@ body:
- receiver/mongodb
- receiver/mongodbatlas
- receiver/mysql
- receiver/namedpipe
- receiver/nginx
- receiver/nsxt
- receiver/opencensus
Expand Down
1 change: 1 addition & 0 deletions receiver/namedpipereceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
39 changes: 39 additions & 0 deletions receiver/namedpipereceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Named Pipe Receiver

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [alpha]: logs |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fnamedpipe%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fnamedpipe) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fnamedpipe%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fnamedpipe) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@djaglowski](https://www.github.com/djaglowski) |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

This receiver supports opening a Unix Named Pipe (aka FIFO), and reading logs from it.

## Prerequisites

Named pipes are only supported on Unix operating systems.


## Configuration

The following settings are required:

- `path`: The path to open the named pipe at.

The following settings are optional:

- `mode`: The mode bits to set on the opened pipe (default: 666)

## Example Configuration

```yaml
receivers:
namedpipe:
path: /tmp/pipe
mode: 0600
```
8 changes: 8 additions & 0 deletions receiver/namedpipereceiver/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

// Package namedpipereceiver implements a receiver that can be used by the
// OpenTelemetry collector to receive logs using the stanza log agent
package namedpipereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/namedpipereceiver"
67 changes: 67 additions & 0 deletions receiver/namedpipereceiver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/namedpipereceiver

go 1.20

require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.89.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.91.0
go.opentelemetry.io/collector/confmap v0.91.0
go.opentelemetry.io/collector/consumer v0.91.0
go.opentelemetry.io/collector/receiver v0.91.0
go.uber.org/zap v1.26.0
)

require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/expr-lang/expr v1.15.7 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/influxdata/go-syslog/v3 v3.0.1-0.20230911200830-875f5bc594a4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
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.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.91.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.91.0 // indirect
go.opentelemetry.io/collector/extension v0.91.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0 // indirect
go.opentelemetry.io/collector/pdata v1.0.0 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza => ../../pkg/stanza

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden
Loading

0 comments on commit 97a920d

Please sign in to comment.