You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
Change prometheus to not aggregate metrics and only export them. (#385)
* draft using stop aggregating on prometheus client (counters) * remove prometheus client aggregations Measures are being exported as summaries since histograms doesn't exist on OpenTelemetry yet. Better error handling must be done. * make pre commit * add simple error callback * remove options from collector * refactor exporter to smaller methods * wording * change to snapshot * lock collection and checkpointset read * remove histogram options and unexported fields from the Exporter * documenting why prometheus uses a stateful batcher * add todo for histograms * change summaries objects to summary quantiles * remove histogram buckets from tests * wording * rename 'lockedCheckpoint' to 'syncCheckpointSet' * default summary quantiles should be defaulted to no buckets. * add quantiles options * refactor test.CheckpointSet and add docs * flip aggregators merge Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This commit is contained in:
committed by
rghetia
parent
99cb01b246
commit
6f04903876
@ -27,6 +27,7 @@ import (
|
||||
// Controller organizes a periodic push of metric data.
|
||||
type Controller struct {
|
||||
lock sync.Mutex
|
||||
collectLock sync.Mutex
|
||||
sdk *sdk.SDK
|
||||
errorHandler sdk.ErrorHandler
|
||||
batcher export.Batcher
|
||||
@ -160,8 +161,12 @@ func (c *Controller) tick() {
|
||||
// TODO: either remove the context argument from Export() or
|
||||
// configure a timeout here?
|
||||
ctx := context.Background()
|
||||
c.sdk.Collect(ctx)
|
||||
err := c.exporter.Export(ctx, c.batcher.CheckpointSet())
|
||||
c.collect(ctx)
|
||||
checkpointSet := syncCheckpointSet{
|
||||
mtx: &c.collectLock,
|
||||
delegate: c.batcher.CheckpointSet(),
|
||||
}
|
||||
err := c.exporter.Export(ctx, checkpointSet)
|
||||
c.batcher.FinishedCollection()
|
||||
|
||||
if err != nil {
|
||||
@ -169,6 +174,28 @@ func (c *Controller) tick() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) collect(ctx context.Context) {
|
||||
c.collectLock.Lock()
|
||||
defer c.collectLock.Unlock()
|
||||
|
||||
c.sdk.Collect(ctx)
|
||||
}
|
||||
|
||||
// syncCheckpointSet is a wrapper for a CheckpointSet to synchronize
|
||||
// SDK's collection and reads of a CheckpointSet by an exporter.
|
||||
type syncCheckpointSet struct {
|
||||
mtx *sync.Mutex
|
||||
delegate export.CheckpointSet
|
||||
}
|
||||
|
||||
var _ export.CheckpointSet = (*syncCheckpointSet)(nil)
|
||||
|
||||
func (c syncCheckpointSet) ForEach(fn func(export.Record)) {
|
||||
c.mtx.Lock()
|
||||
defer c.mtx.Unlock()
|
||||
c.delegate.ForEach(fn)
|
||||
}
|
||||
|
||||
func (realClock) Now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
Reference in New Issue
Block a user