-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat(plugin): add grpc plugin #215
Merged
mayurkale22
merged 19 commits into
open-telemetry:master
from
markwolff:add-grpc-plugin
Sep 11, 2019
Merged
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0db3a5b
feat: add grpc plugin
markwolff 52d5024
fix: remove test typo
markwolff 92ef3c5
fix: nyc missing from test
markwolff 5382516
fix: linting and NodeTracer export
markwolff dfb24f0
chore: rename grpc test file
markwolff 08e0fba
test: add error code tests
markwolff 052dc53
Merge branch 'master' into add-grpc-plugin
markwolff 02c1d4c
refactor: logger is given to plugin
markwolff 91d8a25
Merge branch 'master' into add-grpc-plugin
markwolff 64a805d
fix(grpc): using logger before defined
markwolff aefc3e4
refactor: move private statics to internal file
markwolff f0bac7b
test: add withSpan OK test
markwolff 2d01b61
refactor: follow plugin naming pattern
markwolff e9793a4
Merge branch 'master' into add-grpc-plugin
markwolff 8633a7f
refactor(tests): replace ProxyTracer
markwolff 798bc4b
refactor(grpc): move helper funcs to utils
markwolff 51bb59c
Merge branch 'master' into add-grpc-plugin
markwolff df5aed8
refactor(tests): use new memory exporter helper
markwolff 4eed3e8
Merge branch 'master' into add-grpc-plugin
mayurkale22 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
24 changes: 24 additions & 0 deletions
24
packages/opentelemetry-plugin-grpc/src/enums/grpcAttributeNames.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,24 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
export enum GrpcAttributeNames { | ||
mayurkale22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
COMPONENT = 'grpc.component', | ||
GRPC_KIND = 'grpc.kind', // SERVER or CLIENT | ||
GRPC_METHOD = 'grpc.method', | ||
GRPC_STATUS_CODE = 'grpc.status_code', | ||
GRPC_ERROR_NAME = 'grpc.error_name', | ||
GRPC_ERROR_MESSAGE = 'grpc.error_message', | ||
} |
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,71 @@ | ||
/** | ||
mayurkale22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Copyright 2019, OpenTelemetry 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
import * as grpcModule from 'grpc'; | ||
import * as events from 'events'; | ||
|
||
export type grpc = typeof grpcModule; | ||
|
||
export type SendUnaryDataCallback = ( | ||
error: grpcModule.ServiceError | null, | ||
// tslint:disable-next-line:no-any | ||
value?: any, | ||
trailer?: grpcModule.Metadata, | ||
flags?: grpcModule.writeFlags | ||
) => void; | ||
|
||
export interface GrpcPluginOptions {} | ||
|
||
interface GrpcStatus { | ||
code: number; | ||
details: string; | ||
metadata: grpcModule.Metadata; | ||
} | ||
|
||
export type ServerCall = | ||
| typeof grpcModule.ServerUnaryCall | ||
| typeof grpcModule.ServerReadableStream | ||
| typeof grpcModule.ServerWriteableStream | ||
| typeof grpcModule.ServerDuplexStream; | ||
|
||
export type ServerCallWithMeta = ServerCall & { | ||
metadata: grpcModule.Metadata; | ||
status: GrpcStatus; | ||
// tslint:disable-next-line:no-any | ||
request?: any; | ||
} & events.EventEmitter; | ||
|
||
export type GrpcClientFunc = typeof Function & { | ||
path: string; | ||
requestStream: boolean; | ||
responseStream: boolean; | ||
}; | ||
|
||
// TODO: Delete if moving internal file loaders to BasePlugin | ||
/** | ||
* Maps a name (key) representing a internal file module and its exports | ||
*/ | ||
export interface ModuleNameToFilePath { | ||
client: string; // path/to/file | ||
[wildcard: string]: string; // string indexer | ||
} | ||
|
||
/** | ||
* Maps a semver to a module:filepath Map | ||
*/ | ||
export interface ModuleExportsMapping { | ||
[semver: string]: ModuleNameToFilePath; | ||
} |
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,30 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
// Equivalent to lodash _.findIndex | ||
export const findIndex: <T>(args: T[], fn: (arg: T) => boolean) => number = ( | ||
args, | ||
fn: Function | ||
) => { | ||
let index = -1; | ||
for (const arg of args) { | ||
index++; | ||
if (fn(arg)) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
}; |
Oops, something went wrong.
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.
I'd suggest to keep it standardized everywhere, either change all packages script to
test/**/*.test.ts
or keep ittest/**/*.ts
. WDYT?