Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Add garbage collection support to the Prometheus metrics adjuster #613

Merged
merged 8 commits into from
Jul 26, 2019
Merged

Add garbage collection support to the Prometheus metrics adjuster #613

merged 8 commits into from
Jul 26, 2019

Conversation

dinooliva
Copy link
Contributor

No description provided.

@songy23 songy23 requested a review from rghetia July 23, 2019 17:37
@codecov
Copy link

codecov bot commented Jul 24, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@6b475fc). Click here to learn what that means.
The diff coverage is 90.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #613   +/-   ##
=========================================
  Coverage          ?   69.16%           
=========================================
  Files             ?       92           
  Lines             ?     6110           
  Branches          ?        0           
=========================================
  Hits              ?     4226           
  Misses            ?     1664           
  Partials          ?      220
Impacted Files Coverage Δ
receiver/prometheusreceiver/metrics_receiver.go 72.13% <100%> (ø)
...er/prometheusreceiver/internal/metrics_adjuster.go 92.4% <90.54%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b475fc...b0efd74. Read the comment docs.

@dinooliva
Copy link
Contributor Author

@rghetia - ptal

Copy link
Contributor

@rghetia rghetia left a comment

Choose a reason for hiding this comment

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

Overall looks good.
One comment regarding Lock/UnLock. Typically you want Lock followed by defer UnLock. That is not always possible. But if it is then we should follow that.

}
jm.lastGC = time.Now()
}
jm.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

jm.Unlock can be defer jm.Unlock right after jm.Lock

I would like to put tsm.Lock() inside tsm.gc() but I am not sure that would work. The question is will anothe goroutine will have tsm while jm is Locked above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can move the tsm.lock() to tsm.gc().

It is is possible that the metricsadjuster could mark the tsm and it will be removed from the JobsMap when it didn't need to be but that would happen even with locking (in a slightly different order).

Copy link
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

LGTM except minor nit. Please rebase.

jm.Lock()
defer jm.Unlock()
// recheck lastGC to make sure gc is necessary
if current.Sub(jm.lastGC) > jm.gcInterval {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the previous check is done before locking jm - this check is to verify that no other gc() has happened in the interim before we grab the lock. I'll add a comment to clarify what's going on.

@songy23 songy23 merged commit 7b57179 into census-instrumentation:master Jul 26, 2019
@dinooliva dinooliva deleted the metrics-adjuster branch July 26, 2019 17:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants