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

Allow all exporters to be batched and queued #376

Merged
merged 17 commits into from
Feb 14, 2019
Merged

Allow all exporters to be batched and queued #376

merged 17 commits into from
Feb 14, 2019

Conversation

sjkaris
Copy link

@sjkaris sjkaris commented Feb 12, 2019

Adds the ability for all exporters to be batched and queued (part 2 of the original batching PR #361)

Testing Done: unit tests

Copy link

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @sjkaris!

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 overall

doneFns, traceExporters, _ := createExporters(opts.RawConfig, logger)

if spanSender == nil && len(traceExporters) == 0 {
logger.Fatal("Unrecognized sender type or no exporters configured")
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: may be good to differentiate the two cases.

var cfg struct {
Exporters *struct {
Copy link
Member

Choose a reason for hiding this comment

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

Does this radically change what the DataDog exporter will look like in the YAML file?

Copy link
Author

Choose a reason for hiding this comment

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

No, it keeps it the same

@@ -33,22 +36,24 @@ func TestPrometheusExporter(t *testing.T) {
}{
{
config: `
exporters:
Copy link
Member

Choose a reason for hiding this comment

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

Changing this is a little worrying, does this mean that we shall no longer have sections?

@odeke-em
Copy link
Member

Thank you for working on this @sjkaris!

I have a bit of a concern:
a) Is this PR just changing from YAML to Viper?
b) How come in the code and in tests we are switching from

exporters:
   <exporter_name>: 
      <exporter_config>

to

<exporter_name>:
   <exporter_config>

This change seems more of a Viper change than batching, but if I am not mistaken, please send that change separately as it'll make it easier to review but also to catch bugs and keep batching for exporters focused too.

Thank you.

@sjkaris
Copy link
Author

sjkaris commented Feb 13, 2019

This PR doesnt change the way the config is written at all.

Basically, with this change, the prometheus exporter package no longer cares about its parent sections. Instead, internal/config/config.go and cmd/occollector/app/collector/processors.go are responsible for the parent paths.

This change is actually only for batching, the viper changes are done since without it there is no way to instantiate the exporters without a root reference.

zipkin:
upload_period: 1ms
endpoint: ` + cst.URL
v := viper.New()
Copy link
Member

Choose a reason for hiding this comment

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

This pattern is quite common throughout the code and most likely might make writing tests warrant reading through viper but also bytes.NewBuffer.

How about let's make an internal helper to do all this parsing?

func ViperFromYAML(yamlBlob []byte) (*viper.Viper, error) {
   v := viper.New()
   v.SetConfigType("yaml")
   if err := v.ReadConfig(bytes.NewBuffer(yamlBlob)); err != nil {
       return nil, err
   }
   return v, nil
}

@@ -87,7 +89,10 @@ func runOCAgent() {
log.Fatalf("Could not instantiate logger: %v", err)
}

traceExporters, metricsExporters, closeFns, err := config.ExportersFromYAMLConfig(logger, yamlBlob)
// TODO(skaris): move the rest of the configs to use viper
v := viper.New()
Copy link
Member

Choose a reason for hiding this comment

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

We forgot to set below v.SetConfigType("yaml") which directly goes to my suggestion to extract such code into a single helper.

Copy link
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Great, LGTM, thank you @sjkaris!

@sjkaris sjkaris merged commit 77741c8 into census-instrumentation:master Feb 14, 2019
@sjkaris sjkaris deleted the final-generic-queueing branch February 14, 2019 01:20
fivesheep pushed a commit to fivesheep/opencensus-service that referenced this pull request Jun 12, 2019
)

* Add batching to all exporters

Testing Done: unit tests
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.

5 participants