-
Couldn't load subscription status.
- Fork 1.4k
Added feature for dumping current metrics values for debug purpose. #8162
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
Conversation
| MetricsRenderer.prettyPrint(metrics) | ||
| } | ||
|
|
||
| object CurrentMetrics { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure a user might think to look here.
Perhaps we could do:
object ZIO {
def metrics: UIO[zio.metrics.Metrics]
}Then Metrics can have methods such as dump, etc., on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thank you for idea! Done.
|
|
||
| import java.io.IOException | ||
|
|
||
| final case class CurrentMetrics private[metrics] (metrics: Set[MetricPair.Untyped]) extends Serializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| final case class CurrentMetrics private[metrics] (metrics: Set[MetricPair.Untyped]) extends Serializable { | |
| final case class Metrics private[metrics] (metrics: Set[MetricPair.Untyped]) extends Serializable { |
| /** | ||
| * Dumps all current metrics to the specified callback. | ||
| */ | ||
| def dumpWith[R, E, T](f: CurrentMetrics => ZIO[R, E, T])(implicit trace: Trace): ZIO[R, E, T] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not exist because a user can always flatMap a Metrics, having acquired it with ZIO.metrics.
| /** | ||
| * Dumps all current metrics to the console. | ||
| */ | ||
| def dump(implicit trace: Trace): IO[IOException, Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make this a method on Metrics.
|
@Grryum Good to merge when the CI is passing. Can you please take a look at the failures? 🙏 |
… others metric tests.
…te between separated tests.
… method at ZIO object.
|
@jdegoes first of all thank you for review! I've fixed all pipeline failures. |
|
|
||
| } | ||
|
|
||
| private[metrics] object MetricsRenderer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point this could be changed to private object Metrics or these could be inlined as private methods in the Metrics class.
| * Dumps all current metrics to the console. | ||
| */ | ||
| def dump(implicit trace: Trace): IO[IOException, Unit] = | ||
| prettyPrint.flatMap(zio.Console.print(_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printLine
|
|
||
| import java.io.IOException | ||
|
|
||
| final case class Metrics private[zio] (metrics: Set[MetricPair.Untyped]) extends Serializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case classes are already serializable so no need for this unless you're trying to do the product with serializable thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could construct the Metrics in the companion object so this constructor can be private instead of package private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, forgot to remove this, thank you!
…MetricRenderer object to Metrics class.
|
@adamgfraser I've also added MetricKey description to rendered string. |
This merge request introduces a new feature that allows for the dumping of current ZIO metric values for the purpose of debugging. The primary objective of this feature is to provide developers efficient method to gain insights into the current state of various metrics during debugging sessions.
Dump will look like:
Closes #5543