Socket
Socket
Sign inDemoInstall

vxx

Package Overview
Dependencies
14
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.1.1

src/plugins/plugin-connect.js

168

CHANGELOG.md
# Node.js Agent for Google Cloud Trace ChangeLog
## 2017-03-15, Version 1.0.1 (Experimental), @kjin
### Notable changes
**bug fixes**
* [[`ca4b67bd44`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ca4b67bd44)] - Ensure http response streams are paused (#438) (Matthew Loring) [#438](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/438)
**new plugins**
* [[`1ab25b2804`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/1ab25b2804)] - Experimental postgres plugin (#402) (Matthew Loring) [#402](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/402)
* [[`dc41a8b3ab`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/dc41a8b3ab)] - Context propagation for google-gax (#404) (Matthew Loring) [#404](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/404)
**redis**
* [[`72ab6775ce`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/72ab6775ce)] - Support redis 2.7 (#439) (Kelvin Jin) [#439](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/439)
**grpc**
* [[`71cd5c3178`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/71cd5c3178)] - Distributed tracing support in gRPC (#436) (Kelvin Jin) [#436](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/436)
### Commits
* [[`ca4b67bd44`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ca4b67bd44)] - Ensure http response streams are paused (#438) (Matthew Loring) [#438](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/438)
* [[`72ab6775ce`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/72ab6775ce)] - Support redis 2.7 (#439) (Kelvin Jin) [#439](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/439)
* [[`71cd5c3178`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/71cd5c3178)] - Distributed tracing support in gRPC (#436) (Kelvin Jin) [#436](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/436)
* [[`1ab25b2804`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/1ab25b2804)] - Experimental postgres plugin (#402) (Matthew Loring) [#402](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/402)
* [[`dc41a8b3ab`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/dc41a8b3ab)] - Context propagation for google-gax (#404) (Matthew Loring) [#404](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/404)
## 2017-03-01, Version 1.0.0 (Experimental), @matthewloring
This version does not include any changes since 1.0.0-rc1. It is the first publish to the new module name: @google-cloud/trace-agent.
## 2017-02-28, Version 1.0.0-rc1 (Experimental), @matthewloring
### Notable changes
This version introduces a full redesigned API for creating [custom trace spans](doc/trace-api.md) as well as an API
for writing [custom plugins](doc/plugin-guide.md) to instrument modules so tracing information can be reported. Please
check out our docs section for a full description of the changes. While this is a semver major change, we expect
it will only affect users of the custom span api.
In addition to API changes, this release includes the following semver major behavior changes:
- The `databaseResultReportingSize` configuration option has been replaced by the `maximumLabelValueSize` configuration option which applies to all label values (instead of just database results).
- This module now uses the same authentication code as [google-cloud-node](https://github.com/GoogleCloudPlatform/google-cloud-node) API libraries. This changes the precedence of accepting auth credentials via config.credentials vs. config.keyFileName vs. the environment variable GOOGLE_APPLICATION_CREDENTIALS.
### Commits
* [[`a7ff674833`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/a7ff674833)] - fix doc links (#430) (Kelvin Jin) [#430](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/430)
* [[`c1773f4d4f`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/c1773f4d4f)] - Plugin loader throws for plugins with glaring issues (#428) (Kelvin Jin) [#428](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/428)
* [[`d030be1f16`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/d030be1f16)] - Trace API and Plugin Developer Docs (#427) (Kelvin Jin) [#427](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/427)
* [[`2a374fdbc1`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/2a374fdbc1)] - Added Plugin API docs (#362) (Kelvin Jin) [#362](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/362)
* [[`c68c22f8fe`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/c68c22f8fe)] - Test log level correction (#424) (Matthew Loring) [#424](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/424)
* [[`e74b60afda`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/e74b60afda)] - Remove version lower bound check (#423) (Matthew Loring) [#423](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/423)
* [[`f17bd67e37`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f17bd67e37)] - Improve redis code coverage (#422) (Matthew Loring) [#422](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/422)
* [[`1ea81a5032`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/1ea81a5032)] - Test for throw on invalid value for onUncaughtException (#425) (Matthew Loring) [#425](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/425)
* [[`c3435fff3c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/c3435fff3c)] - Look for new app engine env vars during configuration (#421) (Matthew Loring) [#421](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/421)
* [[`2617526bd2`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/2617526bd2)] - Remove trace property from config (#420) (Matthew Loring) [#420](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/420)
* [[`bfa1d4e28f`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/bfa1d4e28f)] - Disambiguate context loss from sampling when creating child spans (#416) (Matthew Loring) [#416](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/416)
* [[`97f87908b9`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/97f87908b9)] - Make TraceWriter a Service object (#417) (Ali Ijaz Sheikh) [#417](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/417)
* [[`39331429e4`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/39331429e4)] - Small test changes (#419) (Kelvin Jin) [#419](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/419)
* [[`eacfa15317`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/eacfa15317)] - New configuration for globally controlled label value sizes (#415) (Matthew Loring) [#415](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/415)
* [[`9032aeaaba`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/9032aeaaba)] - Plugins with falsey paths don't get loaded (#418) (Kelvin Jin) [#418](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/418)
* [[`035d1cc9e9`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/035d1cc9e9)] - Make trace interface uniform between module exports and plugins (#411) (Kelvin Jin) [#411](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/411)
* [[`0772ee0508`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/0772ee0508)] - Fix merging of nest configuration objects (#414) (Matthew Loring) [#414](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/414)
* [[`f5662e0372`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f5662e0372)] - cleanup todos (#395) (Matthew Loring) [#395](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/395)
* [[`a8a6e58ce3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/a8a6e58ce3)] - Remove old hooks mechanism (#410) (Matthew Loring) [#410](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/410)
* [[`aebb3a5601`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/aebb3a5601)] - Expand test-index.js (#409) (Matthew Loring) [#409](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/409)
* [[`08095ae687`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/08095ae687)] - Clean up trace writer error messages (#412) (Matthew Loring) [#412](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/412)
* [[`2cca378d3e`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/2cca378d3e)] - simplify interop-mongo-express (#401) (Matthew Loring) [#401](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/401)
* [[`f9a4b7ba50`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f9a4b7ba50)] - Simplifications in test/common (#408) (Matthew Loring) [#408](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/408)
* [[`33f90fc53c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/33f90fc53c)] - Starting testing on Circle-CI (#407) (Ali Ijaz Sheikh)
* [[`f641802cf2`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f641802cf2)] - Refactor public api to match plugin api (#393) (Matthew Loring) [#393](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/393)
* [[`58b3dd4a4c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/58b3dd4a4c)] - Instrument multiple versions of the same module (#397) (Matthew Loring) [#397](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/397)
* [[`6f05b156d3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/6f05b156d3)] - Consolidate usage of `agent.private_()` (#406) (Dominic Kramer) [#406](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/406)
* [[`60ef26a698`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/60ef26a698)] - Correct broken test (#396) (Matthew Loring) [#396](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/396)
* [[`ecb3ccb218`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ecb3ccb218)] - Reduce dependence on setTimeout timing in testing (#405) (Matthew Loring)
* [[`8553d02a3d`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8553d02a3d)] - Add docker start/stop script for DB unit tests (#385) (Kelvin Jin)
* [[`749821958c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/749821958c)] - Add database result summarization to plugins (#400) (Matthew Loring) [#400](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/400)
* [[`6a307d143d`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/6a307d143d)] - Add stack trace to service network errors (#394) (Matthew Loring) [#394](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/394)
* [[`91e1ccef72`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/91e1ccef72)] - Fix restify non-interference tests (#403) (Matthew Loring) [#403](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/403)
* [[`da804af08d`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/da804af08d)] - Add Express Trace Plugin (#363) (Kelvin Jin) [#363](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/363)
* [[`ff67bef00e`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ff67bef00e)] - Fix for external unit test failures (#388) (Kelvin Jin) [#388](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/388)
* [[`f30bd330ba`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f30bd330ba)] - Add gRPC Plugin (#390) (Kelvin Jin) [#390](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/390)
* [[`533d28af5a`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/533d28af5a)] - Use closures instead of bind in plugins (#391) (Dominic Kramer) [#391](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/391)
* [[`0874b1a23b`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/0874b1a23b)] - Add http plugin (#370) (Cristian Cavalli)
* [[`8e30d88abe`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8e30d88abe)] - Bugfix for creating root spans through plugin API (#389) (Kelvin Jin) [#389](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/389)
* [[`4c2f330e8d`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/4c2f330e8d)] - Support hapi tracing through the plugin API (#379) (Dominic Kramer) [#379](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/379)
* [[`4dc20bf5f3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/4dc20bf5f3)] - Support mysql tracing through the plugin API (#376) (Dominic Kramer) [#376](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/376)
* [[`bb926acf1c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/bb926acf1c)] - Support redis tracing through the plugin API (#377) (Dominic Kramer) [#377](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/377)
* [[`4e20f685d3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/4e20f685d3)] - Support Connect tracing through the plugin API (#381) (Dominic Kramer) [#381](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/381)
* [[`5c5e3e2e70`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/5c5e3e2e70)] - Support mongodb-core tracing through the plugin API (#384) (Dominic Kramer) [#384](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/384)
* [[`0eb389668b`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/0eb389668b)] - Support Koa tracing through the plugin API (#380) (Dominic Kramer) [#380](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/380)
* [[`837b892471`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/837b892471)] - Support restify tracing through the plugin API (#374) (Ali Ijaz Sheikh)
* [[`1cc616b37e`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/1cc616b37e)] - Remove agent.stop() (#378) (Kelvin Jin) [#378](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/378)
* [[`1e109d2c90`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/1e109d2c90)] - Plugin API: Interface change (#386) (Kelvin Jin) [#386](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/386)
* [[`9743556fed`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/9743556fed)] - Plugin API: Added module unpatching and updated tests correspondingly (#383) (Kelvin Jin) [#383](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/383)
* [[`9011c8aca3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/9011c8aca3)] - Plugin API: Loading Improvements (#372) (Kelvin Jin) [#372](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/372)
* [[`b41e921f18`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/b41e921f18)] - Remove agent isRunning/trace isActive (#368) (Matthew Loring) [#368](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/368)
* [[`ad18074227`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ad18074227)] - Run all tests stand alone (#369) (Matthew Loring) [#369](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/369)
* [[`8d34ed46f6`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8d34ed46f6)] - Plugin API: Add createChildSpan (#373) (Kelvin Jin) [#373](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/373)
* [[`b17394d5f1`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/b17394d5f1)] - Plugin API: Additional comments, logging, handling no namespace (#366) (Kelvin Jin)
* [[`c999103951`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/c999103951)] - Remove the trace constructor and rename startAgent (#367) (Dominic Kramer) [#367](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/367)
## 2017-01-19, Version 0.6.1 (Experimental), @matthewloring
### Commits
* [[`8b05415dc5`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8b05415dc5)] - ignore labels unless it is an object (#352) (Ali Ijaz Sheikh)
## 2017-01-13, Version 0.6.0 (Experimental), @matthewloring
### Notable changes
**bug fixes**:
* [[`94e5dad453`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/94e5dad453)] - Limit span names/labels to service limits (#345) (Matthew Loring) [#345](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/345)
* [[`d31798c9d7`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/d31798c9d7)] - Display contents of label values of object type (#346) (Matthew Loring) [#346](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/346)
**configuration**:
* [[`8e46d5f8ed`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8e46d5f8ed)] - Remove unncessary environment variables (#331) (Matthew Loring) [#331](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/331)
**hapi**:
* [[`b89dda8f1b`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/b89dda8f1b)] - Support for hapi 16 (#325) (Matthew Loring) [#325](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/325)
### Commits
* [[`94e5dad453`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/94e5dad453)] - Limit span names/labels to service limits (#345) (Matthew Loring) [#345](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/345)
* [[`d31798c9d7`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/d31798c9d7)] - Display contents of label values of object type (#346) (Matthew Loring) [#346](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/346)
* [[`ca84959c28`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/ca84959c28)] - Ensure agent is always set for mysql/grpc (#343) (Matthew Loring) [#343](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/343)
* [[`4e6670363c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/4e6670363c)] - Address system dependence of sed in tests (#339) (Dominic Kramer) [#339](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/339)
* [[`8aed09d156`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8aed09d156)] - Removed dependency on cloud-diagnostics-common (#338) (Kelvin Jin) [#338](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/338)
* [[`f5401db6bb`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f5401db6bb)] - Add `coverage` to `.gitignore` (#336) (Dominic Kramer) [#336](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/336)
* [[`60cf051967`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/60cf051967)] - Specify package name in version string (#335) (Matthew Loring) [#335](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/335)
* [[`8e46d5f8ed`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/8e46d5f8ed)] - Remove unncessary environment variables (#331) (Matthew Loring) [#331](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/331)
* [[`422c9508ee`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/422c9508ee)] - Rename the `lib` directory to `src` (#333) (Dominic Kramer) [#333](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/333)
* [[`04b3b31023`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/04b3b31023)] - Add AUTHORS file (#332) (Matthew Loring) [#332](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/332)
* [[`aa5da46bf8`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/aa5da46bf8)] - Fix typo in `parseContextFromHeader` comment (#329) (Adri Van Houdt)
* [[`398f46c33f`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/398f46c33f)] - hapi versions in README.md were out of sync (#328) (Ali Ijaz Sheikh)
* [[`00a9ec7b07`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/00a9ec7b07)] - Fix some typos in the README (#323) (Dominic Kramer)
* [[`b89dda8f1b`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/b89dda8f1b)] - Support for hapi 16 (#325) (Matthew Loring) [#325](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/325)
* [[`598366f194`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/598366f194)] - Add badges + update dependencies (#324) (Matthew Loring) [#324](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/324)
* [[`63e7aae593`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/63e7aae593)] - Begin testing against v7 on travis (#322) (Matthew Loring) [#322](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/322)
## 2016-11-11, Version 0.5.10 (Experimental), @matthewloring
### Commits
* [[`43b79b9e1c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/43b79b9e1c)] - Remove query parameters from span names (#320) (Matthew Loring) [#320](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/320)
## 2016-10-31, Version 0.5.9 (Experimental), @matthewloring
### Notable changes
**configuration**:
* [[`f72983f4c3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f72983f4c3)] - Implemented reading keyFile/credentials field from config object (#315) (Kelvin Jin)
### Commits
* [[`372f81a1a6`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/372f81a1a6)] - Stackdriver is lower case d (#318) (Steren)
* [[`f72983f4c3`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/f72983f4c3)] - Implemented reading keyFile/credentials field from config object (#315) (Kelvin Jin)
* [[`a1650a414c`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/a1650a414c)] - fix(docs): fix typo in installation docs (#313) (Michael Prentice) [#313](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/313)
* [[`47b35d4bcc`](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/commit/47b35d4bcc)] - Correct mysql supported version and update framework support list (#310) (Matthew Loring) [#310](https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/pull/310)
## 2016-10-03, Version 0.5.8 (Experimental), @matthewloring

@@ -4,0 +172,0 @@

82

config.js

@@ -16,7 +16,13 @@ /**

*/
/**
* This file has been modified by Keymetrics
*/
'use strict';
var path = require('path');
// Default configuration
module.exports = {
trace: {
// Log levels: 0-disabled,1-error,2-warn,3-info,4-debug

@@ -31,20 +37,46 @@ logLevel: 1,

// The maximum result size in characters to report on database spans if
// `enhancedDatabaseReporting` is enabled.
databaseResultReportingSize: 127,
// The maximum number of characters reported on a label value. This
// cannot exceed 16383, the maximum value accepted by the service.
maximumLabelValueSize: 512,
// Valid entries are:
// 'express', 'hapi', 'http', 'restify'
excludedHooks: [],
// A list of trace plugins to load. Each field's key in this object is the
// name of the module to trace, and its value is the require-friendly path
// to the plugin.
// By default, all of the following plugins are loaded.
// Specifying a different object for this field in the configuration passed
// to the method that starts the trace agent will cause that object to be
// merged with this one.
// To disable a plugin in this list, you may override its path with a falsey
// value. Disabling any of the default plugins may cause unwanted behavior,
// so use caution.
plugins: {
'connect': path.join(__dirname, 'src/plugins/plugin-connect.js'),
'express': path.join(__dirname, 'src/plugins/plugin-express.js'),
'google-gax': path.join(__dirname, 'src/plugins/plugin-google-gax.js'),
'grpc': path.join(__dirname, 'src/plugins/plugin-grpc.js'),
'hapi': path.join(__dirname, 'src/plugins/plugin-hapi.js'),
'http': path.join(__dirname, 'src/plugins/plugin-http.js'),
'koa': path.join(__dirname, 'src/plugins/plugin-koa.js'),
'mongodb-core': path.join(__dirname, 'src/plugins/plugin-mongodb-core.js'),
'mysql': path.join(__dirname, 'src/plugins/plugin-mysql.js'),
'pg': path.join(__dirname, 'src/plugins/plugin-pg.js'),
'redis': path.join(__dirname, 'src/plugins/plugin-redis.js'),
'restify': path.join(__dirname, 'src/plugins/plugin-restify.js')
},
// @type {number} max number of frames to include on traces (0 disables)
stackTraceLimit: 10,
stackTraceLimit: 20,
// Not used
// We buffer the captured traces for `flushDelaySeconds` before publishing
// to the trace API; unless the buffer fills up before then.
// See `bufferSize`.
flushDelaySeconds: 30,
// This filter will exclude trace before any rate is applied
// For each entry key, there is an array of value that might matching
// if any of these value are matched, trace are ignored
// Any value can be string or regex
// If paths are present in this array, then these paths will be ignored before
// `samplingRate` based decisions are made. Paths must include a leading
// forward slash and be of the form:
// /componentOne/componentTwo/...
// Paths can additionally be classified by regex in which case any path matching
// any provided regex will be ignored.
// We ignore the health checker probes (/_ah/health) by default.
ignoreFilter: {

@@ -61,4 +93,5 @@ 'url': [],

// Not used
bufferSize: 5,
// The number of transactions we buffer before we publish to the trace
// API, unless we hit `flushDelaySeconds` first.
bufferSize: 1000,

@@ -91,4 +124,17 @@ // Specifies the behavior of the trace agent in the case of an uncaught exception.

// projects.
ignoreContextHeader: false
}
ignoreContextHeader: false,
// The contents of a key file. If this field is set, its contents will be
// used for authentication instead of your application default credentials.
credentials: null,
// A path to a key file relative to the current working directory. If this
// field is set, the contents of the pointed file will be used for
// authentication instead of your application default credentials.
// If credentials is also set, the value of keyFilename will be ignored.
keyFilename: null,
// For testing purposes only.
// Used by unit tests to force loading of a new agent if one exists already.
forceNewAgent_: false
};

@@ -17,2 +17,6 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';

@@ -26,8 +30,8 @@

var SpanData = require('./src/span-data.js');
var Logger = require('./src/logger.js');
var semver = require('semver');
var extend = require('extend');
var constants = require('./src/constants.js');
var path = require('path');
var util = require('./src/util.js');
var traceUtil = require('./src/util.js');
var TraceApi = require('./src/trace-api.js');
var pluginLoader = require('./src/trace-plugin-loader.js');

@@ -37,3 +41,3 @@ var modulesLoadedBeforeTrace = [];

for (var i = 0; i < filesLoadedBeforeTrace.length; i++) {
var moduleName = util.packageNameFromPath(filesLoadedBeforeTrace[i]);
var moduleName = traceUtil.packageNameFromPath(filesLoadedBeforeTrace[i]);
if (moduleName && moduleName !== 'vxx' &&

@@ -47,140 +51,83 @@ modulesLoadedBeforeTrace.indexOf(moduleName) === -1) {

/**
* Phantom implementation of the trace agent. This allows API users to decouple
* the enable/disable logic from the calls to the tracing API. The phantom API
* has a lower overhead than isEnabled checks inside the API functions.
* @private
*/
var phantomTraceAgent = {
startSpan: function() { return SpanData.nullSpan; },
endSpan: function(spanData) { spanData.close(); },
runInSpan: function(name, labels, fn) {
if (typeof(labels) === 'function') {
fn = labels;
}
fn(function() {});
},
runInRootSpan: function(name, labels, fn) {
if (typeof(labels) === 'function') {
fn = labels;
}
fn(function() {});
},
setTransactionName: function() {},
addTransactionLabel: function() {}
};
/** @private */
var agent = phantomTraceAgent;
var initConfig = function(projectConfig) {
var util = require('util');
var config = {};
util._extend(config, require('./config.js').trace);
util._extend(config, projectConfig);
var config = extend(true, {}, require('./config.js'), projectConfig);
if (config.maximumLabelValueSize > constants.TRACE_SERVICE_LABEL_VALUE_LIMIT) {
config.maximumLabelValueSize = constants.TRACE_SERVICE_LABEL_VALUE_LIMIT;
}
return config;
};
var traceApi = new TraceApi('Custom Span API');
var agent;
/**
* The singleton public agent. This is the public API of the module.
* Start the Trace agent that will make your application available for
* tracing with Stackdriver Trace.
*
* @param {object=} config - Trace configuration
*
* @resource [Introductory video]{@link
* https://www.youtube.com/watch?v=NCFDqeo7AeY}
*
* @example
* trace.start();
*/
var publicAgent = {
isActive: function() {
return agent !== phantomTraceAgent;
},
function start(projectConfig) {
var config = initConfig(projectConfig);
getAgent: function() {
return agent;
},
getCls : function() {
return agent.getCls()
},
if (traceApi.isActive() && !config.forceNewAgent_) { // already started.
throw new Error('Cannot call start on an already started agent.');
}
getBus : function() {
return agent.traceWriter;
},
if (!config.enabled) {
return traceApi;
}
startSpan: function(name, labels) {
return agent.startSpan(name, labels);
},
if (config.logLevel < 0) {
config.logLevel = 0;
} else if (config.logLevel >= Logger.LEVELS.length) {
config.logLevel = Logger.LEVELS.length - 1;
}
var logger = new Logger(config.logLevel, config.logger === 'debug' ? 'vxx' : undefined);
endSpan: function(spanData, labels) {
return agent.endSpan(spanData, labels);
},
if (onUncaughtExceptionValues.indexOf(config.onUncaughtException) === -1) {
logger.error('The value of onUncaughtException should be one of ',
onUncaughtExceptionValues);
throw new Error('Invalid value for onUncaughtException configuration.');
}
runInSpan: function(name, labels, fn) {
return agent.runInSpan(name, labels, fn);
},
var headers = {};
headers[constants.TRACE_AGENT_REQUEST_HEADER] = 1;
runInRootSpan: function(name, labels, fn) {
return agent.runInRootSpan(name, labels, fn);
},
if (modulesLoadedBeforeTrace.length > 0) {
logger.warn('Tracing might not work as the following modules ' +
'were loaded before the trace agent was initialized: ' +
JSON.stringify(modulesLoadedBeforeTrace));
}
setTransactionName: function(name) {
return agent.setTransactionName(name);
},
agent = require('./src/trace-agent.js').get(config, logger);
traceApi.enable_(agent);
pluginLoader.activate(agent);
addTransactionLabel: function(key, value) {
return agent.addTransactionLabel(key, value);
},
traceApi.getCls = function() {
return agent.getCls();
};
start: function(projectConfig) {
if (this.isActive()) { // already started.
agent.logger.warn('Calling start on already started agent.' +
'New configuration will be ignored.');
return this;
}
traceApi.getBus = function() {
return agent.traceWriter;
};
var config = initConfig(projectConfig);
if (!config.enabled) {
return this;
}
var logger = new Logger(config.logLevel, 'vxx');
if (!semver.satisfies(process.versions.node, '>=0.12')) {
logger.error('Tracing is only supported on Node versions >=0.12');
return this;
}
return traceApi;
}
if (onUncaughtExceptionValues.indexOf(config.onUncaughtException) === -1) {
logger.error('The value of onUncaughtException should be one of ',
onUncaughtExceptionValues);
throw new Error('Invalid value for onUncaughtException configuration.');
}
function get() {
return traceApi;
}
var headers = {};
headers[constants.TRACE_AGENT_REQUEST_HEADER] = 1;
if (modulesLoadedBeforeTrace.length > 0) {
logger.error('Tracing might not work as the following modules ' +
'were loaded before the trace agent was initialized: ' +
JSON.stringify(modulesLoadedBeforeTrace));
}
agent = require('./src/trace-agent.js').get(config, logger);
return this; // for chaining
},
get: function() {
if (this.isActive()) {
return this;
}
throw new Error('The agent must be initialized by calling start.');
},
stop: function() {
if (this.isActive()) {
agent.stop();
agent = phantomTraceAgent;
}
},
/**
* For use in tests only.
* @private
*/
private_: function() { return agent; }
global._google_trace_agent = traceApi;
module.exports = {
start: start,
get: get
};
module.exports = global._km_trace_agent = publicAgent;
// If the module was --require'd from the command line, start the agent.

@@ -187,0 +134,0 @@ if (module.parent && module.parent.id === 'internal/preload') {

{
"name": "vxx",
"version": "1.0.3",
"description": "VXX",
"version": "1.1.1",
"description": "Node.js Tracing Driver",
"main": "index.js",
"repository": "keymetrics/vxx",
"scripts": {
"test": "GCLOUD_PROJECT=2 NODE_ENV=COGTEST ./bin/run-test.sh",
"test": "./bin/run-test.sh",
"changelog": "./bin/run-changelog.sh",

@@ -27,18 +27,21 @@ "coverage": "./bin/run-test.sh -c",

"mocha": "^3.0.0",
"nock": "^8.0.0",
"proxyquire": "^1.4.0",
"request": "^2.61.0",
"timekeeper": "^0.1.1",
"tmp": "0.0.28"
"retry-request": "^1.3.2",
"timekeeper": "^1.0.0",
"tmp": "0.0.31"
},
"dependencies": {
"continuation-local-storage": "^3.1.4",
"debug": "^2.2.0",
"debug": "^2.6.3",
"extend": "^3.0.0",
"is": "^3.2.0",
"lodash.findindex": "^4.4.0",
"lodash.isequal": "^4.0.0",
"lodash.merge": "^4.6.0",
"methods": "^1.1.1",
"semver": "^5.0.1",
"shimmer": "^1.0.0",
"uuid": "^2.0.1"
"uuid": "^3.0.1"
}
}

@@ -17,2 +17,6 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';

@@ -19,0 +23,0 @@

@@ -21,6 +21,6 @@ /**

/** @const {string} header that carries trace context across Google infrastructure. */
TRACE_CONTEXT_HEADER_NAME: 'x-km-trace-context',
TRACE_CONTEXT_HEADER_NAME: 'x-cloud-trace-context',
/** @const {string} header that is used to identify outgoing http made by the agent. */
TRACE_AGENT_REQUEST_HEADER: 'x-km-trace-agent-request',
TRACE_AGENT_REQUEST_HEADER: 'x-cloud-trace-agent-request',

@@ -27,0 +27,0 @@ /** @const {number} bitmask to determine whether trace is enabled in trace options. */

/**
* Copyright 2015 Google Inc. All Rights Reserved.
* Copyright 2017 Keymetrics. All Rights Reserved.
*

@@ -19,4 +19,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var debug = console.log;
var LEVELS = ['disabled', 'error', 'warn', 'info', 'debug']
var debug = console.log;
var LEVELS = ['disabled', 'error', 'warn', 'info', 'debug'];

@@ -27,5 +27,6 @@ /**

*/
function Logger(level, name) {
if (name)
debug = require('debug')(name);
function Logger (level, name) {
if (name) {
debug = require('debug')(typeof name === 'string' ? name : 'vxx');
}
this.level = level;

@@ -36,21 +37,26 @@ this.debug('Logger started');

Logger.prototype.error = function () {
if (LEVELS.indexOf('error') <= this.level)
if (LEVELS.indexOf('error') <= this.level) {
debug.apply(this, arguments);
}
}
};
Logger.prototype.warn = function () {
if (LEVELS.indexOf('warn') <= this.level)
if (LEVELS.indexOf('warn') <= this.level) {
debug.apply(this, arguments);
}
}
};
Logger.prototype.info = function () {
if (LEVELS.indexOf('info') <= this.level)
if (LEVELS.indexOf('info') <= this.level) {
debug.apply(this, arguments);
}
}
};
Logger.prototype.debug = function () {
if (LEVELS.indexOf('debug') <= this.level)
if (LEVELS.indexOf('debug') <= this.level) {
debug.apply(this, arguments);
}
}
};
Logger.LEVELS = LEVELS;
module.exports = Logger;

@@ -19,4 +19,8 @@ /**

var constants = require('./constants.js');
var is = require('is');
var TraceSpan = require('./trace-span.js');
var TraceLabels = require('./trace-labels.js');
var traceUtil = require('./util.js');
var util = require('util');

@@ -38,3 +42,4 @@ // Auto-incrementing integer

this.agent = agent;
this.span = new TraceSpan(name, spanId, parentSpanId);
var spanName = traceUtil.truncate(name, constants.TRACE_SERVICE_SPAN_NAME_LIMIT);
this.span = new TraceSpan(spanName, spanId, parentSpanId);
this.trace = trace;

@@ -75,4 +80,7 @@ this.isRoot = isRoot;

});
// Set the label on the trace span directly to bypass truncation to
// config.maxLabelValueSize.
this.span.setLabel(TraceLabels.STACK_TRACE_DETAILS_KEY,
JSON.stringify({stack_frame: stackFrames}));
traceUtil.truncate(JSON.stringify({stack_frame: stackFrames}),
constants.TRACE_SERVICE_LABEL_VALUE_LIMIT));

@@ -97,6 +105,24 @@ Error.stackTraceLimit = origLimit;

SpanData.prototype.addLabel = function(key, value) {
this.span.setLabel(key, value);
var k = traceUtil.truncate(key, constants.TRACE_SERVICE_LABEL_KEY_LIMIT);
var string_val = typeof value === 'string' ? value : util.inspect(value);
var v = traceUtil.truncate(string_val, this.agent.config().maximumLabelValueSize);
this.span.setLabel(k, v);
};
/**
* Add properties from provided `labels` param to the span as labels.
*
* @param {Object<string, string}>=} labels Labels to be attached to the newly
* created span. Non-object data types are silently ignored.
*/
SpanData.prototype.addLabels = function(labels) {
var that = this;
if (is.object(labels)) {
Object.keys(labels).forEach(function(key) {
that.addLabel(key, labels[key]);
});
}
};
/**
* Closes the span and queues it for publishing if it is a root.

@@ -147,8 +173,2 @@ */

SpanData.nullSpan = {
createChildSpanData: function() { return SpanData.nullSpan; },
addLabel: function() {},
close: function() {}
};
/**

@@ -155,0 +175,0 @@ * Export SpanData.

@@ -17,6 +17,9 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';
var cls = require('./cls');
var hooks = require('./hooks/index.js');
var Trace = require('./trace.js');

@@ -29,2 +32,3 @@ var SpanData = require('./span-data.js');

var isEqual = require('lodash.isequal');
var util = require('./util.js');

@@ -41,7 +45,7 @@ /** @type {TraceAgent} */

hooks.activate(this);
this.namespace = cls.createNamespace();
this.traceWriter = new TraceWriter(logger, config);
this.policy = tracingPolicy.createTracePolicy(config);
this.getCls = function() {

@@ -51,7 +55,5 @@ return cls;

this.policy = tracingPolicy.createTracePolicy(config);
if (config.onUncaughtException !== 'ignore') {
this.unhandledException = function() {
traceAgent.traceWriter.flushBuffer_();
traceAgent.traceWriter.flushBuffer_(traceAgent.config_.projectId);
if (config.onUncaughtException === 'flushAndExit') {

@@ -73,5 +75,10 @@ setTimeout(function() {

TraceAgent.prototype.stop = function() {
hooks.deactivate();
// Even though plugins should be unpatched, setting a new policy that
// never generates traces allows persisting wrapped methods (either because
// they are already instantiated or the plugin doesn't unpatch them) to
// short-circuit out of trace generation logic.
this.policy = new tracingPolicy.TraceNonePolicy();
// Stop the trace writer from publishing any new traces.
this.traceWriter.stop();
cls.destroyNamespace();
this.traceWriter.stop();
this.namespace = null;

@@ -97,3 +104,3 @@ traceAgent = null;

* @param {Object<string, string}>=} labels Labels to be attached
* to the newly created span.
* to the newly created span. Non-object data types are silently ignored.
* @param {number=} skipFrames The number of caller frames to eliminate from

@@ -108,7 +115,3 @@ * stack traces.

var newSpan = rootSpan.createChildSpanData(name, skipFrames + 1);
if (labels) {
Object.keys(labels).forEach(function(key) {
newSpan.addLabel(key, labels[key]);
});
}
newSpan.addLabels(labels);
return newSpan;

@@ -126,10 +129,6 @@ } else {

* @param {Object<string, string}>=} labels Labels to be attached
* to the terminated span.
* to the terminated span. Non-object data types are silently ignored.
*/
TraceAgent.prototype.endSpan = function(spanData, labels) {
if (labels) {
Object.keys(labels).forEach(function(key) {
spanData.addLabel(key, labels[key]);
});
}
spanData.addLabels(labels);
spanData.close();

@@ -139,105 +138,13 @@ };

/**
* Run the provided function in a new span with the provided name.
* If the provided function accepts a parameter, it is assumed to be
* async and is given a continuation to terminate the span after its
* work is completed.
* @param {string} name The name of the resulting span.
* @param {Object<string, string}>=} labels Labels to be attached
* to the resulting span.
* @param {function(function()=)} fn The function to trace.
*/
TraceAgent.prototype.runInSpan = function(name, labels, fn) {
if (typeof(labels) === 'function') {
fn = labels;
labels = undefined;
}
var span = this.startSpan(name, labels, 1);
if (fn.length === 0) {
fn();
this.endSpan(span);
} else {
fn(this.endSpan.bind(this, span));
}
};
/**
* Run the provided function in a new root span with the provided
* name. As with runInSpan, if the provided function accepts a parameter,
* it is assumed to be asynchronous, and a callback will be passed
* to the function to terminate the root span.
* @param {string} name The name of the resulting root span.
* @param {Object<string, string}>=} labels Labels to be attached
* to the resulting span.
* @param {function(function()=)} fn The function to trace.
*/
TraceAgent.prototype.runInRootSpan = function(name, labels, fn) {
if (typeof(labels) === 'function') {
fn = labels;
labels = undefined;
}
var self = this;
this.namespace.run(function () {
if (cls.getRootContext()) {
self.logger.error('Can\'t nest root spans');
return;
}
var span = self.createRootSpanData(name, null, null, 3, 'SPAN_KIND_UNSPECIFIED');
if (labels) {
Object.keys(labels).forEach(function(key) {
span.addLabel(key, labels[key]);
});
}
if (fn.length === 0) {
fn();
span.close();
} else {
fn(function () {
span.close();
});
}
});
};
/**
* Set the name of the root transaction.
* @param {string} name The new name for the current root transaction.
*/
TraceAgent.prototype.setTransactionName = function(name) {
var rootSpan = cls.getRootContext();
if (rootSpan === SpanData.nullSpan) {
return;
}
if (rootSpan) {
rootSpan.span.name = name;
} else {
this.logger.error('Cannot set transaction name without an active transaction');
}
};
/**
* Add a new key value label to the root transaction.
* @param {string} key The key for the new label.
* @param {string} value The value for the new label.
*/
TraceAgent.prototype.addTransactionLabel = function(key, value) {
var rootSpan = cls.getRootContext();
if (rootSpan) {
rootSpan.addLabel(key, value);
} else {
this.logger.error('Cannot add label without an active transaction');
}
};
/**
* Determines whether a trace of the given name should be recorded based
* on the current tracing policy.
*
* @param {object} request object
* @param {!number} options the trace header options
* @param {string} options the req metadata
* @param {!number} headerOptions the trace header options
*/
TraceAgent.prototype.shouldTrace = function(request, options) {
var locallyAllowed = this.policy.shouldTrace(Date.now(), request);
TraceAgent.prototype.shouldTrace = function(options, headerOptions) {
var locallyAllowed = this.policy.shouldTrace(Date.now(), options);
// Note: remotelyDisallowed is false if no trace options are present.
var remotelyDisallowed = !(isNaN(options) ||
(options & constants.TRACE_OPTIONS_TRACE_ENABLED));
var remotelyDisallowed = !(isNaN(headerOptions) ||
(headerOptions & constants.TRACE_OPTIONS_TRACE_ENABLED));
return locallyAllowed && !remotelyDisallowed;

@@ -278,7 +185,5 @@ };

/**
* Parse a cookie-style header string to extract traceId, spandId and options
* ex: '123456/667;o=3'
* -> {traceId: '123456', spanId: '667', options: '3'}
* note that we ignore trailing garbage if there is more than one '='
* Returns null if traceId or spanId are could not be found.
* Parse a cookie-style header string to extract traceId, spandId and options,
* or returns null if the agent has been configured to ignore it.
* @see util.parseContextFromHeader
*

@@ -293,15 +198,3 @@ * @param {string} str string representation of the trace headers

}
if (!str) {
return null;
}
var matches = str.match(/^([0-9a-fA-F]+)(?:\/([0-9a-fA-F]+))?(?:;o=(.*))?/);
if (!matches || matches.length !== 4 || matches[0] !== str ||
(matches[2] && isNaN(matches[2]))) {
return null;
}
return {
traceId: matches[1],
spanId: matches[2],
options: Number(matches[3])
};
return util.parseContextFromHeader(str);
};

@@ -331,3 +224,3 @@

get: function(config, logger) {
if (traceAgent) {
if (traceAgent && !config.forceNewAgent_) {
if (!isEqual(config, traceAgent.config_)) {

@@ -334,0 +227,0 @@ traceAgent.logger.warn('New configuration does not match configuration' +

@@ -17,2 +17,6 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';

@@ -23,4 +27,3 @@

*/
function TraceLabels() {
}
var TraceLabels = {};

@@ -32,4 +35,8 @@

TraceLabels.HTTP_RESPONSE_CODE_LABEL_KEY =
'http/status_code';
'http/status_code';
/**
* @type {string} The well-known label for http request path.
*/
TraceLabels.HTTP_PATH_LABEL_KEY = 'http/path';

@@ -41,3 +48,2 @@ /**

/**

@@ -54,7 +60,2 @@ * @type {string} The well-known label for http method.

/**
* @type {string} The well-known label for http path.
*/
TraceLabels.HTTP_PATH_LABEL_KEY = 'http/path';
/**
* @type {string} The well-known label for stack-traces

@@ -75,2 +76,29 @@ */

/**
* @type {string} The well-known label for the app version on AppEngine.
*/
TraceLabels.GAE_VERSION = 'trace.cloud.google.com/gae/app/version';
/**
* @type {string} The well-known label for the module name on AppEngine.
*/
TraceLabels.GAE_MODULE_NAME = 'trace.cloud.google.com/gae/app/module';
/**
* @type {string} The well-known label for the module version on AppEngine.
*/
TraceLabels.GAE_MODULE_VERSION = 'trace.cloud.google.com/gae/app/module_version';
/**
* @type {string} The label for GCE instance id. This is not a label
* recognized by the trace API.
*/
TraceLabels.GCE_INSTANCE_ID = 'trace.cloud.google.com/gce/instanceid';
/**
* @type {string} The label for GCE hostname. This is not a label
* recognized by the trace API.
*/
TraceLabels.GCE_HOSTNAME = 'trace.cloud.google.com/gce/hostname';
/**
* @type {string} The label for http request source ip. This is not a

@@ -77,0 +105,0 @@ * label recognized by the trace API.

@@ -19,21 +19,3 @@ /**

var util = require('util');
var constants = require('./constants.js');
/**
* Truncates the provided `string` to be at most `length` bytes
* after utf8 encoding and the appending of '...'.
* We produce the result by iterating over input characters to
* avoid truncating the string potentially producing partial unicode
* characters at the end.
*/
function truncate(string, length) {
string = string.substr(0, length - 3);
while (Buffer.byteLength(string, 'utf8') > length - 3) {
string = string.substr(0, string.length - 1);
}
return string + '...';
}
/**
* Creates a trace span object.

@@ -43,7 +25,3 @@ * @constructor

function TraceSpan(name, spanId, parentSpanId) {
if (Buffer.byteLength(name, 'utf8') > constants.TRACE_SERVICE_SPAN_NAME_LIMIT) {
this.name = truncate(name, constants.TRACE_SERVICE_SPAN_NAME_LIMIT);
} else {
this.name = name;
}
this.name = name;
this.parentSpanId = parentSpanId;

@@ -64,10 +42,3 @@ this.spanId = spanId;

TraceSpan.prototype.setLabel = function(key, value) {
if (Buffer.byteLength(key, 'utf8') > constants.TRACE_SERVICE_LABEL_KEY_LIMIT) {
key = truncate(key, constants.TRACE_SERVICE_LABEL_KEY_LIMIT);
}
var val = typeof value === 'object' ? util.inspect(value) : '' + value;
if (Buffer.byteLength(val, 'utf8') > constants.TRACE_SERVICE_LABEL_VALUE_LIMIT) {
val = truncate(val, constants.TRACE_SERVICE_LABEL_VALUE_LIMIT);
}
this.labels[key] = val;
this.labels[key] = value;
};

@@ -74,0 +45,0 @@

@@ -17,8 +17,12 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';
var util = require('util');
var traceLabels = require('./trace-labels.js');
var pjson = require('../package.json');
var constants = require('./constants.js');
var EventEmitter = require('events').EventEmitter;
var EventEmitter = require('events').EventEmitter;

@@ -30,11 +34,17 @@ var headers = {};

* Creates a basic trace writer.
* @param {!Logger} logger
* @param {!Logger} logger The Trace Agent's logger object.
* @param {Object} config A config object containing information about
* authorization credentials.
* @constructor
*/
function TraceWriter(logger, config) {
/** @private */
function TraceWriter(logger, options) {
options = options || {};
EventEmitter.call(this);
/** @private */
this.logger_ = logger;
/** @private */
this.config_ = config;
this.config_ = options;

@@ -51,3 +61,3 @@ /** @private {Array<string>} stringified traces to be published */

TraceWriter.prototype.__proto__ = EventEmitter.prototype;
util.inherits(TraceWriter, EventEmitter);

@@ -77,6 +87,7 @@ TraceWriter.prototype.stop = function() {

}
if (process.env.NODE_ENV === 'test') {
this.queueTrace_(spanData.trace);
}
this.emit('transaction', spanData.trace);
if (process.env.NODE_ENV === 'test')
this.queueTrace_(spanData.trace);
};

@@ -141,4 +152,4 @@

*/
TraceWriter.prototype.publish_ = function(json) {
if (process.send)
TraceWriter.prototype.publish_ = function(projectId, json) {
if (process.send) {
process.send({

@@ -148,2 +159,3 @@ type: 'axm:trace',

});
}
};

@@ -150,0 +162,0 @@

@@ -17,2 +17,6 @@ /**

/**
* This file has been modified by Keymetrics
*/
'use strict';

@@ -36,14 +40,15 @@

function FilterPolicy(basePolicy, filters) {
function FilterPolicy (basePolicy, filters) {
this.basePolicy = basePolicy;
this.filters = filters;
this.filters['name'] = this.filters['path'];
}
FilterPolicy.prototype.matches = function(request) {
FilterPolicy.prototype.matches = function (request) {
var self = this, match = false;
Object.keys(request).forEach(function (key) {
if (!(self.filters[key] instanceof Array)) return ;
if (!(self.filters[key] instanceof Array)) return;
return self.filters[key].some(function(candidate) {
match = match ? true : ((typeof candidate === 'string' && request[key].indexOf(candidate) > -1) ||
return self.filters[key].some(function (candidate) {
match = match ? true : ((typeof candidate === 'string' && request[key] === candidate) ||
(candidate instanceof RegExp && request[key].match(candidate)));

@@ -55,3 +60,3 @@ });

FilterPolicy.prototype.shouldTrace = function(dataMillis, request) {
FilterPolicy.prototype.shouldTrace = function (dataMillis, request) {
return !this.matches(request) && this.basePolicy.shouldTrace(dataMillis, request);

@@ -64,15 +69,20 @@ };

function TraceNonePolicy() {}
TraceNonePolicy.prototype.shouldTrace = function() { return false; };
module.exports = {
createTracePolicy: function(config) {
var basePolicy = config.samplingRate < 1 ? new TraceAllPolicy() : new RateLimiterPolicy(config.samplingRate);
if (!config.ignoreFilter) return basePolicy;
TraceAllPolicy: TraceAllPolicy,
TraceNonePolicy: TraceNonePolicy,
FilterPolicy: FilterPolicy,
createTracePolicy: function (config) {
var basePolicy = config.samplingRate < 1 ? new TraceAllPolicy() : new RateLimiterPolicy(config.samplingRate);
// search for a filter to apply
Object.keys(config.ignoreFilter).forEach(function (filter) {
if (config.ignoreFilter[filter].length > 0)
basePolicy = new FilterPolicy(basePolicy, config.ignoreFilter);
})
var hasFilter = Object.keys(config.ignoreFilter || []).some(function (filter) {
return config.ignoreFilter[filter].length > 0;
});
// if no filter has been set fallback to base policy
return basePolicy;
return hasFilter ? new FilterPolicy(basePolicy, config.ignoreFilter) : basePolicy;
}
};

@@ -19,49 +19,22 @@ /**

var Module = require('module');
var fs = require('fs');
var path = require('path');
/**
* Produces an object summarization of limited size. This summarization
* does not adhere to the JSON spec so it cannot be reparsed even if
* the entire object fits inside the desired size.
*
* @param {Object} o The object to be summarized.
* @param {number} n Max length of the summary.
* Truncates the provided `string` to be at most `length` bytes
* after utf8 encoding and the appending of '...'.
* We produce the result by iterating over input characters to
* avoid truncating the string potentially producing partial unicode
* characters at the end.
*/
function stringifyPrefix(o, n) {
var buf = new Buffer(n);
var pos = 0;
var worklist = [];
function pushObject(o) {
var keys = Object.keys(o);
for (var i = Math.min(keys.length - 1, Math.floor(n/4)); i >= 0; i--) {
worklist.push((i === keys.length - 1) ? '}' : ',');
worklist.push(o[keys[i]]);
worklist.push(':');
worklist.push(keys[i]);
}
worklist.push('{');
function truncate(string, length) {
if (Buffer.byteLength(string, 'utf8') <= length) {
return string;
}
worklist.push(o);
while (worklist.length > 0) {
var elem = worklist.pop();
if (elem && typeof elem === 'object') {
pushObject(elem);
} else {
var val;
if (typeof elem === 'function') {
val = '[Function]';
} else if (typeof elem === 'string') {
val = elem;
} else {
// Undefined, Null, Boolean, Number, Symbol
val = String(elem);
}
pos += buf.write(val, pos);
if (buf.length === pos) {
buf.write('...', pos - 3);
break;
}
}
string = string.substr(0, length - 3);
while (Buffer.byteLength(string, 'utf8') > length - 3) {
string = string.substr(0, string.length - 1);
}
return buf.toString('utf8', 0, pos);
return string + '...';
}

@@ -82,2 +55,29 @@

/**
* Parse a cookie-style header string to extract traceId, spandId and options
* ex: '123456/667;o=3'
* -> {traceId: '123456', spanId: '667', options: '3'}
* note that we ignore trailing garbage if there is more than one '='
* Returns null if traceId or spanId could not be found.
*
* @param {string} str string representation of the trace headers
* @return {?{traceId: string, spanId: string, options: number}}
* object with keys. null if there is a problem.
*/
function parseContextFromHeader(str) {
if (!str) {
return null;
}
var matches = str.match(/^([0-9a-fA-F]+)(?:\/([0-9a-fA-F]+))?(?:;o=(.*))?/);
if (!matches || matches.length !== 4 || matches[0] !== str ||
(matches[2] && isNaN(matches[2]))) {
return null;
}
return {
traceId: matches[1],
spanId: matches[2],
options: Number(matches[3])
};
}
/**
* Retrieves a package name from the full import path.

@@ -94,5 +94,44 @@ * For example:

/**
* Determines the path at which the requested module will be loaded given
* the provided parent module.
*
* @param {string} request The name of the module to be loaded.
* @param {object} parent The module into which the requested module will be loaded.
*/
function findModulePath(request, parent) {
var mainScriptDir = path.dirname(Module._resolveFilename(request, parent));
var resolvedModule = Module._resolveLookupPaths(request, parent);
var paths = resolvedModule[1];
for (var i = 0, PL = paths.length; i < PL; i++) {
if (mainScriptDir.indexOf(paths[i]) === 0) {
return path.join(paths[i], request.replace('/', path.sep));
}
}
return null;
}
/**
* Determines the version of the module located at `modulePath`.
*
* @param {?string} modulePath The absolute path to the root directory of the
* module being loaded. This may be null if we are loading an internal module
* such as http.
*/
function findModuleVersion(modulePath, load) {
if (modulePath) {
var pjson = path.join(modulePath, 'package.json');
if (fs.existsSync(pjson)) {
return load(pjson).version;
}
}
return process.version;
}
module.exports = {
stringifyPrefix: stringifyPrefix,
packageNameFromPath: packageNameFromPath
truncate: truncate,
parseContextFromHeader: parseContextFromHeader,
packageNameFromPath: packageNameFromPath,
findModulePath: findModulePath,
findModuleVersion: findModuleVersion
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc