Skip to content

Commit

Permalink
eval: support simple legends for streaming data (#1607)
Browse files Browse the repository at this point in the history
To make streaming data more consistent with the backends
allow simple legends to be used. Defaults to true, but
can be disabled if needed.
  • Loading branch information
brharrington authored Feb 9, 2024
1 parent 076f04f commit 1677c6d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
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

0 comments on commit 1677c6d

Please sign in to comment.