Skip to content

Commit

Permalink
metrics: Introduce MetricBuilderRegistry for instrumenting expression…
Browse files Browse the repository at this point in the history
…s in server stack

Problem

Metrics creations are scattered in many stack modules, each stack module has its
filter and independent from others. However, instrumenting an expression needs
access to all component metrics.

Solution

Introduce a stack param to cache metrics as well as providing lazy vals to create
expressions.

Result

The original approach was having a stack.module that sits at the end of the
stack where all needed metrics are generated. the downside is it registers the
same expressions many times (= connections), and the last override the previous
ones.  The current approach should reduce the expression evaluation time, but
requires implementors to have more context on the finagle stack for metrics
creation sequence.

Differential Revision: https://phabricator.twitter.biz/D663915
  • Loading branch information
yufangong authored and jenkins committed May 21, 2021
1 parent 1c82625 commit ec1f12e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.twitter.server.util.{AdminJsonConverter, MetricSchemaSource}
import com.twitter.util.Future

object MetricExpressionHandler {
private val Version = 0.7
private val Version = 1.0
private val statsFormatter = StatsFormatter.default

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MetricExpressionHandlerTest extends AnyFunSuite {
val expectedResponse =
"""
|{
| "@version" : 0.7,
| "@version" : 1.0,
| "counters_latched" : false,
| "separator_char" : "/",
| "expressions" : [
Expand Down

0 comments on commit ec1f12e

Please sign in to comment.