Skip to content

Commit

Permalink
Initial contribution of remote tap extension (open-telemetry#27477)
Browse files Browse the repository at this point in the history
**Description:**
Adds the basis of a new extension, the remote ~observer~ tap extension,
to be used to display the contents of the data observed via remote
observer processors.

This PR deals only with the structure and required files related to the
extension.

**Link to tracking Issue:**
open-telemetry#19634

**Testing:**
N/A

**Documentation:**
README

---------

Co-authored-by: Pablo Collins <[email protected]>
  • Loading branch information
2 people authored and jmsnll committed Nov 12, 2023
1 parent 954da60 commit 3d159e8
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 10 deletions.
27 changes: 27 additions & 0 deletions .chloggen/new_extension_remotetap.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: remotetapextension

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add a new extension, remotetapextension to use with the remoteobserverprocessor processors.

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

# (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 @@ -111,6 +111,7 @@ extension/observer/k8sobserver/ @open-te
extension/oidcauthextension/ @open-telemetry/collector-contrib-approvers @jpkrohling
extension/opampextension/ @open-telemetry/collector-contrib-approvers @portertech @evan-bradley @tigrannajaryan
extension/pprofextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy
extension/remotetapextension/ @open-telemetry/collector-contrib-approvers @atoulme
extension/sigv4authextension/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @erichsueh3
extension/storage/ @open-telemetry/collector-contrib-approvers @dmitryax @atoulme @djaglowski
extension/storage/dbstorage/ @open-telemetry/collector-contrib-approvers @dmitryax @atoulme
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 @@ -103,6 +103,7 @@ body:
- extension/oidcauth
- extension/opamp
- extension/pprof
- extension/remotetap
- extension/sigv4auth
- extension/storage
- extension/storage/dbstorage
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 @@ -97,6 +97,7 @@ body:
- extension/oidcauth
- extension/opamp
- extension/pprof
- extension/remotetap
- extension/sigv4auth
- extension/storage
- extension/storage/dbstorage
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 @@ -97,6 +97,7 @@ body:
- extension/oidcauth
- extension/opamp
- extension/pprof
- extension/remotetap
- extension/sigv4auth
- extension/storage
- extension/storage/dbstorage
Expand Down
20 changes: 10 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/cmd/telemetrygen"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/confmap/provider/s3provider"
schedule:
Expand Down Expand Up @@ -297,6 +292,16 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/extension/encoding/jsonlogencodingextension"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/extension/encoding/otlpencodingextension"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/extension/headerssetterextension"
schedule:
Expand Down Expand Up @@ -357,11 +362,6 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/extension/opampextension"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/extension/pprofextension"
schedule:
Expand Down
1 change: 1 addition & 0 deletions extension/remotetapextension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
31 changes: 31 additions & 0 deletions extension/remotetapextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Remote Tap Extension

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

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

This extension runs as a Web server that loads the remote observers that are registered against it.

It allows users of the collectors to visualize data going through pipelines.

The following settings are required:

- `endpoint` (default = localhost:11000): The endpoint in which the web server will
be listening to. Use localhost:<port> to make it available only locally, or
":<port>" to make it available on all network interfaces.

Example:
```yaml

extensions:
remoteobserver:
```
The full list of settings exposed for this exporter are documented [here](./config.go).
21 changes: 21 additions & 0 deletions extension/remotetapextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package remotetapextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension"

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
)

type Config struct {
confighttp.HTTPServerSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

func createDefaultConfig() component.Config {
return &Config{
HTTPServerSettings: confighttp.HTTPServerSettings{
Endpoint: "127.0.0.1:11000",
},
}
}
8 changes: 8 additions & 0 deletions extension/remotetapextension/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 remotetapextension implements an extension that exposes the golang
// remoteobserver processor websockets through a Web interface.
package remotetapextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension"
53 changes: 53 additions & 0 deletions extension/remotetapextension/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package remotetapextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension"

import (
"context"
"embed"
"errors"
"io/fs"
"net/http"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)

//go:embed http/*
var httpFS embed.FS

type remoteObserverExtension struct {
config *Config
settings extension.CreateSettings
server *http.Server
}

func (s *remoteObserverExtension) Start(_ context.Context, host component.Host) error {

htmlContent, err := fs.Sub(httpFS, "html")
if err != nil {
return err
}
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.FS(htmlContent)))
s.server, err = s.config.HTTPServerSettings.ToServer(host, s.settings.TelemetrySettings, mux)
if err != nil {
return err
}

go func() {
err := s.server.ListenAndServe()
if err != nil && !errors.Is(err, http.ErrServerClosed) {
_ = s.settings.TelemetrySettings.ReportComponentStatus(component.NewFatalErrorEvent(err))
}
}()
return nil
}

func (s *remoteObserverExtension) Shutdown(_ context.Context) error {
if s.server == nil {
return nil
}
return s.server.Close()
}
26 changes: 26 additions & 0 deletions extension/remotetapextension/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package remotetapextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension/internal/metadata"
)

func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
component.StabilityLevelDevelopment,
)
}

func createExtension(_ context.Context, settings extension.CreateSettings, config component.Config) (extension.Extension, error) {
return &remoteObserverExtension{config: config.(*Config), settings: settings}, nil
}
50 changes: 50 additions & 0 deletions extension/remotetapextension/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension

go 1.20

require (
go.opentelemetry.io/collector/component v0.88.1-0.20231026220224-6405e152a2d9
go.opentelemetry.io/collector/config/confighttp v0.88.1-0.20231026220224-6405e152a2d9
go.opentelemetry.io/collector/extension v0.88.1-0.20231026220224-6405e152a2d9
)

require (
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.17.2 // 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/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/rs/cors v1.10.1 // indirect
go.opentelemetry.io/collector v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configauth v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configcompression v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configopaque v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/configtls v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/config/internal v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/confmap v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/extension/auth v0.88.1-0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0017.0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/collector/pdata v1.0.0-rcv0017.0.20231026220224-6405e152a2d9 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.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
)
Loading

0 comments on commit 3d159e8

Please sign in to comment.