Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jun 23, 2023
1 parent ea71e93 commit 7530bc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions exporter/collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ Additional configuration for the metric exporter:
- `metric.prefix` (optional): MetricPrefix overrides the prefix / namespace of the Google Cloud metric type identifier. If not set, defaults to "custom.googleapis.com/opencensus/"
- `metric.skip_create_descriptor` (optional): Whether to skip creating the
metric descriptor.
- `metric.wal.directory` (optional): Path to local write-ahead-log file.
- `metric.wal.max_backoff` (optional): Maximum duration to retry entries from
- `metric.experimental_wal.experimental_directory` (optional): Path to local write-ahead-log file.
- `metric.experimental_wal.experimental_max_backoff` (optional): Maximum duration to retry entries from
the WAL on network errors.

Addition configuration for the logging exporter:
Expand Down
6 changes: 3 additions & 3 deletions exporter/collector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type MetricConfig struct {
// suffixes for summary metrics, but does not (yet) include the domain prefix
GetMetricName func(baseName string, metric pmetric.Metric) (string, error)
// WALConfig holds configuration settings for the write ahead log.
WALConfig *WALConfig `mapstructure:"wal_config"`
WALConfig *WALConfig `mapstructure:"experimental_wal_config"`
Prefix string `mapstructure:"prefix"`
// KnownDomains contains a list of prefixes. If a metric already has one
// of these prefixes, the prefix is not added.
Expand Down Expand Up @@ -148,9 +148,9 @@ type MetricConfig struct {
// it preserves both the data on disk and the order of the data points.
type WALConfig struct {
// Directory is the location to store WAL files.
Directory string `mapstructure:"directory"`
Directory string `mapstructure:"experimental_directory"`
// MaxBackoff sets the length of time to exponentially re-try failed exports.
MaxBackoff time.Duration `mapstructure:"max_backoff"`
MaxBackoff time.Duration `mapstructure:"experimental_max_backoff"`
}

// ImpersonateConfig defines configuration for service account impersonation.
Expand Down
18 changes: 8 additions & 10 deletions exporter/collector/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ type MetricsExporter struct {
// A channel that receives metric descriptor and sends them to GCM once
metricDescriptorC chan *monitoringpb.CreateMetricDescriptorRequest
client *monitoring.MetricClient
exportFunc func(context.Context, *monitoringpb.CreateTimeSeriesRequest) error
// Only used for testing purposes in lieu of initializing a fake client
exportFunc func(context.Context, *monitoringpb.CreateTimeSeriesRequest) error
// requestOpts applies options to the context for requests, such as additional headers.
requestOpts []func(*context.Context, requestInfo)
mapper metricMapper
Expand Down Expand Up @@ -138,12 +139,6 @@ func (me *MetricsExporter) Shutdown(ctx context.Context) error {
go func() {
// Wait until all goroutines are done
me.goroutines.Wait()
// Close the WAL if open
if me.wal != nil {
if err := me.wal.Close(); err != nil {
me.obs.log.Error(fmt.Sprintf("error closing WAL: %+v\n", err))
}
}
close(c)
}()
select {
Expand Down Expand Up @@ -573,8 +568,11 @@ func (me *MetricsExporter) watchWALFile(ctx context.Context) error {

func (me *MetricsExporter) runWALReadAndExportLoop(ctx context.Context) {
defer me.goroutines.Done()
runCtx, cancel := context.WithCancel(ctx)
defer cancel()
defer func() {
if err := me.wal.Close(); err != nil {
me.obs.log.Error(fmt.Sprintf("error closing WAL: %+v\n", err))
}
}()
for {
select {
case <-ctx.Done():
Expand All @@ -583,7 +581,7 @@ func (me *MetricsExporter) runWALReadAndExportLoop(ctx context.Context) {
// do one last final read/export then return
// otherwise the runner goroutine could leave some hanging metrics unexported
for {
err := me.readWALAndExport(runCtx)
err := me.readWALAndExport(ctx)
if err != nil {
if !errors.Is(err, wal.ErrOutOfRange) {
me.obs.log.Error(fmt.Sprintf("error flushing remaining WAL entries: %+v", err))
Expand Down

0 comments on commit 7530bc3

Please sign in to comment.