Skip to content

Conversation

@nkarpov
Copy link
Contributor

@nkarpov nkarpov commented Jul 22, 2019

What changes were proposed in this pull request?

Today all registered metric sources are reported to GraphiteSink with no filtering mechanism, although the codahale project does support it.

GraphiteReporter (ScheduledReporter) from the codahale project requires you implement and supply the MetricFilter interface (there is only a single implementation by default in the codahale project, MetricFilter.ALL).

Propose to add an additional regex config to match and filter metrics to the GraphiteSink

How was this patch tested?

Included a GraphiteSinkSuite that tests:

  1. Absence of regex filter (existing default behavior maintained)
  2. Presence of regex=<regexexpr> correctly filters metric keys

@dongjoon-hyun
Copy link
Member

ok to test

@dongjoon-hyun
Copy link
Member

Thank you for your first contribution, @nkarpov . Could you elaborate more about the verification steps in your PR?

@SparkQA
Copy link

SparkQA commented Jul 22, 2019

Test build #108023 has finished for PR 25232 at commit eaf37c8.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

import com.codahale.metrics.MetricRegistry
import com.codahale.metrics.{Metric, MetricFilter, MetricRegistry}
import com.codahale.metrics.graphite.{Graphite, GraphiteReporter, GraphiteUDP}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty line is one of the required Apache Spark coding styles.

[error] /home/jenkins/workspace/SparkPullRequestBuilder/core/src/main/scala/org/apache/spark/metrics/sink/GraphiteSink.scala:25:0: There should at least one a single empty line separating groups 3rdParty and spark.

You can run the code style checker by the following.

$ dev/scalastyle

@nkarpov
Copy link
Contributor Author

nkarpov commented Jul 22, 2019

Hi @dongjoon-hyun!

Setup: start a graphite server & add host, port etc. in metrics.properties

For each scenario below step through w/ debugger to confirm MetricFilter is registered and corresponding metrics are posted to graphite server:

  1. Did not provide driver.sink.graphite.regex in metrics.properties -> successfully defaults to MetricFilter.ALL & all (driver) metrics reported

  2. Did provide driver.sink.graphite.regex=streaming in metrics.properties, enable streaming metrics configuration (spark.conf.set("spark.sql.streaming.metricsEnabled", true)) & start a MemoryStream to console -> successfully registers anonymous MetricFilter in this PR and reports the 6 metrics that are expected to match regex expression streaming

I couldn't find an existing testing suite for the GraphiteSink so I verified manually as above. The change seemed minor enough for that to be OK but let me know if a more robust suite should be added.

Also, if we're happy with the naming convention here, I will add documentation in the following files as part of the PR

https://github.com/apache/spark/blob/master/docs/monitoring.md &
https://github.com/apache/spark/blob/master/conf/metrics.properties.template

@HyukjinKwon
Copy link
Member

@nkarpov, please update this comment in the PR description under How was this patch tested?.

Also, since there is no test, it would be better to describe, with commands, step by step from scratch. With explicit steps, we and our descendants later can detect regressions later other fixes come. Otherwise, every time we should parse your steps and come up with the proper commands.

Ideally it should be copy-and-pastable to reduce human efforts since there's no test case that detects regression automatically.

@SparkQA
Copy link

SparkQA commented Jul 23, 2019

Test build #108026 has finished for PR 25232 at commit d0543a0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@nkarpov
Copy link
Contributor Author

nkarpov commented Jul 23, 2019

Thanks @HyukjinKwon - in that case it's worth to just add the tests. Added in latest commit.

@SparkQA
Copy link

SparkQA commented Jul 23, 2019

Test build #108036 has finished for PR 25232 at commit 4314fa7.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class GraphiteSinkSuite extends SparkFunSuite

@HyukjinKwon
Copy link
Member

Thanks for adding a test.

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Jul 23, 2019

Test build #108039 has finished for PR 25232 at commit 4314fa7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class GraphiteSinkSuite extends SparkFunSuite

val props = new Properties
props.put("host", "127.0.0.1")
props.put("port", "54321")
props.put("regex", "streaming")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal to have regex pattern on test case, as we support regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@HeartSaVioR
Copy link
Contributor

Thanks for the contribution. I'm seeing the benefit on the change as I introduced similar thing (not for Spark though), but it also ended up with advanced (complicated) supports: accepting multiple patterns, with mode either "whitelist" or "blacklist" (not both, of course).

Hopefully I'm not seeing too many Dropwizard metrics in Spark so this might be good enough to start.

@nkarpov
Copy link
Contributor Author

nkarpov commented Jul 24, 2019

Thanks @HeartSaVioR - I've added a better regex example in the test. And you make a good point re: whitelist/blacklist - I think it'll be clear with an example in metrics.properties template? Should we rename the config?

Otherwise, @HeartSaVioR @HyukjinKwon @dongjoon-hyun, it's my first commit so please help me understand what it takes to be merged :) My only outstanding item ATM is to include an example in metrics.properties template file if we are good on naming convention.

@SparkQA
Copy link

SparkQA commented Jul 24, 2019

Test build #108111 has finished for PR 25232 at commit 72754cd.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HeartSaVioR
Copy link
Contributor

I'm also one of contributors trying to help reviewing. :) @HyukjinKwon and @dongjoon-hyun are able to review and approve the patch. So let's wait their next round of reviews.

@HyukjinKwon
Copy link
Member

Can we make the tests passed? Also, you can cc people who appears in Git blame. cc @jerryshao

@nkarpov
Copy link
Contributor Author

nkarpov commented Jul 25, 2019

I've appended some documentation. I don't think the previous failures were related

@SparkQA
Copy link

SparkQA commented Jul 25, 2019

Test build #108180 has finished for PR 25232 at commit 768777a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but as I said earlier you need to get approvals from committers.

@jerryshao
Copy link
Contributor

LGTM. Trigger the test again.

@jerryshao
Copy link
Contributor

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Aug 2, 2019

Test build #108540 has finished for PR 25232 at commit 768777a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@jerryshao jerryshao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jerryshao
Copy link
Contributor

Thanks for the contribution, merging to master branch.

@jerryshao jerryshao closed this in 6d32dee Aug 2, 2019
@dongjoon-hyun
Copy link
Member

Thank you so much, @jerryshao ! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants