-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add Apache Spark receiver #5318
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
beb7835
Add apachespark receiver
crobert-1 5bfdf39
Add more docker contents
crobert-1 17ea065
Update CHANGELOG.md
crobert-1 522ba58
Fix formatting
crobert-1 5af0a08
Fix golden file test format
crobert-1 11ed17f
rename test file
crobert-1 b3dd491
Ignore scope version in testing
crobert-1 9327511
Merge branch 'main' into add_apache_spark_receiver
crobert-1 93764e0
Merge branch 'main' into add_apache_spark_receiver
crobert-1 66b857f
Update internal/components/components.go
crobert-1 27e817c
Fix fmt error
crobert-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM apache/spark:3.4.0-python3 | ||
|
||
COPY ./long_running.py /opt/spark/examples/src/main/python/long_running.py | ||
RUN chmod +x /opt/spark/examples/src/main/python/long_running.py | ||
|
||
CMD [ "/opt/spark/bin/spark-submit", "/opt/spark/examples/src/main/python/long_running.py" ] | ||
|
||
EXPOSE 4040 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This file was a direct copy from here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Keep the original spark license. | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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://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. | ||
# | ||
# Original source: https://github.com/apache/spark/blob/master/examples/src/main/python/status_api_demo.py | ||
# | ||
# NOTICE: | ||
# Apache Spark | ||
# Copyright 2014 and onwards The Apache Software Foundation. | ||
# | ||
# This product includes software developed at | ||
# The Apache Software Foundation (http://www.apache.org/). | ||
# | ||
|
||
import time | ||
import threading | ||
import queue as Queue | ||
from typing import Any, Callable, List, Tuple | ||
|
||
from pyspark import SparkConf, SparkContext | ||
|
||
|
||
def delayed(seconds: int) -> Callable[[Any], Any]: | ||
def f(x: int) -> int: | ||
time.sleep(seconds) | ||
return x | ||
return f | ||
|
||
|
||
def call_in_background(f: Callable[..., Any], *args: Any) -> Queue.Queue: | ||
result: Queue.Queue = Queue.Queue(1) | ||
t = threading.Thread(target=lambda: result.put(f(*args))) | ||
t.daemon = True | ||
t.start() | ||
return result | ||
|
||
|
||
def main() -> None: | ||
conf = SparkConf().set("spark.ui.showConsoleProgress", "false") | ||
sc = SparkContext(appName="PythonStatusAPIDemo", conf=conf) | ||
|
||
def run() -> List[Tuple[int, int]]: | ||
rdd = sc.parallelize(range(10), 10).map(delayed(2)) | ||
reduced = rdd.map(lambda x: (x, 1)).reduceByKey(lambda x, y: x + y) | ||
return reduced.map(delayed(2)).collect() | ||
|
||
result = call_in_background(run) | ||
status = sc.statusTracker() | ||
while result.empty(): | ||
ids = status.getJobIdsForGroup() | ||
for id in ids: | ||
job = status.getJobInfo(id) | ||
assert job is not None | ||
|
||
print("Job", id, "status: ", job.status) | ||
for sid in job.stageIds: | ||
info = status.getStageInfo(sid) | ||
if info: | ||
print("Stage %d: %d tasks total (%d active, %d complete)" % | ||
(sid, info.numTasks, info.numActiveTasks, info.numCompletedTasks)) | ||
time.sleep(1) | ||
|
||
print("Job results are:", result.get()) | ||
sc.stop() | ||
|
||
|
||
if __name__ == "__main__": | ||
for i in range(100): | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// 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://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. | ||
|
||
//go:build integration | ||
|
||
package tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" | ||
|
||
"github.com/signalfx/splunk-otel-collector/tests/testutils" | ||
) | ||
|
||
const sparkPort = "4040" | ||
|
||
func TestApacheSparkIntegration(t *testing.T) { | ||
testutils.CheckGoldenFile(t, "all_metrics_config.yaml", "all_expected_metrics.yaml", | ||
pmetrictest.IgnoreMetricValues(), | ||
pmetrictest.IgnoreStartTimestamp(), | ||
pmetrictest.IgnoreTimestamp(), | ||
pmetrictest.IgnoreScopeVersion(), | ||
pmetrictest.IgnoreResourceAttributeValue("spark.application.id"), | ||
pmetrictest.IgnoreResourceAttributeValue("spark.application.name"), | ||
pmetrictest.IgnoreMetricAttributeValue("active", "spark.stage.status"), | ||
pmetrictest.IgnoreMetricAttributeValue("complete", "spark.stage.status"), | ||
pmetrictest.IgnoreMetricAttributeValue("failed", "spark.stage.status"), | ||
pmetrictest.IgnoreMetricAttributeValue("pending", "spark.stage.status"), | ||
pmetrictest.IgnoreMetricDataPointsOrder(), | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This file was a direct copy from here.