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

Add baggage restriction manager #131

Closed
wants to merge 2 commits into from
Closed

Conversation

black-adder
Copy link
Contributor

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.7%) to 94.165% when pulling 4b428ec on baggage_restrictions into d4d9921 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 98.654% when pulling 02131ee on baggage_restrictions into d4d9921 on master.

* @param {string} [serviceName] - name of the current service / application, same as given to Tracer
* @param {object} [options] - optional settings
* @param {object} [options.logger] - optional logger, see _flow/logger.js
* @param {object} [options.failClosed] - this determines the startup failure mode of RemoteBaggageRestrictionManager.
Copy link
Contributor

Choose a reason for hiding this comment

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

It isn't easy to grasp whatfailClosed does simply by looking at the name.
I suggest renaming it to something like the following:

startupFailurePolicy:  allow | deny

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 thought so too, but according to Yuri: "it's a very common engineering term and you should be ashamed for not knowing it"

Copy link
Member

Choose a reason for hiding this comment

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

https://www.google.com/search?q=fail+open+fail+closed. Widely used in security.

But I agree that it's not the best name to use for the options, I was simply referring to the principle. A property with allow | deny values sgtm. Is it only on startup? I'd be more specific with the name.

_logger: Logger;
_metrics: Metrics;

_refreshInterval: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you append the unit to the key, something like refreshIntervalMs or so

* @param {number} [options.port] - port for jaeger-agent for BaggageRestrictionManager endpoint
* @param {function} [options.onRestrictionsUpdate]
*/
constructor(serviceName: string, options: any = {}) {
Copy link
Contributor

@vprithvi vprithvi Jul 6, 2017

Choose a reason for hiding this comment

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

How does the caller know that startup of the RemoteBaggageRestrictionManager is successful?
I see that it maintains an initialized bool, but I feel a callback might be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user can decide up front what to do incase of initialization failure via the failclosed variable. I dont think we need a callback.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but what if I want custom behavior. For e.g., I don't want the service to startup if this condition is not met.

@@ -106,6 +122,9 @@ export default class Span {
if (this.getBaggageItem(normalizedKey)) {
logs['override'] = 'true';
}
if (truncated) {
logs['truncated'] = 'true';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a better way of capturing this data?
With multiple baggage items, it might be difficult to figure out which one was truncated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each baggage item gets its own set of logs. If we were to dump everything into the same logs, then there would be trouble. I think this current approach is fine.

this._initialized = false;
this._onRestrictionsUpdate = options.onRestrictionsUpdate;

this._refreshBaggageRestrictions();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this not respect the initial delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the baggage restrictions cache should be initialized (or at least attempted) before this constructor completes. This way when the tracer is initialized, users can start adding baggage right away rather than having to wait for at most 60 seconds for the initial delay.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why though?
Without making this a blocking call, there is no guarantee that the request was completed.

}

_updateRestrictions(restrictions: Array<BaggageRestriction>) {
let restrictionsMap: { [key: string]: number } = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make more sense to have the agent return a map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sheeeeet, yeah this is a good idea... My only gripe with this approach is that in the idl, I defined it as: https://github.com/uber/jaeger-idl/blob/master/thrift/baggage.thrift which I prefer over map<string, i32> because it's harder to tell what the variables mean without having a comment describing it.

Now the debate becomes lets leave the thrift idl as is but have the agent convert the array into a map before returning it. This does make sense but again you have that issue where as the consumer of the json, you dont know what the variables in the map symbolizes. By returning it as json array instead of map, each variable is keyed correctly so you know what they symbolize. wdyt?

Copy link
Contributor

@vprithvi vprithvi Jul 10, 2017

Choose a reason for hiding this comment

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

re: thrift idl:
Thrift supports typedefs, so you can have a map<BaggageKey, BaggageValue>

Copy link
Member

Choose a reason for hiding this comment

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

I prefer wire format to be lists, not maps. But thrift format should be hidden behind an interface, it's fine to return a map from the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yurishkuro Why do you prefer the wire format to be a list even when holding map data? What advantages does it have to simply having it as a map?

Copy link
Member

Choose a reason for hiding this comment

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

extensibility - jaegertracing/jaeger-idl#30

@black-adder black-adder closed this Aug 4, 2017
Iuriy-Budnikov pushed a commit to agile-pm/jaeger-client-node that referenced this pull request Sep 25, 2021
* Skeleton: Add basic-tracer package

* remove codecov for now
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