-
Notifications
You must be signed in to change notification settings - Fork 327
Conversation
metric/reader/reader.go
Outdated
) | ||
|
||
// Reader periodically reads metrics from all producers registered | ||
// with producer manager and exports those metrics using provided | ||
// exporter. Call Reader.Stop() to stop the reader. | ||
// exporter1. Call Reader.Stop() to stop the reader1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are "exporter1" and "reader1"? Typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when refactored it renamed in reader.go as well. I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bogdandrutu PTAL. |
metric/reader/reader.go
Outdated
// limitations under the License. | ||
// | ||
|
||
package reader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not in metricexport? Also generic names are not good for go packages (so this should be metricreader), I forgot to mention this for producer that should be metricproducer (please fix that).
metric/registry.go
Outdated
@@ -53,6 +56,8 @@ func (r *Registry) AddInt64Gauge(name, description string, unit metricdata.Unit, | |||
} | |||
|
|||
func (r *Registry) initGauge(g *gauge, labelKeys []string, name string, description string, unit metricdata.Unit) *gauge { | |||
r.mu.Lock() | |||
defer r.mu.Unlock() | |||
existing, ok := r.gauges[name] | |||
if ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of log.Panic probably we should return an error. you can file an issue for this.
metric/registry.go
Outdated
) | ||
|
||
// Registry creates and manages a set of gauges. | ||
// External synchronization is required if you want to add gauges to the same | ||
// registry from multiple goroutines. | ||
type Registry struct { | ||
mu sync.RWMutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a different issue, can we split it?
@bogdandrutu PTAL. |
metric/export.go
Outdated
|
||
// Exporter is an interface that exporters implement to export the metric data. | ||
type Exporter interface { | ||
ExportMetric(data []*metricdata.Metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this conflicts with already defined interface used for OC-service.
Should this be changed to ?
- Export( ) OR
- ExportMetrics() . - It is plural, could be very confusing.
OR should the oc-service change it to
- ExportMetricPb(...) - because it exports metric protobuf
@bogdandrutu, @songy23 any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the oc-service change it to
ExportMetricPb(...) - because it exports metric protobuf
I would suggest to go with this approach. I think we should stick to "Metric" when we're referring to the native Go metrics data model and "MetricPb" when referring to the proto-generated files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @odeke-em
@songy23, @bogdandrutu PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
metric/metricexport/reader.go
Outdated
} | ||
|
||
// Options to configure optional parameters for Reader. | ||
type Options struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options is very generic name to have in this package. Consider to use the same pattern as https://golang.org/src/net/http/server.go?s=76578:79938#L2468
So you have a IntervalReader struct with exported properties like ReportingInterval, users will have to set this before calling "Start"
intervalReader := NewIntervalReader(reader, exporter)
intervalReader.ReportingInterval = 30 * time.Second
intervalReader.Start()
You can check the reporting interval at the beginning of Start and save it in a local variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
metric/metricexport/reader.go
Outdated
// with producer manager and exports those metrics using provided | ||
// exporter. | ||
type Reader struct { | ||
Sampler trace.Sampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to export this for the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
metric/export.go
Outdated
) | ||
|
||
// Exporter is an interface that exporters implement to export the metric data. | ||
type Exporter interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the metric package and not metricexport?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved.
@bogdandrutu PTAL. |
metric/metricexport/reader.go
Outdated
} | ||
|
||
ctx := context.Background() | ||
_, span := trace.StartSpan( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be:
ctx, span := trace.StartSpan(context.Background(), spanName, trace.WithSampler(...))
data = append(data, producer.Read()...) | ||
} | ||
// TODO: [rghetia] what to do with errors? log them? | ||
exporter.ExportMetrics(ctx, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to record metrics for this. Not now.
metric/metricexport/reader.go
Outdated
// Reader reads metrics from all producers registered | ||
// with producer manager and exports those metrics using provided | ||
// exporter. | ||
type Reader struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably for this we should do a WithOption pattern because does not have a start method.
Also include ctx in ExportMetric api.
@bogdandrutu PTAL. |
* Add support for reader. * handle multiple call to reader.Stop and test for producer while reader is stopped. * fix typo. * fix review comment and refactor reader to metricexport package. * change Reader to IntervalReader and add Reader. Also include ctx in ExportMetric api. * modify export interface to return error and make it plural. * remove option and provide Start function. * move exporter.go to metricexport package. * added option for reader. * make constants private. (cherry picked from commit 5ae9166)
No description provided.