Skip to content

Commit

Permalink
feat: use small HTTP dependency (#858)
Browse files Browse the repository at this point in the history
Use teenyRequest instead of request. This saves 900 ms at
startup time.
  • Loading branch information
fhinkel authored Sep 18, 2018
1 parent 13f617a commit 210dc3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@types/pify": "^3.0.0",
"@types/protobufjs": "^5.0.31",
"@types/proxyquire": "^1.3.28",
"@types/request": "^2.0.8",
"@types/request": "^2.47.1",
"@types/semver": "^5.4.0",
"@types/shimmer": "^1.0.1",
"@types/tmp": "0.0.33",
Expand Down Expand Up @@ -103,10 +103,10 @@
"hex2dec": "^1.0.1",
"is": "^3.2.0",
"methods": "^1.1.1",
"request": "^2.83.0",
"require-in-the-middle": "^3.0.0",
"semver": "^5.4.1",
"shimmer": "^1.2.0",
"teeny-request": "^3.9.0",
"uuid": "^3.0.1"
}
}
5 changes: 3 additions & 2 deletions src/trace-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {AxiosError} from 'axios';
import * as gcpMetadata from 'gcp-metadata';
import {OutgoingHttpHeaders} from 'http';
import * as os from 'os';
import * as request from 'request';
import * as r from 'request'; // Only for type declarations.
import {teenyRequest} from 'teeny-request';

import {Constants} from './constants';
import {Logger} from './logger';
Expand Down Expand Up @@ -79,7 +80,7 @@ export class TraceWriter extends common.Service {
private readonly logger: Logger) {
super(
{
requestModule: request,
requestModule: teenyRequest as typeof r,
packageJson: pjson,
projectIdRequired: false,
baseUrl: 'https://cloudtrace.googleapis.com/v1',
Expand Down
2 changes: 1 addition & 1 deletion test/test-trace-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as assert from 'assert';
import {OutgoingHttpHeaders} from 'http';
import * as nock from 'nock';
import * as os from 'os';
import {Response} from 'request';
import {Response} from 'request'; // Only for type declarations.
import * as shimmer from 'shimmer';

import {SpanKind, Trace} from '../src/trace';
Expand Down

0 comments on commit 210dc3f

Please sign in to comment.