Skip to content

Commit

Permalink
[receiver/apachespark] Outline apache spark receiver component (#21971)
Browse files Browse the repository at this point in the history
* [receiver/apachespark] Outline apache spark receiver component
  • Loading branch information
mrsillydog committed May 16, 2023
1 parent 6f1b6b9 commit 51d1056
Show file tree
Hide file tree
Showing 26 changed files with 929 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-apache-spark-metric-receiver.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: apachesparkreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: adds the apachesparkreceiver metric receiver

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

# (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
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ receiver/azureeventhubreceiver/ @open-telemetry/collect
receiver/activedirectorydsreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @binaryfissiongames
receiver/aerospikereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @antonblock
receiver/apachereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/apachesparkreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @Caleb-Hurshman @mrsillydog
receiver/awscloudwatchreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/awscontainerinsightreceiver/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @pxaws
receiver/awsecscontainermetricsreceiver/ @open-telemetry/collector-contrib-approvers @Aneurysm9
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 @@ -148,6 +148,7 @@ body:
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
- receiver/apachespark
- receiver/awscloudwatch
- receiver/awscontainerinsight
- receiver/awsecscontainermetrics
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 @@ -142,6 +142,7 @@ body:
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
- receiver/apachespark
- receiver/awscloudwatch
- receiver/awscontainerinsight
- receiver/awsecscontainermetrics
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 @@ -142,6 +142,7 @@ body:
- receiver/activedirectoryds
- receiver/aerospike
- receiver/apache
- receiver/apachespark
- receiver/awscloudwatch
- receiver/awscontainerinsight
- receiver/awsecscontainermetrics
Expand Down
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,11 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/apachesparkreceiver"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/awscloudwatchreceiver"
schedule:
Expand Down Expand Up @@ -1097,8 +1102,3 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/windowseventlogreceiver"
schedule:
interval: "weekly"
day: "wednesday"
3 changes: 3 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.77.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.77.0 // indirect
Expand Down Expand Up @@ -884,6 +885,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aeros

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => ../../receiver/awscontainerinsightreceiver
Expand Down
3 changes: 2 additions & 1 deletion cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ receivers:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.77.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.77.0
Expand Down Expand Up @@ -352,6 +353,7 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/expvarreceiver => ../../receiver/expvarreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver => ../../receiver/apachereceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver => ../../receiver/apachesparkreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarder => ../../extension/httpforwarder
- github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter => ../../exporter/elasticsearchexporter
- github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter => ../../exporter/awscloudwatchlogsexporter
Expand Down Expand Up @@ -394,4 +396,3 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ../../connector/spanmetricsconnector
- github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37
- github.com/outcaste-io/ristretto v0.2.0 => github.com/outcaste-io/ristretto v0.2.1

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.

3 changes: 3 additions & 0 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ require (
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
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.77.0
Expand Down Expand Up @@ -984,6 +985,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/expva

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter => ../../exporter/elasticsearchexporter
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcontribcol/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func TestDefaultReceivers(t *testing.T) {
{
receiver: "apache",
},
{
receiver: "apachespark",
},
{
receiver: "awscloudwatch",
getConfigFn: func() component.Config {
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ require (
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
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.77.0
Expand Down Expand Up @@ -883,6 +884,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aeros

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

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

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => ./receiver/awscontainerinsightreceiver
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver"
Expand Down Expand Up @@ -226,6 +227,7 @@ func Components() (otelcol.Factories, error) {
activedirectorydsreceiver.NewFactory(),
aerospikereceiver.NewFactory(),
apachereceiver.NewFactory(),
apachesparkreceiver.NewFactory(),
awscontainerinsightreceiver.NewFactory(),
awsecscontainermetricsreceiver.NewFactory(),
awsfirehosereceiver.NewFactory(),
Expand Down
1 change: 1 addition & 0 deletions receiver/apachesparkreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
50 changes: 50 additions & 0 deletions receiver/apachesparkreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Apache Spark Receiver

| Status | |
| ------------------------ | ---------------- |
| Stability | [development] |
| Supported pipeline types | metrics |
| Distributions | [contrib] |

This receiver fetches metrics for an Apache Spark cluster through the Apache Spark REST API - specifically, the /metrics/json, /api/v1/applications/[app-id]/stages, /api/v1/applications/[app-id]/executors, and /api/v1/applications/[app-id]/jobs endpoints.

## Purpose

The purpose of this component is to allow monitoring of Apache Spark clusters and the applications running on them through the collection of performance metrics like memory utilization, CPU utilization, shuffle operations, garbage collection time, I/O operations, and more.

## Prerequisites

This receiver supports Apache Spark versions:

- 3.3.2+

## Configuration

These configuration options are for connecting to an Apache Spark application.

The following settings are optional:

- `collection_interval`: (default = `60s`): This receiver collects metrics on an interval. This value must be a string readable by Golang's [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`.
- `endpoint`: (default = `http:https://localhost:4040`): Apache Spark endpoint to connect to in the form of `[http][:https://]{host}[:{port}]`
- `whitelisted_application_names`: An array of Spark application names for which metrics should be collected. If no application names are specified, metrics will be collected for all Spark applications running on the cluster at the specified endpoint.

### Example Configuration

```yaml
receivers:
apachespark:
collection_interval: 60s
endpoint: http:https://localhost:4040
whitelisted_application_names:
- PythonStatusAPIDemo
- PythonLR
```

The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml).

## Metrics

Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml)

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
49 changes: 49 additions & 0 deletions receiver/apachesparkreceiver/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apachesparkreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver"

import (
"errors"
"net/url"
"time"

"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/receiver/scraperhelper"
)

const (
defaultCollectionInterval = time.Minute
defaultEndpoint = "http:https://localhost:4040"
)

var (
errInvalidEndpoint = errors.New("'endpoint' must be in the form of <scheme>:https://<hostname>:<port>")
)

// Config defines the configuration for the various elements of the receiver agent.
type Config struct {
scraperhelper.ScraperControllerSettings `mapstructure:",squash"`
confighttp.HTTPClientSettings `mapstructure:",squash"`
WhitelistedApplicationNames []string `mapstructure:"whitelisted_application_names"`
}

// Validate validates missing and invalid configuration fields.
func (cfg *Config) Validate() error {
_, parseErr := url.Parse(cfg.Endpoint)
if parseErr != nil {
return errInvalidEndpoint
}
return nil
}
56 changes: 56 additions & 0 deletions receiver/apachesparkreceiver/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apachesparkreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver"

import (
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/config/confighttp"
)

func TestValidate(t *testing.T) {
testCases := []struct {
desc string
cfg *Config
expectedErr error
}{
{
desc: "default config",
cfg: &Config{},
expectedErr: nil,
},
{
desc: "invalid endpoint",
cfg: &Config{
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: "invalid:https://endpoint 12efg",
},
},
expectedErr: errInvalidEndpoint,
},
}

for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
actualErr := tc.cfg.Validate()
if tc.expectedErr != nil {
require.EqualError(t, actualErr, tc.expectedErr.Error())
} else {
require.NoError(t, actualErr)
}
})
}
}
15 changes: 15 additions & 0 deletions receiver/apachesparkreceiver/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apachesparkreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachesparkreceiver"
Loading

0 comments on commit 51d1056

Please sign in to comment.