Skip to content
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

eval: support simple legends for streaming data #1607

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions atlas-eval/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ atlas.eval {

// Which version of the LWC server API to use
lwcapi-version = 2

// If set to true, then it will try to generate a simple legend for the set of expressions
// on the graph. By default the legend will just summarize the expression which is often
// long and hard to read for users.
simple-legends-enabled = true
}

graph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.typesafe.scalalogging.StrictLogging
* Helper to analyze a set of expressions and try to automatically set a reasonable
* human readable legend.
*/
private[graph] object SimpleLegends extends StrictLogging {
object SimpleLegends extends StrictLogging {

def generate(exprs: List[StyleExpr]): List[StyleExpr] = {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.netflix.atlas.core.model.ModelExtractors
import com.netflix.atlas.core.model.StatefulExpr
import com.netflix.atlas.core.model.StyleExpr
import com.netflix.atlas.core.stacklang.Interpreter
import com.netflix.atlas.eval.graph.SimpleLegends
import com.netflix.atlas.eval.stream.Evaluator.DataSource
import com.netflix.atlas.eval.stream.Evaluator.DataSources
import com.netflix.atlas.eval.util.HostRewriter
Expand All @@ -35,11 +36,16 @@ private[stream] class ExprInterpreter(config: Config) {

private val hostRewriter = new HostRewriter(config.getConfig("atlas.eval.host-rewrite"))

// Use simple legends for expressions
private val simpleLegendsEnabled: Boolean =
config.getBoolean("atlas.eval.stream.simple-legends-enabled")

def eval(expr: String): List[StyleExpr] = {
interpreter.execute(expr).stack.map {
val exprs = interpreter.execute(expr).stack.map {
case ModelExtractors.PresentationType(t) => t
case v => throw new MatchError(v)
}
if (simpleLegendsEnabled) SimpleLegends.generate(exprs) else exprs
}

def eval(uri: Uri): List[StyleExpr] = {
Expand Down
4 changes: 4 additions & 0 deletions atlas-eval/src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ atlas {
graph {
simple-legends-enabled = false
}

stream {
simple-legends-enabled = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ object TestContext {
| expression-limit = 50000
|
| ignored-tag-keys = []
|
| simple-legends-enabled = false
|}
|
|atlas.eval.host-rewrite {
Expand Down
Loading