Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publisher pipeline: pass logger and metrics registry #8091

Merged
merged 5 commits into from
Aug 29, 2018

Conversation

urso
Copy link

@urso urso commented Aug 26, 2018

We should strive to not have dependencies on globals in beats. The
publisher pipeline rewrite made sure we don't work with globals
internally. Yet some globals have been introduced since, and even though
the library didn't use globals internally, initialization still did use
globals at some points.
This change removes globals for logging/metrics/telemetry, by requiring
the beat instance to pass down required instances.

@urso urso added the in progress Pull request is currently in progress. label Aug 26, 2018
@urso urso requested review from ph and ruflin August 26, 2018 17:00
@@ -38,6 +38,12 @@ var publishDisabled = false

const defaultQueueType = "mem"

type Monitors struct {

Choose a reason for hiding this comment

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

exported type Monitors should have comment or be unexported

@@ -38,6 +38,12 @@ var publishDisabled = false

const defaultQueueType = "mem"

type Monitors struct {
Metrics *monitoring.Registry
Telemetry *monitoring.Registry
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting separate of telemetry and metrics here. At the moment the separation is pretty clear but I don't think it will stay like this. Perhaps we better pass a map[string]*monitoring.Registry instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the proposed way instead of map[string]*monitoring.Registry, using a field reflect a clear intends, using a map complexify the access patterns instead of a nil check.

I would argue that maybe the monitoring package could expose a struct to list the possible monitors so we only have one place to change and the access definition are centralized.

Concerning having Logger inside the monitor struct Monitor, at first I was against a logger is effectively some kind of monitor.

Copy link
Author

Choose a reason for hiding this comment

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

I agree with PH, using a map will complicate the code and make it much more error prone. Instead we should have well defined types. Right now we use globals in a few places, so I kept the struct local to the publisher pipeline for now (makes me wonder if I missed some globals in the outputs).

Wasn't sure about the logger, but then decided to put it into the struct as well. Ideas was: all functionality passed/configured is for the purpose of getting some insights into an instance of the publisher pipeline. The metrics registry share the same type, but they are used in very different ways as well.

@ruflin ruflin added the needs_backport PR is waiting to be backported to other branches. label Aug 27, 2018
Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -38,6 +38,12 @@ var publishDisabled = false

const defaultQueueType = "mem"

type Monitors struct {
Metrics *monitoring.Registry
Telemetry *monitoring.Registry
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the proposed way instead of map[string]*monitoring.Registry, using a field reflect a clear intends, using a map complexify the access patterns instead of a nil check.

I would argue that maybe the monitoring package could expose a struct to list the possible monitors so we only have one place to change and the access definition are centralized.

Concerning having Logger inside the monitor struct Monitor, at first I was against a logger is effectively some kind of monitor.

@ph
Copy link
Contributor

ph commented Aug 27, 2018

@urso
The build is falling with a valid reason:

warning: ignoring symlink /home/travis/gopath/src/github.com/elastic/beats/libbeat/build/python-env/local/include
warning: ignoring symlink /home/travis/gopath/src/github.com/elastic/beats/libbeat/build/python-env/local/lib
# github.com/elastic/beats/libbeat/publisher/pipeline/stress
publisher/pipeline/stress/run.go:61:32: cannot use nil as type pipeline.Monitors in argument to pipeline.Load
# github.com/elastic/beats/libbeat/publisher/queue/memqueue
publisher/queue/memqueue/queue_test.go:75:19: not enough arguments in call to NewBroker
	have (Settings)
	want (logger, Settings)
make[1]: *** [check] Error 2
make[1]: Leaving directory `/home/travis/gopath/src/github.com/elastic/beats/libbeat'
make: *** [check] Error 1

@urso
Copy link
Author

urso commented Aug 27, 2018

The build is falling with a valid reason:

Yeah, that's why PR is still in progress. There might be some more test builds I have to fix before PR goes green.

@urso urso added review and removed in progress Pull request is currently in progress. labels Aug 27, 2018
Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

LGTM

@ph Do you want to have an other look?

@urso We should make sure that the queue types show potentially show up in monitoring and telemetry which requires a few changes in ES and KB. Do you want to open an issue in https://github.com/elastic/stack-monitoring ?

@ph
Copy link
Contributor

ph commented Aug 28, 2018

@urso LGTM but lets add a simple changelog

urso added 5 commits August 28, 2018 23:28
We should strive to not have dependencies on globals in beats. The
publisher pipeline rewrite made sure we don't work with globals
internally. Yet some globals have been introduced since, and even though
the library didn't use globals internally, initialization still did use
globals at some points.
This change removes globals for logging/metrics/telemetry, by requiring
the beat instance to pass down required instances.
@urso urso force-pushed the pipeline-pass-monitors branch from 155f723 to ade2188 Compare August 28, 2018 21:28
@urso urso merged commit 8c15e6e into elastic:master Aug 29, 2018
graphaelli added a commit to graphaelli/apm-server that referenced this pull request Aug 29, 2018
* includes minor updates for elastic/beats#8091 NewBroker change
jalvz pushed a commit to elastic/apm-server that referenced this pull request Aug 29, 2018
* includes minor updates for elastic/beats#8091 NewBroker change
@urso urso added v6.5.0 and removed needs_backport PR is waiting to be backported to other branches. labels Aug 29, 2018
graphaelli added a commit to elastic/apm-server that referenced this pull request Sep 11, 2018
urso pushed a commit to urso/beats that referenced this pull request Oct 19, 2018
We should strive to not have dependencies on globals in beats. The
publisher pipeline rewrite made sure we don't work with globals
internally. Yet some globals have been introduced since, and even though
the library didn't use globals internally, initialization still did use
globals at some points.
This change removes globals for logging/metrics/telemetry, by requiring
the beat instance to pass down required instances.

(cherry picked from commit 8c15e6e)
urso pushed a commit that referenced this pull request Oct 22, 2018
We should strive to not have dependencies on globals in beats. The
publisher pipeline rewrite made sure we don't work with globals
internally. Yet some globals have been introduced since, and even though
the library didn't use globals internally, initialization still did use
globals at some points.
This change removes globals for logging/metrics/telemetry, by requiring
the beat instance to pass down required instances.

(cherry picked from commit 8c15e6e)
@urso urso deleted the pipeline-pass-monitors branch February 19, 2019 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants