Skip to content

Commit

Permalink
Remove old hooks mechanism (#410)
Browse files Browse the repository at this point in the history
PR-URL: #410
  • Loading branch information
matthewloring authored Feb 23, 2017
1 parent aebb3a5 commit a8a6e58
Show file tree
Hide file tree
Showing 98 changed files with 104 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
test/hooks/fixtures
test/plugins/fixtures
test/performance
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- redis-64\tools\redis-server.exe --service-start
# install modules
- npm install
- ps: ForEach ($fix in Get-ChildItem -Directory test/hooks/fixtures/*) { cd $fix; npm install --silent }
- ps: ForEach ($fix in Get-ChildItem -Directory test/plugins/fixtures/*) { cd $fix; npm install --silent }
- ps: cd ..\..\..\..
# set GCLOUD_PROJECT
- SET GCLOUD_PROJECT=0
Expand All @@ -33,7 +33,7 @@ before_test:
test_script:
# run tests
- ps: ForEach ($test in Get-ChildItem test/*.js) { node_modules/.bin/mocha $test --timeout 4000 --R; if ($lastexitcode -ne 0) { exit 1 } }
- ps: ForEach ($test in Get-ChildItem test/hooks/*.js) { node_modules/.bin/mocha $test --timeout 4000 --R; if ($lastexitcode -ne 0) { exit 1 } }
- ps: ForEach ($test in Get-ChildItem test/plugins/*.js) { node_modules/.bin/mocha $test --timeout 4000 --R; if ($lastexitcode -ne 0) { exit 1 } }

# Don't actually build using MSBuild
build: off
4 changes: 2 additions & 2 deletions bin/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ done
jshint . || exit 1

# Install framework deps
for dir in test/hooks/fixtures/*/ ;
for dir in test/plugins/fixtures/*/ ;
do
echo -en "travis_fold:start:npm_install_${dir}\\r" | tr / _
echo "npm install in ${dir}"
Expand All @@ -39,7 +39,7 @@ function run {
}

# Run test/coverage
for test in test/*.js test/hooks/*.js ;
for test in test/*.js test/plugins/*.js ;
do
if [[ ! $(node --version) =~ v0\.12\..* || ! "${test}" =~ .*trace\-koa\.js ]]
then
Expand Down
4 changes: 0 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ module.exports = {
'restify': path.join(__dirname, 'src/plugins/plugin-restify.js')
},

// Valid entries are:
// 'express', 'hapi', 'http', 'restify'
excludedHooks: [],

// @type {number} max number of frames to include on traces (0 disables)
stackTraceLimit: 10,

Expand Down
205 changes: 0 additions & 205 deletions src/hooks/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/trace-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'use strict';

var cls = require('./cls');
var hooks = require('./hooks/index.js');
var pluginLoader = require('./trace-plugin-loader.js');
var Trace = require('./trace.js');
var SpanData = require('./span-data.js');
Expand All @@ -37,7 +36,6 @@ function TraceAgent(config, logger) {
this.config_ = config;
this.logger = logger;

hooks.activate(this);
pluginLoader.activate(this);

this.namespace = cls.createNamespace();
Expand Down Expand Up @@ -66,7 +64,6 @@ function TraceAgent(config, logger) {
TraceAgent.prototype.stop = function() {
// Deactivate plugins. This calls unpatch() for all plugin patches that
// support it.
hooks.deactivate();
pluginLoader.deactivate();
// Even though plugins should be unpatched, setting a new policy that
// never generates traces allows persisting wrapped methods (either because
Expand Down
44 changes: 0 additions & 44 deletions test/hooks/test-hooks-index.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test-agent-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('agent interaction with metadata service', function() {
}, callback);
}
});
common = require('./hooks/common.js');
common = require('./plugins/common.js');
trace = require('..');
delete process.env.GCLOUD_PROJECT;
});
Expand Down
28 changes: 24 additions & 4 deletions test/test-agent-stopped.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,32 @@

var assert = require('assert');
var http = require('http');
var nock = require('nock');
var proxyquire = require('proxyquire');

describe('test-agent-stopped', function() {
var agent;
before(function() {
before(function(done) {
// Setup: Monkeypatch gcp-metadata to not ask for retries at all.
var retryRequest = require('retry-request');
proxyquire('gcp-metadata', {
'retry-request': function(requestOps, callback) {
return retryRequest(requestOps, {
retries: 0
}, callback);
}
});
var scope = nock('http://metadata.google.internal')
.get('/computeMetadata/v1/project/project-id')
.reply(404);
delete process.env.GCLOUD_PROJECT;
agent = require('..').start();
// Wait 20ms for agent to fail getting remote project id.
setTimeout(function() {
assert.ok(!agent.isActive());
scope.done();
done();
}, 20);
});

after(function() {
Expand All @@ -33,7 +53,7 @@ describe('test-agent-stopped', function() {
describe('express', function() {
it('should not break if no project number is found', function(done) {
assert.ok(!agent.isActive());
var app = require('./hooks/fixtures/express4')();
var app = require('./plugins/fixtures/express4')();
app.get('/', function (req, res) {
res.send('hi');
});
Expand All @@ -54,7 +74,7 @@ describe('test-agent-stopped', function() {
describe('hapi', function() {
it('should not break if no project number is found', function(done) {
assert.ok(!agent.isActive());
var hapi = require('./hooks/fixtures/hapi8');
var hapi = require('./plugins/fixtures/hapi8');
var server = new hapi.Server();
server.connection({ port: 8081 });
server.route({
Expand All @@ -81,7 +101,7 @@ describe('test-agent-stopped', function() {
describe('restify', function() {
it('should not break if no project number is found', function(done) {
assert.ok(!agent.isActive());
var restify = require('./hooks/fixtures/restify4');
var restify = require('./plugins/fixtures/restify4');
var server = restify.createServer();
server.get('/', function (req, res, next) {
res.writeHead(200, {
Expand Down
Loading

0 comments on commit a8a6e58

Please sign in to comment.