Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Throttle debug traces #274

Merged
merged 3 commits into from
Apr 20, 2018

Conversation

isaachier
Copy link
Contributor

No description provided.

@isaachier isaachier force-pushed the throttle_debug_traces branch 2 times, most recently from 940e402 to ff33499 Compare March 26, 2018 19:00
@codecov
Copy link

codecov bot commented Mar 26, 2018

Codecov Report

Merging #274 into master will increase coverage by 0.35%.
The diff coverage is 95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
+ Coverage   86.27%   86.62%   +0.35%     
==========================================
  Files          55       55              
  Lines        2972     3006      +34     
==========================================
+ Hits         2564     2604      +40     
+ Misses        287      282       -5     
+ Partials      121      120       -1
Impacted Files Coverage Δ
metrics.go 100% <ø> (ø) ⬆️
span.go 100% <100%> (+0.97%) ⬆️
tracer.go 89.62% <100%> (+1.05%) ⬆️
internal/throttler/remote/throttler.go 100% <100%> (ø) ⬆️
config/config.go 94.96% <100%> (+2.05%) ⬆️
jaeger_thrift_span.go 98.41% <100%> (+0.02%) ⬆️
crossdock/endtoend/handler.go 87.5% <25%> (-5.84%) ⬇️
zipkin_thrift_span.go 73.11% <0%> (+2.15%) ⬆️

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 a7a6162...a7305c8. Read the comment docs.

config/config.go Outdated
),
)

fmt.Printf("Overriding default debug throttler, config = %+v, throttler = %+v\n", c.Throttler, debugThrottler)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be cleaned up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I might have a handful of these I need to get rid of.

@isaachier isaachier force-pushed the throttle_debug_traces branch from 4c43b5d to 78bc99d Compare March 26, 2018 20:16
This was referenced Mar 26, 2018
// requests are made.
func (t *Throttler) SetProcess(process jaeger.Process) {
t.uuid.Store(process.UUID)
if clientID := process.ClientID(); clientID != "" {
fmt.Printf("Setting clientID to %+v\n", clientID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here too...

if !t.synchronousInitialization {
value, ok := t.credits[operation]
if !ok || value == 0 {
if !ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@black-adder you might notice this changes the throttler to set operations to zero whenever they are encountered, ignoring the t.synchronousInitialization flag. The reason for this is to maintain the operations for the request that requires a list of operation names. Furthermore, that is why I changed the condition above to check for !ok || value == 0. When value is 0, it is either not initialized and just a placeholder, or it needs more credits. Either way, that indicates it is a good time to consider a synchronous request.

resp := make([]creditResponse, len(operations))
for i, op := range operations {
resp[i] = creditResponse{Operation: op, Credits: h.credits}
operations := r.URL.Query()["operations"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor difference. Not sure if this is more correct or less correct.

@@ -1,4 +1,4 @@
// Copyright (c) 2017 Uber Technologies, Inc.
// Copyright (c) 2017-2018 Uber Technologies, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you manually doing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes lol talk to @yurishkuro.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems painful... I'll see how we can automate this

Copy link
Contributor Author

@isaachier isaachier Mar 27, 2018

Choose a reason for hiding this comment

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

I think it can be done with the existing script if you append -<current-year> and limit the files to the list given by this command git diff --name-status master | grep -E '^M' | sed 's/^M\s\+//g'. That looks scarier than it is ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't seem to work on my Mac. Unclear why not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spent way too long researching this... Mac chokes on tab characters (see tab here https://github.com/git/git/blob/c6284da4ff4afbde8211efe5d03f3604b1c6b9d6/combine-diff.c#L1185). Maybe git diff --name-status master | grep -E '^M' | tr '\t' ';' | sed 's/^M;//g' instead.

Copy link
Member

Choose a reason for hiding this comment

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

Mac chokes on tab characters

with what error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually more bizarre than that. In my terminal, any attempt to evaluate a tab character causes autocomplete. If I copy and paste this M process.go from the output into my input I get Makefileprocess.go. There seems to be no way to simply sed with a tab character on my Mac.

config/config.go Outdated
// MaximumBalance limits the maximum number of credits the throttler will
// accumulate on a per-operation basis before it will stop requesting more
// credits. To leave it unbounded, leave this as zero.
MaximumBalance float64 `yaml:"maximumBalance"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of this variable. The agent should handle all allocations and determining the maximum. Also, looking at the code, it looks like you have if maximumBalance is allocated, then the client doesn't make a request to the agent which means the operation will fall out of the agent's memory due to the TTL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I will remove.

Operation string `json:"operation"`
Credits float64 `json:"credits"`
}
type creditResponse map[string]float64
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't very future proof. If we add another field to the response (although I can't think of one at the moment), the json unmarshalling will fail. However, if we leave this as a struct, we can upgrade the agents to return the new field and still be backwards compatible with older versions of the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I was avoiding a backend change but maybe this is worth fixing. In that case, we might as well use Thrift to enforce structure here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this one please

@@ -151,7 +155,6 @@ func NewTracer(
"128 bit trace IDs, consider enabling the \"Gen128Bit\" option")
}
t.process = Process{
UUID: "PLACEHOLDER", // TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

the whole point of this field was to allow all the structs that implement ProcessSetter to use this client UUID. Yes it's unfortunate that we have to add the client uuid to both the tags and this field but I prefer passing the UUID as a first class variable rather than having all the ProcessSetter's iterate over tags to retrieve the client UUID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya considered both. Essentially, I want the propagation through tags but the in process representation to be cached in a field. Wasn't sure if a field was preferred over a method. Up to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

let's use the field. Since the ProcessSetter has already been released, removing UUID is a breaking change.

metrics.go Outdated
ThrottledDebugSpans metrics.Counter `metric:"throttled_debug_spans"`

// Number of times throttler successfully updated.
ThrottlerUpdateSuccess metrics.Counter `metric:"throttler_update_success" tags:"result=ok"`
Copy link
Contributor

Choose a reason for hiding this comment

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

the tag result=ok kinda defeats naming the metric throttler_update_success

It should be metric:"throttler_updates" tags:"result=ok" and metric:"throttler_updates" tags:"result=err"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I had no idea about these tags. Thanks for the explanation.

@black-adder
Copy link
Contributor

also, looks like the config file needs to be covered

@isaachier isaachier force-pushed the throttle_debug_traces branch from d5c7387 to 8a97bab Compare March 27, 2018 17:23
@black-adder
Copy link
Contributor

black-adder commented Apr 13, 2018

I had a thought; do we want to let the throttler know of operations before IsAllowed is called? ie any time we see a new operation, we register it inside throttler.

EDIT: I guess it doesn't make sense if SynchronousInitialization is set. If it isn't set, might be useful. Meh

@black-adder
Copy link
Contributor

tests are broken and I don't think we have 100% coverage

@isaachier
Copy link
Contributor Author

Look at the errors. They don't make sense.

@isaachier isaachier force-pushed the throttle_debug_traces branch from cdf520a to 5a13b65 Compare April 16, 2018 20:33
)

type creditResponse struct {
Operation string `json:"operation"`
Credits float64 `json:"credits"`
BalancesByOperation map[string]float64 `json:"balancesByOperation"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I still have the same 2 comments as before, I'd prefer this to not be a map but an array so it's more extensible in the future. The internal representation inside the client can be a map but json should be array. How much of a headache is this to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure if it was using maps at all or just a very unstructured map with no fields to encapsulate it. I don't mind a list so much just don't think it's inherently more extensible than a map. Some protocols implements maps while others don't. Thrift seems to prefer lists.

Copy link
Contributor

Choose a reason for hiding this comment

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

in the future, if we use the creditResponse to handle both debug throttling and normal sampling throttling, a 1 to 1 mapping won't work. You can either change it to a json list or map[string]struct{}. Where does thrift come into this? Looks like we don't have a thrift definition for the credits payload.

process.go Outdated
UUID string
Tags []Tag
Service string
ClientID string
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change. Hopefully no one has used it yet but it feels very iffy given we've already cut a version of jaeger client with UUID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. I can change it back. Just changed the meaning in other places so I didn't think to leave this as UUID.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just change this back to uuid, the rest can still be clientID

@black-adder
Copy link
Contributor

damn DCO, squash all your commits into one, sign it and then do a force push.

@isaachier
Copy link
Contributor Author

Ya lol I've been careful but it is futile because one of the first commits you had is missing it. Will squash in a sec.

@isaachier isaachier force-pushed the throttle_debug_traces branch 2 times, most recently from 819e06d to e1e59ee Compare April 17, 2018 16:28
Signed-off-by: Isaac Hier <isaachier@gmail.com>
@isaachier isaachier force-pushed the throttle_debug_traces branch from e1e59ee to 7e16cbc Compare April 17, 2018 16:39
@@ -82,6 +82,15 @@ type Metrics struct {

// Number of times baggage restrictions failed to update.
BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=err"`

// Number of times debug spans were throttled.
ThrottledDebugSpans metrics.Counter `metric:"throttled_debug_spans"`
Copy link
Contributor

Choose a reason for hiding this comment

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

can you assert that these metrics are being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Isaac Hier added 2 commits April 18, 2018 15:13
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
@isaachier
Copy link
Contributor Author

Can someone please rerun the above build? I see a bizarre error occurred in Travis:

# cd .; git clone https://go.googlesource.com/lint /home/travis/gopath/src/golang.org/x/lint
Cloning into '/home/travis/gopath/src/golang.org/x/lint'...
fatal: git fetch-pack: expected ACK/NAK, got '?error: Git repository not found'
fatal: The remote end hung up unexpectedly

@black-adder black-adder merged commit fa1caaa into jaegertracing:master Apr 20, 2018
yurishkuro added a commit that referenced this pull request Apr 30, 2018
- Support throttling for debug traces (#274) <Isaac Hier>
- Remove dependency on Apache Thrift (#303) <Yuri Shkuro>
- Remove dependency on tchannel  (#295) (#294) <Yuri Shkuro>
- Test with Go 1.9 (#298) <Yuri Shkuro>

Signed-off-by: Yuri Shkuro <ys@uber.com>
@isaachier isaachier deleted the throttle_debug_traces branch June 12, 2018 13:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants