Repository: aws/aws-xray-sdk-node
Pull request #11 (2017-12-04 23:54:32)

WIP: work around cls handling of Promises
continuation-local-storage chooses to bind the context to the Promise
constructor and passes this to any and all reactions to that promise.
While this might make sense in some cases, it very much doesn't when
it comes to tracing an HTTP request context. Provide a patcher for
Promises which will bind the reaction handler to the active segment
when "then" or "catch" is called.

Hey X-Ray team

Didn't expose this patcher or go through the work of integrating it, but wanted to write up a test exposing the issue, and share a possible solution to it.

In the current state, if a Promise is created in request/segment A, and waited upon in request/segment B, than all metadata/errors/subsegments etc. after the fact will be added to segment A instead of B. This is due to the way continuation-local-storage opts to bind Promises, leaning more strictly towards execution paths, which I don't believe fits for a product like X-Ray.

Certainly not the first APM-style product to have this problem, since they all use cls :)

Let me know your thoughts, I'll point our TAMs this way as well.

- Owen


Patch:
diff --git a/package.json b/package.json
index c8ce243..295c762 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
   "private": true,
   "license": "Apache-2.0",
   "devDependencies": {
-    "aws-xray-sdk-core": "^1.1.4",
+    "aws-xray-sdk-core": "^1.1.7",
     "chai": "^3.5.0",
     "eslint": "^3.10.2",
     "grunt": "^1.0.1",
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index 08a3cf3..5eb7c32 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,11 +1,14 @@
 # Changelog for AWS X-Ray Core SDK for JavaScript
-<!--LATEST=1.1.4-->
+<!--LATEST=1.1.7-->
 <!--ENTRYINSERT-->
 
+## 1.1.7
+* bugfix: Fixed issue where undefined host name would not match any path based sampling rule.
+
 ## 1.1.5
 * The X-Ray SDK for Node.js is now an open source project. You can follow the project and submit issues and pull requests on [GitHub](https://github.com/aws/aws-xray-sdk-node).
 
-## 1.14
+## 1.1.4
 * bugfix: Fixing issue where an unexpected segment on the CLS context would fail in Lambda 
 ## 1.1.3
 * bugfix: Resolving Lambda segment information on `getSegment` rather than on `addSubsegment`.
diff --git a/packages/core/lib/middleware/sampling/sampling_rules.js b/packages/core/lib/middleware/sampling/sampling_rules.js
index 8416b93..90212a0 100644
--- a/packages/core/lib/middleware/sampling/sampling_rules.js
+++ b/packages/core/lib/middleware/sampling/sampling_rules.js
@@ -34,8 +34,10 @@ SamplingRules.prototype.shouldSample = function shouldSample(serviceName, httpMe
   var matched;
 
   this.rules.some(function(rule) {
-    if (rule.default || (Utils.wildcardMatch(rule.service_name, serviceName)
-      && Utils.wildcardMatch(rule.http_method, httpMethod) && Utils.wildcardMatch(rule.url_path, urlPath))) {
+    // Any null parameters provided will be considered an implicit match.
+    if (rule.default || (serviceName == null || (Utils.wildcardMatch(rule.service_name, serviceName))
+      && (httpMethod == null || Utils.wildcardMatch(rule.http_method, httpMethod))
+      && (urlPath == null || Utils.wildcardMatch(rule.url_path, urlPath)))) {
 
       matched = rule.sampler;
 
diff --git a/packages/core/lib/patchers/http_p.js b/packages/core/lib/patchers/http_p.js
index 55221ac..5c0cb68 100644
--- a/packages/core/lib/patchers/http_p.js
+++ b/packages/core/lib/patchers/http_p.js
@@ -7,6 +7,7 @@
  */
 
 var _ = require('underscore');
+var url = require('url');
 
 var contextUtils = require('../context_utils');
 var Utils = require('../utils');
@@ -59,6 +60,10 @@ function enableCapture(module, downstreamXRayEnabled) {
       return baseFunc(options, callback);
     }
 
+    if (typeof options === 'string') {
+      options = url.parse(options);
+    }
+
     var parent = contextUtils.resolveSegment(contextUtils.resolveManualSegmentParams(options));
     var hostname = options.hostname || options.host || 'Unknown host';
 
diff --git a/packages/core/lib/patchers/promise_p.js b/packages/core/lib/patchers/promise_p.js
new file mode 100644
index 0000000..1aa2e27
--- /dev/null
+++ b/packages/core/lib/patchers/promise_p.js
@@ -0,0 +1,35 @@
+/**
+ * @module promise_p
+ */
+
+/**
+ * This module patches Promise libraries to correct tracing attribution for http requests.
+ */
+
+var contextUtils = require('../context_utils');
+
+function patchPromise(Promise) {
+  var then = Promise.prototype.then;
+  Promise.prototype.then = function(onFulfilled, onRejected) {
+    if (contextUtils.isAutomaticMode()
+      && tryGetCurrentSegment()
+    ) {
+      var ns = contextUtils.getNamespace();
+
+      onFulfilled = onFulfilled && ns.bind(onFulfilled);
+      onRejected = onRejected && ns.bind(onRejected);
+    }
+
+    return then.call(this, onFulfilled, onRejected);
+  };
+}
+
+function tryGetCurrentSegment() {
+  var segment = null;
+  try {
+    segment = contextUtils.getSegment();
+  } catch(e) { /**/ }
+  return segment;
+}
+
+module.exports = patchPromise;
diff --git a/packages/core/lib/resources/aws_whitelist.json b/packages/core/lib/resources/aws_whitelist.json
index f270b65..c36c32c 100644
--- a/packages/core/lib/resources/aws_whitelist.json
+++ b/packages/core/lib/resources/aws_whitelist.json
@@ -330,6 +330,619 @@
           ]
         }
       }
+    },
+    "s3": {
+      "operations": {
+        "abortMultipartUpload": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "completeMultipartUpload": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "copyObject": {
+          "request_parameters": [
+            "CopySource",
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "createBucket": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "createMultipartUpload": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucket": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketAnalyticsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketCors": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketEncryption": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketInventoryConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketLifecycle": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketMetricsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketPolicy": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketReplication": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketTagging": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteBucketWebsite": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteObject": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteObjectTagging": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "deleteObjects": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketAccelerateConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketAcl": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketAnalyticsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketCors": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketEncryption": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketInventoryConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketLifecycle": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketLifecycleConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketLocation": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketLogging": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketMetricsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketNotification": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketNotificationConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketPolicy": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketReplication": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketRequestPayment": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketTagging": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketVersioning": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getBucketWebsite": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getObject": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getObjectAcl": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getObjectTagging": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "getObjectTorrent": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "headBucket": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "headObject": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listBucketAnalyticsConfigurations": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listBucketInventoryConfigurations": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listBucketMetricsConfigurations": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listMultipartUploads": {
+          "request_parameters": [
+            "Prefix"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listObjectVersions": {
+          "request_parameters": [
+            "Prefix"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listObjects": {
+          "request_parameters": [
+            "Prefix"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listObjectsV2": {
+          "request_parameters": [
+            "Prefix"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "listParts": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketAccelerateConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketAcl": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketAnalyticsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketCors": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketEncryption": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketInventoryConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketLifecycle": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketLifecycleConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketLogging": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketMetricsConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketNotification": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketNotificationConfiguration": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketPolicy": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketReplication": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketRequestPayment": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketTagging": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketVersioning": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putBucketWebsite": {
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putObject": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putObjectAcl": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "putObjectTagging": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "restoreObject": {
+          "request_parameters": [
+            "Key",
+            "VersionId"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "uploadPart": {
+          "request_parameters": [
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        },
+        "uploadPartCopy": {
+          "request_parameters": [
+            "CopySource",
+            "Key"
+          ],
+          "request_descriptors": {
+            "Bucket": {
+              "rename_to": "bucket_name"
+            }
+          }
+        }
+      }
     }
   }
 }
diff --git a/packages/core/package.json b/packages/core/package.json
index 775ce0f..76525e9 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk-core",
-  "version": "1.1.6",
+  "version": "1.1.7",
   "description": "AWS X-Ray SDK for Javascript",
   "author": "Amazon Web Services",
   "contributors": [
diff --git a/packages/express/CHANGELOG.md b/packages/express/CHANGELOG.md
index 6cc143d..b1443c8 100644
--- a/packages/express/CHANGELOG.md
+++ b/packages/express/CHANGELOG.md
@@ -1,5 +1,5 @@
 # Changelog for AWS X-Ray SDK Express for JavaScript
-<!--LATEST=1.1.4-->
+<!--LATEST=1.1.7-->
 <!--ENTRYINSERT-->
 
 ## 1.1.5
diff --git a/packages/express/package.json b/packages/express/package.json
index 11f417a..7986c80 100644
--- a/packages/express/package.json
+++ b/packages/express/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk-express",
-  "version": "1.1.6",
+  "version": "1.1.7",
   "description": "AWS X-Ray Middleware for Express (Javascript)",
   "author": "Amazon Web Services",
   "contributors": [
@@ -14,10 +14,10 @@
     "test": "test"
   },
   "peerDependencies": {
-    "aws-xray-sdk-core": "^1.1.6"
+    "aws-xray-sdk-core": "^1.1.7"
   },
   "devDependencies": {
-    "aws-xray-sdk-core": "^1.1.6",
+    "aws-xray-sdk-core": "^1.1.7",
     "chai": "^3.5.0",
     "eslint": "^3.10.2",
     "grunt": "^1.0.1",
diff --git a/packages/full_sdk/CHANGELOG.md b/packages/full_sdk/CHANGELOG.md
index 8901df9..1791d72 100644
--- a/packages/full_sdk/CHANGELOG.md
+++ b/packages/full_sdk/CHANGELOG.md
@@ -1,7 +1,13 @@
 # Changelog for AWS X-Ray SDK for JavaScript
-<!--LATEST=1.1.4-->
+<!--LATEST=1.1.7-->
 <!--ENTRYINSERT-->
 
+## 1.1.7
+* change: Updated aws-xray-sdk-core to 1.1.7. See aws-xray-sdk-core's CHANGELOG.md for package changes.
+* change: Updated aws-xray-sdk-express to 1.1.7. No further changes.
+* change: Updated aws-xray-sdk-mysql to 1.1.7. No further changes.
+* change: Updated aws-xray-sdk-postgres to 1.1.7. No further changes.
+
 ## 1.1.5
 * The X-Ray SDK for Node.js is now an open source project. You can follow the project and submit issues and pull requests on [GitHub](https://github.com/aws/aws-xray-sdk-node).
 
diff --git a/packages/full_sdk/package.json b/packages/full_sdk/package.json
index 4edfc1d..f63cd88 100644
--- a/packages/full_sdk/package.json
+++ b/packages/full_sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk",
-  "version": "1.1.6",
+  "version": "1.1.7",
   "description": "AWS X-Ray SDK for Javascript",
   "author": "Amazon Web Services",
   "contributors": [
@@ -11,10 +11,10 @@
     "node": ">= 0.8.0"
   },
   "dependencies": {
-    "aws-xray-sdk-core": "^1.1.6",
-    "aws-xray-sdk-express": "^1.1.6",
-    "aws-xray-sdk-mysql": "^1.1.6",
-    "aws-xray-sdk-postgres": "^1.1.6",
+    "aws-xray-sdk-core": "^1.1.7",
+    "aws-xray-sdk-express": "^1.1.7",
+    "aws-xray-sdk-mysql": "^1.1.7",
+    "aws-xray-sdk-postgres": "^1.1.7",
     "pkginfo": "^0.4.0"
   },
   "keywords": [
diff --git a/packages/mysql/package.json b/packages/mysql/package.json
index cba42c5..c029627 100644
--- a/packages/mysql/package.json
+++ b/packages/mysql/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk-mysql",
-  "version": "1.1.6",
+  "version": "1.1.7",
   "description": "AWS X-Ray Patcher for MySQL (Javascript)",
   "author": "Amazon Web Services",
   "contributors": [
@@ -14,10 +14,10 @@
     "test": "test"
   },
   "peerDependencies": {
-    "aws-xray-sdk-core": "^1.1.6"
+    "aws-xray-sdk-core": "^1.1.7"
   },
   "devDependencies": {
-    "aws-xray-sdk-core": "^1.1.6",
+    "aws-xray-sdk-core": "^1.1.7",
     "chai": "^3.5.0",
     "eslint": "^3.10.2",
     "grunt": "^1.0.1",
diff --git a/packages/postgres/package.json b/packages/postgres/package.json
index 92b23f9..914f3e3 100644
--- a/packages/postgres/package.json
+++ b/packages/postgres/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk-postgres",
-  "version": "1.1.6",
+  "version": "1.1.7",
   "description": "AWS X-Ray Patcher for Postgres (Javascript)",
   "author": "Amazon Web Services",
   "contributors": [
@@ -14,10 +14,10 @@
     "test": "test"
   },
   "peerDependencies": {
-    "aws-xray-sdk-core": "^1.1.6"
+    "aws-xray-sdk-core": "^1.1.7"
   },
   "devDependencies": {
-    "aws-xray-sdk-core": "^1.1.6",
+    "aws-xray-sdk-core": "^1.1.7",
     "chai": "^3.5.0",
     "eslint": "^3.10.2",
     "grunt": "^1.0.1",
diff --git a/packages/restify/package.json b/packages/restify/package.json
index c00fdd4..0bc4e56 100644
--- a/packages/restify/package.json
+++ b/packages/restify/package.json
@@ -1,6 +1,6 @@
 {
   "name": "aws-xray-sdk-restify",
-  "version": "1.0.2-beta",
+  "version": "1.0.3-beta",
   "description": "Enables AWS X-Ray for Restify (Javascript)",
   "author": "Amazon Web Services",
   "contributors": [
@@ -14,7 +14,7 @@
     "test": "test"
   },
   "peerDependencies": {
-    "aws-xray-sdk-core": "^1.1.6"
+    "aws-xray-sdk-core": "^1.1.7"
   },
   "devDependencies": {
     "chai": "^3.5.0",


Test patch:
diff --git a/packages/core/test/integration/segment_maintained_across_shared_promise.test.js b/packages/core/test/integration/segment_maintained_across_shared_promise.test.js
new file mode 100644
index 0000000..299b4c8
--- /dev/null
+++ b/packages/core/test/integration/segment_maintained_across_shared_promise.test.js
@@ -0,0 +1,73 @@
+/* global Promise */
+
+if (!global.Promise) {
+  process.exit(0);
+}
+
+var assert = require('chai').assert;
+var http = require('http');
+
+var AWSXRay = require('../../');
+var Segment = AWSXRay.Segment;
+
+require('../../lib/patchers/promise_p')(Promise);
+
+AWSXRay.enableAutomaticMode();
+
+var sharedPromise = null;
+
+var server = http
+  .createServer(function(req, res) {
+    var ns = AWSXRay.getNamespace();
+    ns.bindEmitter(req);
+    ns.bindEmitter(res);
+
+    ns.run(function () {
+      var segment = new Segment('foo');
+
+      AWSXRay.setSegment(segment);
+
+      if (!sharedPromise) {
+        sharedPromise = Promise.resolve();
+      }
+
+      sharedPromise.then(function() {
+        var retrievedSegment = AWSXRay.getSegment();
+        res.end();
+
+        // setTimeout so the assertion isn't caught by the promise
+        setTimeout(function() {
+          assert.equal(segment.id, retrievedSegment.id);
+        });
+      });
+    });
+  }).listen(0, function() {
+    var address = server.address();
+
+    var count = 0;
+    function cb(err) {
+      if (err) {
+        throw err;
+      }
+
+      if (++count === 2) {
+        server.close();
+      }
+    }
+    sendRequest(address, cb);
+    sendRequest(address, cb);
+  });
+
+function sendRequest(address, cb) {
+  http
+    .request({
+      hostname: address.address,
+      port: address.port,
+      path: '/'
+    })
+    .on('response', function(res) {
+      res.on('end', cb).resume();
+    })
+    .on('error', cb)
+    .end();
+}
diff --git a/packages/core/test/unit/middleware/mw_utils.test.js b/packages/core/test/unit/middleware/mw_utils.test.js
index c05c65a..f0e0f10 100644
--- a/packages/core/test/unit/middleware/mw_utils.test.js
+++ b/packages/core/test/unit/middleware/mw_utils.test.js
@@ -3,6 +3,7 @@ var sinon = require('sinon');
 
 var MWUtils = require('../../../lib/middleware/mw_utils');
 var SamplingRules = require('../../../lib/middleware/sampling/sampling_rules');
+var Segment = require('../../../lib/segments/segment');
 
 //headers are case-insensitive
 var XRAY_HEADER = 'x-amzn-trace-id';
@@ -209,6 +210,43 @@ describe('Middleware utils', function() {
     });
   });
 
+  describe('#samplingWildcardMatch', function() {
+    var segment = new Segment('foo');
+    var headers = {};
+    var res = {
+      req: {
+        headers: {},
+        url: '/api/move/up',
+        method: 'GET',
+      },
+      header: {}
+    };
+
+    var customRules = {
+      version: 1,
+      rules: [
+        {
+          description: 'Player moves.',
+          service_name: '*',
+          http_method: '*',
+          url_path: '/api/move/*',
+          fixed_target: 0,
+          rate: 1
+        }
+      ],
+      default: {
+        fixed_target: 0,
+        rate: 0
+      }
+    };
+
+    it('should match path based sampling rule if host name is not present in the headerds', function() {
+      MWUtils.setSamplingRules(customRules);
+      MWUtils.resolveSampling(headers, segment, res);
+      assert.notProperty(segment, 'notTraced');
+    });
+  });
+
   describe('#setDefaultName', function() {
     it('it should set the default name', function() {
       MWUtils.setDefaultName(defaultName);
diff --git a/packages/core/test/unit/patchers/http_p.test.js b/packages/core/test/unit/patchers/http_p.test.js
index 15d0b14..4cb2dc1 100644
--- a/packages/core/test/unit/patchers/http_p.test.js
+++ b/packages/core/test/unit/patchers/http_p.test.js
@@ -2,6 +2,7 @@ var assert = require('chai').assert;
 var chai = require('chai');
 var sinon = require('sinon');
 var sinonChai = require('sinon-chai');
+const { URL } = require('url');
 
 var captureHTTPs = require('../../../lib/patchers/http_p').captureHTTPs;
 var captureHTTPsGlobal = require('../../../lib/patchers/http_p').captureHTTPsGlobal;
@@ -144,6 +145,19 @@ describe('HTTP/S', function() {
         newSubsegmentStub.should.have.been.calledWith('Unknown host');
       });
 
+      it('should pass when a string is passed', function() {
+        capturedHttp.request('http://hostname/api');
+        newSubsegmentStub.should.have.been.calledWith('hostname');
+        capturedHttp.get('http://hostname/api');
+        newSubsegmentStub.should.have.been.calledWith('hostname');
+      });
+
+      it('should pass when a URL is passed', function() {
+        var options = new URL('http://hostname/api');
+        capturedHttp.request(options);
+        newSubsegmentStub.should.have.been.calledWith('hostname');
+      });
+
       it('should call the base method', function() {
         capturedHttp.request({'Segment': segment});
         assert(requestSpy.called);
diff --git a/packages/core/test/unit/segments/attributes/aws.test.js b/packages/core/test/unit/segments/attributes/aws.test.js
index 3ff8ff5..abc09d0 100644
--- a/packages/core/test/unit/segments/attributes/aws.test.js
+++ b/packages/core/test/unit/segments/attributes/aws.test.js
@@ -5,11 +5,17 @@ var sinon = require('sinon');
 
 describe('Aws', function() {
   var serviceName = 's3';
+  var bucketName = 'test-bucket';
+  var keyName = 'test-key';
   var req = {
     request: {
       operation: 'putObject',
       httpRequest: {
         region: 'us-east-1'
+      },
+      params: {
+        Bucket: bucketName,
+        Key: keyName
       }
     },
     requestId: 'C9336616C948DC3C',
@@ -17,11 +23,11 @@ describe('Aws', function() {
   };
 
   describe('#init', function() {
-    var sandbox;
+    var sandbox, addDataStub;
 
     beforeEach(function() {
       sandbox = sinon.sandbox.create();
-      sandbox.stub(Aws.prototype, 'addData');
+      addDataStub = sandbox.stub(Aws.prototype, 'addData');
     });
 
     afterEach(function() {
@@ -50,6 +56,14 @@ describe('Aws', function() {
       var aws = new Aws(req, serviceName);
       assert.propertyVal(aws, 'operation', 'PutObject');
     });
+
+    it('should capture s3 params: bucket, key', function() {
+      var aws = new Aws(req, serviceName);
+      addDataStub.should.have.been.calledWith({
+        bucket_name: bucketName,
+        key: keyName
+      });
+    });
   });
 
   describe('#addData', function() {