-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SungJin1212 <[email protected]>
- Loading branch information
1 parent
ab2a6ea
commit a417e1f
Showing
3 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package distributor | ||
|
||
import ( | ||
"sync/atomic" //lint:ignore faillint we can't use go.uber.org/atomic with a protobuf struct without wrapping it. | ||
) | ||
|
||
type WriteStats struct { | ||
// Samples represents X-Prometheus-Remote-Write-Written-Samples | ||
Samples int64 | ||
// Histograms represents X-Prometheus-Remote-Write-Written-Histograms | ||
Histograms int64 | ||
// Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars | ||
Exemplars int64 | ||
} | ||
|
||
func (w *WriteStats) SetSamples(samples int64) { | ||
if w == nil { | ||
return | ||
} | ||
|
||
atomic.StoreInt64(&w.Samples, samples) | ||
} | ||
|
||
func (w *WriteStats) SetHistograms(histograms int64) { | ||
if w == nil { | ||
return | ||
} | ||
|
||
atomic.StoreInt64(&w.Histograms, histograms) | ||
} | ||
|
||
func (w *WriteStats) SetExemplars(exemplars int64) { | ||
if w == nil { | ||
return | ||
} | ||
|
||
atomic.StoreInt64(&w.Exemplars, exemplars) | ||
} | ||
|
||
func (w *WriteStats) LoadSamples() int64 { | ||
if w == nil { | ||
return 0 | ||
} | ||
|
||
return atomic.LoadInt64(&w.Samples) | ||
} | ||
|
||
func (w *WriteStats) LoadHistogram() int64 { | ||
if w == nil { | ||
return 0 | ||
} | ||
|
||
return atomic.LoadInt64(&w.Histograms) | ||
} | ||
|
||
func (w *WriteStats) LoadExemplars() int64 { | ||
if w == nil { | ||
return 0 | ||
} | ||
|
||
return atomic.LoadInt64(&w.Exemplars) | ||
} |