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

Not possible to add a metric to same namespace #171

Open
panduz86 opened this issue Feb 24, 2022 · 0 comments
Open

Not possible to add a metric to same namespace #171

panduz86 opened this issue Feb 24, 2022 · 0 comments

Comments

@panduz86
Copy link

Hello,

we open this ticket because we noticed that after the first creation of a MetricSystem, then it's not possible anymore to add a new metric inside.

For example we have this code

val METRICS_NAMESPACE = "appnamespace"
val METRIC_COUNTER_CASES = "CounterCases"

val MetricsSystem = UserMetricsSystems.getMetricSystem(METRICS_NAMESPACE, builder => { 
  builder.registerCounter(METRIC_COUNTER_CASES)
})

MetricsSystem.counter(METRIC_COUNTER_CASES).inc(1L)

I execute the code above and then I update it for adding a new metric under the same namespace, like this:

val METRICS_NAMESPACE = "appnamespace"
val METRIC_COUNTER_CASES = "CounterCases"
val METRIC_COUNTER_ERRORS = "CounterErrors"

val MetricsSystem = UserMetricsSystems.getMetricSystem(METRICS_NAMESPACE, builder => { 
  builder.registerCounter(METRIC_COUNTER_CASES)
  builder.registerCounter(METRIC_COUNTER_ERRORS)
})

MetricsSystem.counter(METRIC_COUNTER_CASES).inc(1L)
MetricsSystem.counter(METRIC_COUNTER_ERRORS).inc(1L)

when I execute it, I get this exception:

Metric 'CounterErrors' in namespace appnamespace was not found

so basically the new counter has not been created and we think that the reason is that UserMetricsSystems.getMetricSystem doesn't execute the builder metric if the namespace already exists (because of the getOrElseUpdate method called here: https://github.com/mspnp/spark-monitoring/blob/main/src/spark-listeners/src/main/scala/org/apache/spark/metrics/UserMetricsSystem.scala#L33) .

Could you please tell us how to manage this?

Thank you

Paolo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant