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

[aggregator] m3aggregator with pass-through functionality #2105

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fishie9
Copy link
Collaborator

@fishie9 fishie9 commented Jan 13, 2020

What this PR does / why we need it:

This PR introduces the pass-through functionality into m3aggregator.

Special notes for your reviewer:
This is a PR squashing commits in #1802

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


@fishie9 fishie9 requested a review from prateek January 13, 2020 21:39
glide.lock Outdated
@@ -278,7 +278,7 @@ imports:
subpackages:
- regexp
- name: github.com/magiconair/properties
version: de8848e004dd33dc07a2947b3d76f618a7fc7ef1
version: 7757cc9fdb852f7579b24170bcacda2c7471bb6a
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you need this change?

callStart := agg.nowFn()
agg.metrics.passThrough.Inc(1)

if agg.state != aggregatorOpen {

This comment was marked as resolved.

@@ -74,6 +76,9 @@ type Aggregator interface {
// AddForwarded adds a forwarded metric with metadata.
AddForwarded(metric aggregated.ForwardedMetric, metadata metadata.ForwardMetadata) error

// AddPassThrough add a pass-through metric with metadata
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: period at the end of the comment.

metric aggregated.Metric,
metadata metadata.TimedMetadata,
) error {
// Siyu?
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you need to delete this?

// passThroughWriter writes passthrough metrics to backends.
type passThroughWriter struct {
numShards int
writers []writer.Writer
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make a new writer.Writer w/ the locking inside it? will make this simpler to read.

sp policy.StoragePolicy,
callback m3msg.Callbackable,
) {
// The type of a pass-through metric does not matter as it is written directly into m3db.
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, doesn't the incoming metric have a type?

Value: value,
}
metadata := metadata.TimedMetadata{
AggregationID: aggregation.MustCompressTypes(aggregation.Last),
Copy link
Collaborator

Choose a reason for hiding this comment

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

make a const for this rather than do this at every invocation

}

if err := aggregator.AddPassThrough(metric, metadata); err != nil {
log.Info("[FAIL] to write pass-through metric",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you remove these logs?


if err := aggregator.AddPassThrough(metric, metadata); err != nil {
log.Info("[FAIL] to write pass-through metric",
zap.String("metric", metric.String()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: use zap.Stringer in cases like this

callback.Callback(m3msg.OnRetriableError)
}

if s != nil && s.Sample() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should definitely remove these logs.

}
}

type addPassThroughError struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't see any uses of this type, do you need it?

Comment on lines 116 to 127
var multiErr xerrors.MultiError
for i := 0; i < w.numShards; i++ {
w.locks[i].Lock()
multiErr = multiErr.Add(w.writers[i].Close())
w.locks[i].Unlock()
}

if multiErr.Empty() {
return nil
}

return fmt.Errorf("failed to close sharded writer: %v", multiErr.FinalError())
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably start to standardize on go.uber.org/multierr and github.com/pkg/errors as that's what we use everywhere else now.

This then becomes:

var err error

for i := 0; i < w.numShards; i++ {
  w.locks[i].Lock()
  err = multierr.Append(err, w.writers[i].Close())
  w.locks[i].Unlock()
}

return errors.WithMessage(err, "failed to close sharded writer")

Copy link
Collaborator

Choose a reason for hiding this comment

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

talked offline, added errors.WithMessage

Comment on lines 108 to 114
w.Lock()
defer w.Unlock()

if w.closed {
return errShardedWriterClosed
}
w.closed = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on breaking reads of closed out into a helper to simplify mutex usage?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm need the lock for the duration of the functions in all three: Write(), Close() and Flush(). Don't see the formulation you're thinking of here.

src/aggregator/integration/options.go Show resolved Hide resolved
sp policy.StoragePolicy,
callback m3msg.Callbackable,
) {
// The type of a pass-through metric does not matter.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because...

Copy link
Collaborator

Choose a reason for hiding this comment

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

(just update this docstring)

Comment on lines 252 to 253
agg.RLock()
if agg.state != aggregatorOpen {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth making this a helper?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure

Comment on lines 41 to 44
closed bool

numShards int
writers []Writer
Copy link
Collaborator

Choose a reason for hiding this comment

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

style: no spacing except for embeds/non-embeds

Copy link
Collaborator

Choose a reason for hiding this comment

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

done for this instance but don't always agree: sometimes i break things into groups based on vars that are mutated & the locks that guard them.

Comment on lines 126 to 129
PassThroughTopicName *string `yaml:"passThroughTopicName"`

// The number of passthrough writers
NumPassThroughWriters *int `yaml:"numPassThroughWriters"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these need to be nullable? Can we just use defaults + config population?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure

Comment on lines 878 to 895
for _, handler := range flushCfg.Handlers {
if handler.DynamicBackend != nil && c.PassThroughTopicName != nil {
handler.DynamicBackend.Producer.Writer.TopicName = *c.PassThroughTopicName
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm... not the most friendly code, esp for how simple it is. IMO further datapoints to not use config pointers if we can avoid it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

talked offline: going to leave as is because the changes are pretty pervasive to make handler not be a pointer type.

@@ -56,6 +63,12 @@ func Serve(
defer httpServer.Close()
log.Infof("http server: listening on %s", httpAddr)

if err := m3msgServer.ListenAndServe(); err != nil {
return fmt.Errorf("could not start m3msg server at %s: %v", m3msgAddr, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

errors.WithMessage

Copy link
Collaborator

Choose a reason for hiding this comment

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

done

@prateek prateek force-pushed the siyu-passthrough branch 2 times, most recently from 041df7c to c439889 Compare February 5, 2020 20:55
@codecov
Copy link

codecov bot commented Feb 6, 2020

Codecov Report

Merging #2105 into master will decrease coverage by 1.1%.
The diff coverage is 46.9%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #2105     +/-   ##
========================================
- Coverage    65.5%   64.4%   -1.2%     
========================================
  Files         961    1008     +47     
  Lines       85488   86916   +1428     
========================================
- Hits        56021   55983     -38     
- Misses      25367   27017   +1650     
+ Partials     4100    3916    -184
Flag Coverage Δ
#aggregator 83.3% <47.2%> (-16.7%) ⬇️
#cluster 72.5% <ø> (-4.9%) ⬇️
#collector 71.4% <ø> (+40.7%) ⬆️
#dbnode 77.5% <ø> (-22.5%) ⬇️
#m3em 58.1% <ø> (-41.9%) ⬇️
#m3ninx 65.8% <ø> (-34.2%) ⬇️
#m3nsch 51.1% <ø> (-26.9%) ⬇️
#metrics 17.6% <ø> (-82.4%) ⬇️
#msg 74.9% <0%> (-25.1%) ⬇️
#query 44% <ø> (-56%) ⬇️
#x 71.9% <ø> (-28.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6db9eee...1cbd516. Read the comment docs.

sp policy.StoragePolicy,
callback m3msg.Callbackable,
) {
// The type of a pass-through metric does not matter.
Copy link
Collaborator

Choose a reason for hiding this comment

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

(just update this docstring)

@@ -27,6 +27,13 @@ import (
httpserver "github.com/m3db/m3/src/aggregator/server/http"
rawtcpserver "github.com/m3db/m3/src/aggregator/server/rawtcp"
"github.com/m3db/m3/src/x/instrument"
"github.com/m3db/m3/src/x/server"

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove space

"github.com/m3db/m3/src/cmd/services/m3aggregator/config"
"github.com/m3db/m3/src/cmd/services/m3aggregator/serve"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
"github.com/m3db/m3/src/x/instrument"
"github.com/m3db/m3/src/x/server"

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove this space (even though you didn't add it)

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ prateek
❌ Siyu Yang


Siyu Yang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants