Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add exemplar support #65

Merged
merged 14 commits into from
Aug 8, 2023
Merged

Add exemplar support #65

merged 14 commits into from
Aug 8, 2023

Conversation

janstenpickle
Copy link
Contributor

@janstenpickle janstenpickle commented Jul 24, 2023

Exemplars allow us to attach transient labels like trace IDs to metrics

Note that some of this is still WIP, especially Timer and OutcomeRecorder. We'll be doing some more refactoring before coming back for those

@janstenpickle janstenpickle force-pushed the exemplar-support branch 7 times, most recently from a6ef2a3 to 9be037a Compare July 24, 2023 19:04
@janstenpickle janstenpickle marked this pull request as ready for review July 24, 2023 19:49
@janstenpickle janstenpickle requested a review from bastewart July 24, 2023 19:50
@janstenpickle janstenpickle force-pushed the exemplar-support branch 4 times, most recently from ff71d87 to 97476e9 Compare July 25, 2023 18:17
@janstenpickle janstenpickle changed the base branch from main to series/2.x August 2, 2023 09:42
Copy link
Contributor

@alejandrohdezma alejandrohdezma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! 👏🏼 👏🏼

Left some minor comments

One of the things I was thinking is, since this is going into a 2.0 milestone, we should embed exemplar support into every metric type that supports it, and easily provide adding an implicit noop that anyone can import. It would greatly simplify the codebase.

object LabelName extends internal.Refined.StringRegexRefinement[LabelName] with ExemplarLabelNameFromStringLiteral {
protected val regex: Pattern = "^[a-zA-Z_][a-zA-Z_0-9]*$".r.pattern

implicit val ordering: Ordering[LabelName] = catsInstances.toOrdering
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: You should be able to remove it since cats' Order already provides this as an implicit conversion.

This comment follows the conventionalcomments.org standard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it does, but we're going the other way as SortedMap needs Ordering


implicit val ordering: Ordering[LabelName] = catsInstances.toOrdering

override protected def make(a: String): LabelName = new LabelName(a)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why this method?

This comment follows the conventionalcomments.org standard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comes from our internal refinement code

override protected def make(a: SortedMap[LabelName, String]): Labels = new Labels(a)

override protected def test(a: SortedMap[LabelName, String]): Boolean =
a.nonEmpty && a.map { case (k, v) => s"${k.value}$v".length }.sum <= 128
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Very clever!

This comment follows the conventionalcomments.org standard

janstenpickle and others added 2 commits August 7, 2023 18:23
Co-authored-by: Alejandro Hernández <info@alejandrohdezma.com>
Copy link
Contributor

@alejandrohdezma alejandrohdezma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janstenpickle janstenpickle merged commit 3602c03 into series/2.x Aug 8, 2023
@janstenpickle janstenpickle deleted the exemplar-support branch August 8, 2023 08:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants