Skip to content

Commit

Permalink
tweak CSM config to be able to enabled by only environment or config
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Jan 10, 2019
1 parent 1ccdf83 commit adad800
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "client side monitoring",
"description": "CSM now can be enabled globally only from environment without code change"
}
9 changes: 7 additions & 2 deletions lib/service.js
Expand Up @@ -57,7 +57,7 @@ AWS.Service = inherit({
//enable attaching listeners to service client
AWS.SequentialExecutor.call(this);
AWS.Service.addDefaultMonitoringListeners(this);
if (this.config.clientSideMonitoring && this.publisher) {
if ((this.config.clientSideMonitoring || AWS.Service._clientSideMonitoring) && this.publisher) {
var publisher = this.publisher;
this.addNamedListener('PUBLISH_API_CALL', 'apiCall', function PUBLISH_API_CALL(event) {
process.nextTick(function() {publisher.eventHandler(event);});
Expand Down Expand Up @@ -709,7 +709,12 @@ AWS.util.update(AWS.Service, {
if (!this.prototype.publisher && AWS.util.clientSideMonitoring) {
var Publisher = AWS.util.clientSideMonitoring.Publisher;
var configProvider = AWS.util.clientSideMonitoring.configProvider;
this.prototype.publisher = new Publisher(configProvider());
var publisherConfig = configProvider();
this.prototype.publisher = new Publisher(publisherConfig);
if (publisherConfig.enabled) {
//if csm is enabled in environment, SDK should send all metrics
AWS.Service._clientSideMonitoring = true;
}
}
AWS.SequentialExecutor.call(svc.prototype);
AWS.Service.addDefaultMonitoringListeners(svc.prototype);
Expand Down
1 change: 0 additions & 1 deletion test/publisher/functional_test/runner.spec.js
Expand Up @@ -14,7 +14,6 @@ describe('run functional test', () => {
let defaultConfiguration;
let processEnvBackup;
before(() => {
AWS.config.clientSideMonitoring = true;
processEnvBackup = Object.assign({}, process.env);
});

Expand Down

0 comments on commit adad800

Please sign in to comment.