Socket
Socket
Sign inDemoInstall

@google-cloud/trace-agent

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/trace-agent - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

10

build/src/index.js

@@ -102,3 +102,2 @@ "use strict";

[util_1.FORCE_NEW]: forceNew,
projectId: util_1.lastOf(mergedConfig.projectId, process.env.GCLOUD_PROJECT),
onUncaughtException: mergedConfig.onUncaughtException,

@@ -114,2 +113,11 @@ bufferSize: mergedConfig.bufferSize,

},
/**
* Our TypeScript interface suggests that only credentials, keyFilename,
* and projectId are accepted, but by passing the entire object to the
* Trace Writer, we can allow users to supply other fields that are
* publicly supported by the Google Auth Library.
*/
authOptions: Object.assign({}, mergedConfig, {
projectId: util_1.lastOf(mergedConfig.projectId, process.env.GCLOUD_PROJECT),
}),
},

@@ -116,0 +124,0 @@ pluginLoaderConfig: {

4

build/src/trace-writer.d.ts

@@ -20,4 +20,4 @@ /**

import { Singleton } from './util';
export interface TraceWriterConfig extends common.GoogleAuthOptions {
projectId?: string;
export interface TraceWriterConfig {
authOptions: common.GoogleAuthOptions;
onUncaughtException: string;

@@ -24,0 +24,0 @@ bufferSize: number;

@@ -98,3 +98,3 @@ "use strict";

scopes: SCOPES,
}, config);
}, config.authOptions);
this.config = config;

@@ -101,0 +101,0 @@ this.logger = logger;

@@ -107,4 +107,4 @@ "use strict";

.activate();
if (typeof this.config.writerConfig.projectId !== 'string' &&
typeof this.config.writerConfig.projectId !== 'undefined') {
if (typeof this.config.writerConfig.authOptions.projectId !== 'string' &&
typeof this.config.writerConfig.authOptions.projectId !== 'undefined') {
this.logger.error('StackdriverTracer#start: config.projectId, if provided, must be a string.', 'Disabling trace agent.');

@@ -111,0 +111,0 @@ this.disable();

{
"name": "@google-cloud/trace-agent",
"version": "4.0.0",
"version": "4.0.1",
"description": "Node.js Support for StackDriver Trace",

@@ -18,2 +18,3 @@ "main": "build/src/index.js",

"check": "gts check",
"lint": "gts check",
"clean": "rimraf build/src",

@@ -27,4 +28,5 @@ "compile-all": "npm run script compile-auto",

"license-check": "jsgl --local .",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
"predocs-test": "npm run docs"
"predocs-test": "npm run docs",
"docs-test": "linkinator docs/",
"docs": "compodoc src/"
},

@@ -53,2 +55,3 @@ "files": [

"devDependencies": {
"@compodoc/compodoc": "1.1.9",
"@grpc/proto-loader": "^0.5.0",

@@ -84,3 +87,3 @@ "@types/builtin-modules": "^2.0.0",

"js-green-licenses": "^1.0.0",
"linkinator": "^1.1.2",
"linkinator": "^1.5.0",
"mocha": "^6.0.0",

@@ -101,3 +104,3 @@ "nock": "^10.0.0",

"@google-cloud/common": "^2.0.0",
"@opencensus/propagation-stackdriver": "0.0.13",
"@opencensus/propagation-stackdriver": "0.0.14",
"builtin-modules": "^3.0.0",

@@ -104,0 +107,0 @@ "console-log-level": "^1.4.0",

@@ -18,3 +18,3 @@ # Stackdriver Trace Agent for Node.js

The Trace Agent supports Node 6+.
The Trace Agent supports Node 8+.

@@ -32,3 +32,3 @@ > **Note**: Using the Trace Agent requires a Google Cloud Project with the [Stackdriver Trace API enabled](https://console.cloud.google.com/flows/enableapi?apiid=cloudtrace) and associated credentials. These values are auto-detected if the application is running on Google Cloud Platform. If your application is not running on GCP, you will need to specify the project ID and credentials either through the configuration object, or with environment variables. See [Setting Up Stackdriver Trace for Node.js][setting-up-stackdriver-trace] for more details.

Optionally, you can pass a [configuration object](src/config.ts) to the `start()` function as follows:
Optionally, you can pass a [configuration object](https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/config.ts) to the `start()` function as follows:

@@ -60,4 +60,2 @@ <!-- TODO(kjin): Generate documentation from the public interface of the Trace Agent, and link it here. -->

> **Note**: If your source code contains untranspiled [`async/await`][async-await-docs] (introduced in Node 7.6), please see [this section](#tracing-with-async/await) on enabling experimental tracing for `async` functions.
## What gets traced

@@ -84,3 +82,3 @@

To request automatic tracing support for a module not on this list, please [file an issue](https://github.com/googleapis/cloud-trace-nodejs/issues). Alternatively, you can [write a plugin yourself](doc/plugin-guide.md).
To request automatic tracing support for a module not on this list, please [file an issue](https://github.com/googleapis/cloud-trace-nodejs/issues). Alternatively, you can [write a plugin yourself](https://github.com/googleapis/cloud-trace-nodejs/blob/master/doc/plugin-guide.md).

@@ -149,15 +147,12 @@ ### Tracing Additional Modules

A fully detailed overview of the `Tracer` object is available [here](doc/trace-api.md).
A fully detailed overview of the `Tracer` object is available [here](https://github.com/googleapis/cloud-trace-nodejs/blob/master/doc/trace-api.md).
## How does automatic tracing work?
The Trace Agent automatically patches well-known modules to insert calls to functions that start, label, and end spans to measure latency of RPCs (such as mysql, redis, etc.) and incoming requests (such as express, hapi, etc.). As each RPC is typically performed on behalf of an incoming request, we must make sure that this association is accurately reflected in span data. To provide a uniform, generalized way of keeping track of which RPC belongs to which incoming request, we rely on the following mechanisms to keep track of the "trace context" across asynchronous boundaries:
* [`continuation-local-storage`][continuation-local-storage] (which relies on [`async-listener`][async-listener]) in Node 6
* [`async_hooks`][async-hooks] in Node 8+
The Trace Agent automatically patches well-known modules to insert calls to functions that start, label, and end spans to measure latency of RPCs (such as mysql, redis, etc.) and incoming requests (such as express, hapi, etc.). As each RPC is typically performed on behalf of an incoming request, we must make sure that this association is accurately reflected in span data. To provide a uniform, generalized way of keeping track of which RPC belongs to which incoming request, we rely on [`async_hooks`][async-hooks] to keep track of the "trace context" across asynchronous boundaries.
These mechanisms work great in most cases. However, they do have some limitations that can prevent us from being able to properly propagate trace context:
`async_hooks` works well in most cases. However, it does have some limitations that can prevent us from being able to properly propagate trace context:
* It is possible that a module does its own queuing of callback functions – effectively merging asynchronous execution contexts. For example, one may write an http request buffering library that queues requests and then performs them in a batch in one shot. In such a case, when all the callbacks fire, they will execute in the context which flushed the queue instead of the context which added the callbacks to the queue. This problem is called the pooling problem or the [user-space queuing problem][queuing-problem], and is a fundamental limitation of JavaScript. If your application uses such code, you will notice that RPCs from many requests are showing up under a single trace, or that certain portions of your outbound RPCs do not get traced. In such cases we try to work around the problem through monkey patching, or by working with the library authors to fix the code to properly propagate context. However, finding problematic code is not always trivial.
* If your application uses untranspiled `async` functions, you must use Node 8+. (Untranspiled `async` functions are supported from Node 7.6 onward, but we do not support tracing these functions in Node 7.)
* The Node.js `async_hooks` API has [issues tracking context](https://github.com/nodejs/node/issues/26064) around `await`-ed "thenables" (rather than real promises). Requests originating from the body of a `then` implementation in such a user-space "thenable" may not get traced. This is largely an unconventional case but is present in the `knex` module, which monkeypatches the Bluebird Promise's prototype to make database calls. __If you are using `knex` (esp. the `raw` function), see [#946](https://github.com/googleapis/cloud-trace-nodejs/issues/946) for more details on whether you are affected, as well as a suggested workaround.__
* The `async_hooks` API has [issues tracking context](https://github.com/nodejs/node/issues/26064) around `await`-ed "thenables" (rather than real promises). Requests originating from the body of a `then` implementation in such a user-space "thenable" may not get traced. This is largely an unconventional case but is present in the `knex` module, which monkeypatches the Bluebird Promise's prototype to make database calls. __If you are using `knex` (esp. the `raw` function), see [#946](https://github.com/googleapis/cloud-trace-nodejs/issues/946) for more details on whether you are affected, as well as a suggested workaround.__

@@ -168,17 +163,16 @@ ### Tracing bundled or webpacked server code.

The way we trace modules does not support bundled server code. Bundlers like webpack or @zeit/ncc will not work.
The Trace Agent does not support bundled server code, so bundlers like webpack or @zeit/ncc will not work.
## Contributing changes
## Contributing
* See [CONTRIBUTING.md](CONTRIBUTING.md)
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/cloud-trace-nodejs/blob/master/CONTRIBUTING.md).
## Licensing
## License
* See [LICENSE](LICENSE)
Apache Version 2.0
[async-await-docs]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
See [LICENSE](https://github.com/googleapis/cloud-trace-nodejs/blob/master/LICENSE)
[async-hooks]: https://nodejs.org/api/async_hooks.html
[async-listener]: https://www.npmjs.com/package/async-listener
[cloud-console]: https://console.cloud.google.com
[continuation-local-storage]: https://www.npmjs.com/package/continuation-local-storage
[codecov-image]: https://codecov.io/gh/googleapis/cloud-trace-nodejs/branch/master/graph/badge.svg

@@ -185,0 +179,0 @@ [codecov-url]: https://codecov.io/gh/googleapis/cloud-trace-nodejs

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc