Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Fix prometheus exporter when tags are missing. #989

Merged
merged 4 commits into from
Nov 29, 2018

Conversation

bogdandrutu
Copy link
Contributor

Fixes #659

@bogdandrutu
Copy link
Contributor Author

/cc @johanbrandhorst

Copy link
Contributor

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @bogdandrutu! I am doing the first pass, but please revert the removal of tagsToLabels since Prometheus needs sanitization of keys e.g. "org/foo" should become "org_foo" but this change removes that.

func tagsToLabels(tags []tag.Tag) []string {
var names []string
for _, tag := range tags {
names = append(names, internal.Sanitize(tag.Key.Name()))
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this? It is imperative that we sanitize keys for Proemtheus otherwise "org/foo" will fail for Prometheus which expects "org_foo".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unused as you can see I did not change any code that calls it, and this seems to be a package private function.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, but it is noisy in this PR and unrelated to this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point, but dead code is the thing that I "like" the most :) happy to do a different PR if you feel strong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted and I would send a different PR.

defer view.Unregister(v)
view.SetReportingPeriod(time.Millisecond)
// Make a measure without some tags in the view.
ctx, _ := tag.New(context.Background(), tag.Upsert(k2, "issue659"), tag.Upsert(k4, "issue659"))
Copy link
Member

Choose a reason for hiding this comment

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

For a fully defensible test, could you please add here a tag that wasn't registered with the view? e.g. k6 and k7?

Copy link
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thank you @bogdandrutu! LGTM with one minor suggestion to add keys(in the test) that weren't registered with the view, and that will help test out the placement logic and ensure that it doesn't read out of bounds.

@bogdandrutu bogdandrutu merged commit aeef0d7 into census-instrumentation:master Nov 29, 2018
@bogdandrutu bogdandrutu deleted the fixprom branch November 29, 2018 00:47
rdallman added a commit to fnproject/fn that referenced this pull request Feb 22, 2019
rdallman added a commit to fnproject/fn that referenced this pull request Feb 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants