How to use the @google-cloud/trace-agent.start function in @google-cloud/trace-agent

To help you get started, we’ve selected a few @google-cloud/trace-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudfoundry-incubator / cloud-service-broker / acceptance-tests / gcp / stack-driver-trace-test-app / index.js View on Github external
async function main() {
    require('@google-cloud/trace-agent').start({
        logLevel: 4,
        enabled: true,
        projectId: credentials.ProjectId,
        bufferSize: 1,
        // flushDelaySeconds: 0,
        credentials: JSON.parse(Buffer.from(credentials.PrivateKeyData, 'base64').toString("ascii"))
    })
    runServer(`${JSON.parse(Buffer.from(credentials.PrivateKeyData, 'base64').toString("ascii"))} `)
}
github JustinBeckwith / cloudcats / web / server.js View on Github external
'use strict';

require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start({
	allowExpressions: true
});

const path = require('path');
const Hapi = require('hapi');

process.on('unhandledRejection', (reason, p) => {
	console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});

// Set up the server
const server = new Hapi.Server({
	host: '0.0.0.0',
	port: process.env.PORT || 8080
});
github HowNetWorks / uriteller / src / backend / lib / gcloud.js View on Github external
let errorHandler = {
  report(err) {
    // eslint-disable-next-line no-console
    console.error(err);
  },
  express(req, res, next) {
    next();
  }
};

if (process.env.NODE_ENV === "production") {
  require("@google-cloud/trace-agent").start();
  require("@google-cloud/debug-agent").start();
  errorHandler = require("@google-cloud/error-reporting")();
}

module.exports = {
  pubsub() {
    return require("@google-cloud/pubsub")();
  },
  datastore() {
    return require("@google-cloud/datastore")();
  },
  errors: errorHandler
};
github GoogleCloudPlatform / nodejs-getting-started / 7-gce / app.js View on Github external
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
  require('@google-cloud/trace-agent').start();
  require('@google-cloud/debug-agent').start();
}

const path = require('path');
const express = require('express');
const session = require('express-session');
const passport = require('passport');
const config = require('./config');
const logging = require('./lib/logging');
const {Datastore} = require('@google-cloud/datastore');
const DatastoreStore = require('@google-cloud/connect-datastore')(session);

const app = express();

app.disable('etag');
app.set('views', path.join(__dirname, 'views'));
github GoogleCloudPlatform / nodejs-serverless-microservices-demo / image-diff / index.js View on Github external
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/* eslint no-console: "off" */
const traceApi = require('@google-cloud/trace-agent').start({
  serviceContext: {
    service: 'image-diff'
  }
});
const Storage = require('@google-cloud/storage');
const debug = require('@google-cloud/debug-agent').start();
require('@google-cloud/profiler').start();


const diff = require('./diff');

const storage = new Storage();

/**
 * Generic background Cloud Function to be triggered by Cloud Storage.
 *
github GoogleCloudPlatform / nodejs-getting-started / 6-pubsub / worker.js View on Github external
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
  require('@google-cloud/trace-agent').start();
  require('@google-cloud/debug-agent').start();
}

const request = require('request');
const waterfall = require('async').waterfall;
const express = require('express');
const bodyParser = require('body-parser');
const config = require('./config');

const logging = require('./lib/logging');
const images = require('./lib/images');
const model = require('./books/model-datastore');

// When running on Google App Engine Managed VMs, the worker needs
// to respond to HTTP requests and can optionally supply a health check.
// [START server]
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / v1.2 / nodejs / stackdriver-trace-monitoring / end / frontend / app.js View on Github external
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';

const config = require('./config');

// TODO: Load the trace-agent and start it
// Trace must be started before any other code in the 
// application.

require('@google-cloud/trace-agent').start({
  projectId: config.get('GCLOUD_PROJECT')
});

// END TODO

require('@google-cloud/debug-agent').start({
  allowExpressions: true,
  projectId: config.get('GCLOUD_PROJECT')
});

const path = require('path');
const express = require('express');
const scores = require('./gcp/spanner');

const {ErrorReporting} = require('@google-cloud/error-reporting');
const errorReporting = new ErrorReporting({
github GoogleCloudPlatform / nodejs-getting-started / optional-kubernetes-engine / worker.js View on Github external
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
  require('@google-cloud/trace-agent').start();
  require('@google-cloud/debug-agent');
}

const request = require('request');
const waterfall = require('async').waterfall;
const express = require('express');
const config = require('./config');

const logging = require('./lib/logging');
const images = require('./lib/images');
const background = require('./lib/background');

const model = require(`./books/model-${config.get('DATA_BACKEND')}`);

// When running on Google App Engine Managed VMs, the worker needs
// to respond to HTTP requests and can optionally supply a health check.
github JustinBeckwith / cloudcats / worker / server.js View on Github external
'use strict';

require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start({
	allowExpressions: true
});

const loader = require('@grpc/proto-loader');
const grpc = require('grpc');
const analyzer = require('./analyzer');
const logger = require('./logger');

const packageDef = loader.loadSync('cloudcats.proto');
const proto = grpc.loadPackageDefinition(packageDef).cloudcats;

const server = new grpc.Server();
server.addService(proto.Worker.service, {
	analyze: call => {
		analyzer.analyze(call)
github GoogleCloudPlatform / cloud-ops-sandbox / src / currencyservice / client.js View on Github external
* Copyright 2015 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
require('@google-cloud/trace-agent').start();

const path = require('path');
const grpc = require('grpc');
const leftPad = require('left-pad');
const pino = require('pino');

const PROTO_PATH = path.join(__dirname, './proto/demo.proto');
const PORT = 7000;

const shopProto = grpc.load(PROTO_PATH).hipstershop;
const client = new shopProto.CurrencyService(`localhost:${PORT}`,
  grpc.credentials.createInsecure());

const logger = pino({
  name: 'currencyservice-client',
  messageKey: 'message',

@google-cloud/trace-agent

Node.js Support for StackDriver Trace

Apache-2.0
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis

Popular @google-cloud/trace-agent functions