Skip to content

Commit

Permalink
chore: set explicit naming convention (open-telemetry#262)
Browse files Browse the repository at this point in the history
closes open-telemetry#165

Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
  • Loading branch information
OlivierAlbertini authored and mayurkale22 committed Sep 17, 2019
1 parent 08f124f commit a774d78
Show file tree
Hide file tree
Showing 36 changed files with 65 additions and 46 deletions.
1 change: 1 addition & 0 deletions packages/opentelemetry-basic-tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.1.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "^3.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

export enum ExportResult {
Success,
FailedNotRetryable,
FailedRetryable,
SUCCESS,
FAILED_NOT_RETRYABLE,
FAILED_RETRYABLE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class InMemorySpanExporter implements SpanExporter {
spans: ReadableSpan[],
resultCallback: (result: ExportResult) => void
): void {
if (this._stopped) return resultCallback(ExportResult.FailedNotRetryable);
if (this._stopped) return resultCallback(ExportResult.FAILED_NOT_RETRYABLE);
this._finishedSpans.push(...spans);
return resultCallback(ExportResult.Success);
return resultCallback(ExportResult.SUCCESS);
}

shutdown(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('InMemorySpanExporter', () => {
it('should return the success result', () => {
const exorter = new InMemorySpanExporter();
exorter.export([], (result: ExportResult) => {
assert.strictEqual(result, ExportResult.Success);
assert.strictEqual(result, ExportResult.SUCCESS);
});
});

Expand All @@ -81,7 +81,7 @@ describe('InMemorySpanExporter', () => {

// after shutdown export should fail
exorter.export([], (result: ExportResult) => {
assert.strictEqual(result, ExportResult.FailedNotRetryable);
assert.strictEqual(result, ExportResult.FAILED_NOT_RETRYABLE);
});
});
});
2 changes: 1 addition & 1 deletion packages/opentelemetry-basic-tracer/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"mocha": "^6.1.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-loader": "^6.0.4",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry-core/src/trace/TracerDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ export class TracerDelegate implements types.Tracer {
// Wrap a tracer with a TracerDelegate. Provided tracer becomes the default
// fallback tracer for when a global tracer has not been initialized
constructor(
private readonly tracer: types.Tracer | null = null,
private readonly fallbackTracer: types.Tracer = new NoopTracer()
private readonly _tracer: types.Tracer | null = null,
private readonly _fallbackTracer: types.Tracer = new NoopTracer()
) {
this._currentTracer = tracer || fallbackTracer; // equivalent to this.start()
this._currentTracer = _tracer || _fallbackTracer; // equivalent to this.start()
}

// Begin using the user provided tracer. Stop always falling back to fallback tracer
start(): void {
this._currentTracer = this.tracer || this.fallbackTracer;
this._currentTracer = this._tracer || this._fallbackTracer;
}

// Stop the delegate from using the provided tracer. Begin to use the fallback tracer
stop(): void {
this._currentTracer = this.fallbackTracer;
this._currentTracer = this._fallbackTracer;
}

// -- Tracer interface implementation below -- //
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-jaeger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export class JaegerExporter implements SpanExporter {
if (err) {
// @todo: decide whether to break out the loop on first error.
this._logger.error(`failed to append span: ${err}`);
if (done) return done(ExportResult.FailedNotRetryable);
if (done) return done(ExportResult.FAILED_NOT_RETRYABLE);
}
});
}
// @todo: We should wait for all the callbacks of the append calls to
// complete before it calls done with success.
this._logger.debug('successful append for : %s', thriftSpan.length);
if (done) return done(ExportResult.Success);
if (done) return done(ExportResult.SUCCESS);
}
}
4 changes: 2 additions & 2 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('JaegerExporter', () => {

it('should skip send with empty list', () => {
exporter.export([], (result: ExportResult) => {
assert.strictEqual(result, ExportResult.Success);
assert.strictEqual(result, ExportResult.SUCCESS);
});
});

Expand All @@ -90,7 +90,7 @@ describe('JaegerExporter', () => {
};

exporter.export([readableSpan], (result: ExportResult) => {
assert.strictEqual(result, ExportResult.Success);
assert.strictEqual(result, ExportResult.SUCCESS);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-jaeger/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-zipkin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-zipkin/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-node-tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"nyc": "^14.1.1",
"shimmer": "^1.2.0",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "^3.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-node-tracer/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
22 changes: 11 additions & 11 deletions packages/opentelemetry-plugin-grpc/src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class GrpcPlugin extends BasePlugin<grpc> {
// TODO: Delete if moving internal file loaders to BasePlugin
// --- Note: Incorrectly ordered: Begin internal file loader --- //
// tslint:disable-next-line:no-any
protected internalFilesExports: { [key: string]: any } | undefined;
protected readonly internalFileList: ModuleExportsMapping = {
protected _internalFilesExports: { [key: string]: any } | undefined;
protected readonly _internalFileList: ModuleExportsMapping = {
'0.13 - 1.6': { client: 'src/node/src/client.js' },
'^1.7': { client: 'src/client.js' },
};
Expand All @@ -76,21 +76,21 @@ export class GrpcPlugin extends BasePlugin<grpc> {
*/
private _loadInternalFiles(): ModuleExportsMapping {
let result: ModuleExportsMapping = {};
if (this.internalFileList) {
this._logger.debug('loadInternalFiles %o', this.internalFileList);
Object.keys(this.internalFileList).forEach(versionRange => {
if (this._internalFileList) {
this._logger.debug('loadInternalFiles %o', this._internalFileList);
Object.keys(this._internalFileList).forEach(versionRange => {
if (semver.satisfies(this.version, versionRange)) {
if (result) {
this._logger.warn(
'Plugin for %s@%s, has overlap version range (%s) for internal files: %o',
this.moduleName,
this.version,
versionRange,
this.internalFileList
this._internalFileList
);
}
result = this._loadInternalModuleFiles(
this.internalFileList[versionRange],
this._internalFileList[versionRange],
basedir
);
}
Expand Down Expand Up @@ -137,8 +137,8 @@ export class GrpcPlugin extends BasePlugin<grpc> {
// --- End of internal file loader stuff --- //

protected patch(): typeof grpcModule {
if (!this.internalFilesExports) {
this.internalFilesExports = this._loadInternalFiles();
if (!this._internalFilesExports) {
this._internalFilesExports = this._loadInternalFiles();
}
this._logger.debug(
'applying patch to %s@%s',
Expand All @@ -155,8 +155,8 @@ export class GrpcPlugin extends BasePlugin<grpc> {
);
}

if (this.internalFilesExports && this.internalFilesExports['client']) {
grpcClientModule = this.internalFilesExports['client'];
if (this._internalFilesExports && this._internalFilesExports['client']) {
grpcClientModule = this._internalFilesExports['client'];

shimmer.wrap(
grpcClientModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-grpc/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"nyc": "^14.1.1",
"sinon": "^7.3.2",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-http2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http2/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-https/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-https/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-mongodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-mongodb/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-plugin-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-redis/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-scope-async-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"mocha": "^6.1.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "^3.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-scope-async-hooks/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-scope-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"mocha": "^6.1.0",
"nyc": "^14.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"ts-mocha": "^6.0.0",
"ts-node": "^8.0.0",
"typescript": "^3.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-scope-base/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
1 change: 1 addition & 0 deletions packages/opentelemetry-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"gts": "^1.0.0",
"linkinator": "^1.5.0",
"tslint-microsoft-contrib": "^6.2.0",
"tslint-consistent-codestyle":"^1.15.1",
"typedoc": "^0.14.2",
"typescript": "^3.4.5"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-types/tslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": "../../tslint.base.js"
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
15 changes: 10 additions & 5 deletions tslint.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ See the License for the specific language governing permissions and
limitations under the License.`;

const fileHeaderRegexStr =
fileHeaderTemplate
.replace(/[\\\/^$.*+?()[\]{}|]/g, '\\$&') // Escape regex
.replace(/\n/g, '\n \\* ?') // Per line space+asterisk, optional space
.replace('YEAR_PLACEHOLDER', '2\\d{3}');
fileHeaderTemplate
.replace(/[\\\/^$.*+?()[\]{}|]/g, '\\$&') // Escape regex
.replace(/\n/g, '\n \\* ?') // Per line space+asterisk, optional space
.replace('YEAR_PLACEHOLDER', '2\\d{3}');

const fileHeaderDefault =
fileHeaderTemplate.replace('YEAR_PLACEHOLDER', new Date().getFullYear());
fileHeaderTemplate.replace('YEAR_PLACEHOLDER', new Date().getFullYear());

const rules = {
'file-header': [
Expand All @@ -50,6 +50,11 @@ const rules = {
'default': fileHeaderDefault,
},
],
'naming-convention': [true,
{ 'type': 'property', 'modifiers': 'protected', 'leadingUnderscore': 'require' },
{ 'type': 'member', 'modifiers': 'private', 'leadingUnderscore': 'require' },
{ 'type': 'enumMember', 'format': 'UPPER_CASE' },
]
};

module.exports = {
Expand Down

0 comments on commit a774d78

Please sign in to comment.