-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added agent option to http transport #439
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d5fbc55
Added agent option to http transport
RAWeber 2add964
Added type for http transport agent option
RAWeber 4109619
Fix lint imports
RAWeber 9199c5f
Added typescript tests
RAWeber 7a6b616
Fix lint errors
RAWeber 86f4c73
Add URL parameter to Agent function
RAWeber 6e391ba
Update http transport agent test
RAWeber c85d8c2
Ignore tsr-declarations.js file when linting
RAWeber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import {Agent as HttpAgent} from 'http'; | ||
import {Agent as HttpsAgent} from 'https'; | ||
import {URL} from 'url'; | ||
|
||
import {JsonEncoder, Logger, model} from 'zipkin'; | ||
|
||
type Agent = HttpAgent | HttpsAgent; | ||
|
||
declare class HttpLogger implements Logger { | ||
constructor(options: { | ||
endpoint: string, | ||
httpInterval?: number, | ||
jsonEncoder?: JsonEncoder, | ||
httpTimeout?: number, | ||
timeout?: number, | ||
maxPayloadSize?: number, | ||
headers?: { [name: string]: any }, | ||
agent?: Agent | ((url: URL) => Agent), | ||
log?: Console | ||
}); | ||
|
||
logSpan(span: model.Span): void; | ||
} | ||
export {HttpLogger}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/zipkin-transport-http/test-types/HttpLogger.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { expect } from 'chai'; | ||
|
||
import {Agent as HttpAgent } from 'http'; | ||
import {Agent as HttpsAgent} from 'https'; | ||
import {jsonEncoder} from 'zipkin'; | ||
|
||
import { HttpLogger } from 'zipkin-transport-http'; | ||
|
||
describe('HttpLogger', () => { | ||
it('should have correct type', () => { | ||
const options = { | ||
endpoint: 'testEndpoint', | ||
httpInterval: 1000, | ||
jsonEncoder: jsonEncoder.JSON_V1, | ||
timeout: 0, | ||
maxPayloadSize: 0, | ||
headers: {}, | ||
agent: new HttpAgent(), | ||
log: console | ||
}; | ||
const httpLogger: HttpLogger = new HttpLogger(options); | ||
|
||
expect(httpLogger.logSpan).to.be.a('function'); | ||
}); | ||
|
||
it('should accept Http(s) Agent or function which returns Agent', () => { | ||
const agents = [new HttpAgent(), new HttpsAgent(), () => new HttpAgent(), () => new HttpsAgent(), | ||
(url: URL) => new HttpAgent(), (url: URL) => new HttpsAgent(), null, undefined]; | ||
|
||
agents.forEach(agent => { | ||
const options = { | ||
endpoint: 'testEndpoint', | ||
agent | ||
}; | ||
|
||
const httpLogger: HttpLogger = new HttpLogger(options); | ||
|
||
expect(httpLogger).to.have.property('agent', agent || null); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to process
test-type/*.test.ts
tests in all packages. This reflects the second mocha command which usestest/mocha-types.opts
and attempts to run test-type tests in all packages.