-
Notifications
You must be signed in to change notification settings - Fork 289
Throttle debug traces #274
Throttle debug traces #274
Conversation
940e402
to
ff33499
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
config/config.go
Outdated
), | ||
) | ||
|
||
fmt.Printf("Overriding default debug throttler, config = %+v, throttler = %+v\n", c.Throttler, debugThrottler) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
4c43b5d
to
78bc99d
Compare
// 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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ;).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
also, looks like the config file needs to be covered |
d5c7387
to
8a97bab
Compare
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 |
tests are broken and I don't think we have 100% coverage |
Look at the errors. They don't make sense. |
cdf520a
to
5a13b65
Compare
) | ||
|
||
type creditResponse struct { | ||
Operation string `json:"operation"` | ||
Credits float64 `json:"credits"` | ||
BalancesByOperation map[string]float64 `json:"balancesByOperation"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
damn DCO, squash all your commits into one, sign it and then do a force push. |
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. |
819e06d
to
e1e59ee
Compare
Signed-off-by: Isaac Hier <isaachier@gmail.com>
e1e59ee
to
7e16cbc
Compare
@@ -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"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Can someone please rerun the above build? I see a bizarre error occurred in Travis:
|
No description provided.