Skip to content

silently ignore certain unsupported metric types#3901

Merged
demmer merged 7 commits intovitessio:masterfrom
tinyspeck:minor-prom-fixes
Aug 22, 2018
Merged

silently ignore certain unsupported metric types#3901
demmer merged 7 commits intovitessio:masterfrom
tinyspeck:minor-prom-fixes

Conversation

@demmer
Copy link
Copy Markdown
Member

@demmer demmer commented May 6, 2018

Instead of logging a warning for the stats types which are known
to be incompatible with prometheus (e.g. String, Rates, etc), just
silently skip them in the publish phase.

At the same time remove the throttled logger and replace with a
warning log in case new metric types are created which aren't
covered as part of the backend.

Signed-off-by: Michael Demmer mdemmer@slack-corp.com

@demmer demmer requested a review from michael-berlin May 6, 2018 19:28
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about log.Fatalf here instead?

Some background:

We have similar internal code.

In the past, we did only log a warning similar to this.

However, I plan to change this and issue a log.Fatalf() here instead. That's because a crash in a place like this would have caught the missed type handling I accidentally introduced in our internal code (when I adjusted it to the types refactor).

Given that, you probably want to do a similar thing here as well?

A panic here bears the risk that some code doesn't register their variable during init() and instead dynamically at runtime. But as long as each type has at least one variable instance which publishes during/near init(), we will detect such crashes in tests and not in production. That should be good enough?

For our internal plugins, I'll also guard this behavior by a flag and turn the flag off in our production instance config only. You could also add a flag here, but I would rather not set such a flag in e.g. our Kubernetes config. It's just too confusing.

Given all that, I suggest to just change this to log.Fatalf.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@michael-berlin I'm on board with that change and agree the future-proofing benefit is worth the risk.

I opted to not add another flag here and as a result we need to be vigilant when other stats types are refactored.

Then again until we did this work, I don't think anyone touched stats in the past year at least, so I think this is pretty safe all things considered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

personal pet peeve of mine: Make this a proper sentence and use proper capitalization ("Prometheus'"):

// Silently ignore these types since they don't make sense to
// export to Prometheus' data model.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

@michael-berlin michael-berlin left a comment

Choose a reason for hiding this comment

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

LGTM after minor comment about the error text is responded too.

You have merge rights as well, just merge at your own convenience :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I like error messages to be actionable e.g. change it as follows?

"prometheus: Metric type %T (seen for variable: %s) is not covered by type switch. Add it there and to all other plugins which register a NewVarHook.", st, name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing a few:

JSONFunc, Float, FloatFunc, StringMap

FWIW, I just looked up everything that implemented String() inside the stats package, which is what's required for the expvar interface.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh good catch! I only checked for types that were actually used by the vitess code today.

@michael-berlin Since these types aren't used anywhere my instinct is that we should remove them from stats rather than either add them to this list or run the risk that someone starts using them in the future and then it will panic for anyone using prometheus.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmation that the following types are not used internally:

  • JSONFunc
  • Float
  • StringMap

Types which must stay:

  • FloatFunc

@sougou
Copy link
Copy Markdown
Contributor

sougou commented May 11, 2018

Is this good to go?

@demmer
Copy link
Copy Markdown
Member Author

demmer commented May 11, 2018

Given what Michael said I think we should add Prometheus exporter support for Float and FloatFunc since they are trivial, and remove the other unused types.

@sougou
Copy link
Copy Markdown
Contributor

sougou commented May 11, 2018

Sounds good. I'll wait.

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Jul 26, 2018

Any update on this?

demmer added 4 commits July 26, 2018 15:22
Instead of logging a warning for the stats types which are known
to be incompatible with prometheus (e.g. String, Rates, etc), just
silently skip them in the publish phase.

At the same time remove the throttled logger and replace with a
warning log in case new metric types are created which aren't
covered as part of the backend.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Also minor comment changes as suggested in PR feedback.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
@demmer demmer force-pushed the minor-prom-fixes branch from 5d81026 to 0b8bef3 Compare July 26, 2018 19:46
@demmer
Copy link
Copy Markdown
Member Author

demmer commented Jul 26, 2018

Ooooh. Totally forgot about this.

I just did the thing we talked about above and rebased off latest master.

demmer added 2 commits July 27, 2018 06:11
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
@demmer demmer force-pushed the minor-prom-fixes branch from 0b8bef3 to c9a4e25 Compare July 27, 2018 10:12
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
@demmer demmer force-pushed the minor-prom-fixes branch from c9a4e25 to 8b73b9c Compare August 6, 2018 21:58
@demmer demmer merged commit 9d7888e into vitessio:master Aug 22, 2018
@rafael rafael deleted the minor-prom-fixes branch August 22, 2018 21:03
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

Successfully merging this pull request may close these issues.

4 participants