From 83c7fa39aaccfb43cc7a8bbb99132659a355a3bd Mon Sep 17 00:00:00 2001 From: CptSchnitz <12687466+CptSchnitz@users.noreply.github.com> Date: Sun, 11 Jul 2021 11:09:44 +0300 Subject: [PATCH 1/3] docs(auto-instrumentations-node): improved readme (#563) --- .../auto-instrumentations-node/README.md | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/metapackages/auto-instrumentations-node/README.md b/metapackages/auto-instrumentations-node/README.md index 9625c281c1..6acdf9b527 100644 --- a/metapackages/auto-instrumentations-node/README.md +++ b/metapackages/auto-instrumentations-node/README.md @@ -5,6 +5,8 @@ [![devDependencies][devDependencies-image]][devDependencies-url] [![Apache License][license-image]][license-url] +This module provides a simple way to initialize multiple Node instrumentations. + ## Installation ```bash @@ -12,19 +14,25 @@ npm install --save @opentelemetry/auto-instrumentations-node ``` ## Usage +OpenTelemetry Meta Packages for Node automatically loads instrumentations for Node builtin modules and common packages. + +Custom configuration for each of the instrumentations can be passed to the function, by providing an object with the name of the instrumentation as a key, and its configuration as the value. ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node'); const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); +const { Resource } = require('@opentelemetry/resources'); +const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); -const exporter = new CollectorTraceExporter({ - serviceName: 'auto-instrumentations-node', +const exporter = new CollectorTraceExporter(); +const provider = new NodeTracerProvider({ + resource: new Resource({ + [ResourceAttributes.SERVICE_NAME]: 'basic-service', + }), }); - -const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); provider.register(); @@ -32,8 +40,8 @@ registerInstrumentations({ instrumentations: [ getNodeAutoInstrumentations({ // load custom configuration for http instrumentation - "@opentelemetry/instrumentation-http": { - applyCustomAttributesOnSpan: (span)=> { + '@opentelemetry/instrumentation-http': { + applyCustomAttributesOnSpan: (span) => { span.setAttribute('foo2', 'bar2'); }, }, @@ -42,6 +50,19 @@ registerInstrumentations({ }); ``` +## Supported instrumentations + +- [@opentelemetry/instrumentation-dns](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-dns) +- [@opentelemetry/instrumentation-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http) +- [@opentelemetry/instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-grpc) +- [@opentelemetry/instrumentation-express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express) +- [@opentelemetry/instrumentation-koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-koa) +- [@opentelemetry/instrumentation-graphql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql) +- [@opentelemetry/instrumentation-ioredis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis) +- [@opentelemetry/instrumentation-redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis) +- [@opentelemetry/instrumentation-pg](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pg) +- [@opentelemetry/instrumentation-mongodb](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb) +- [@opentelemetry/instrumentation-mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql) ## Useful links From c0ad0014ccacfddc613908bc4f382a062632df5d Mon Sep 17 00:00:00 2001 From: Yaron Date: Sun, 11 Jul 2021 12:04:13 +0300 Subject: [PATCH 2/3] fix(mongo): added missing exported types (#564) --- .../node/opentelemetry-instrumentation-mongodb/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts index dc7053e484..172fda8882 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts @@ -15,4 +15,8 @@ */ export * from './instrumentation'; -export { MongoDBInstrumentationConfig } from './types'; +export { + MongoDBInstrumentationConfig, + MongoDBInstrumentationExecutionResponseHook, + MongoResponseHookInformation, +} from './types'; From 902c91f0e690f3862486eb373fbfa136024be751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= Date: Mon, 12 Jul 2021 10:44:40 +0200 Subject: [PATCH 3/3] chore: enable typescript 4.3 option noImplicitOverride (#549) --- .gitattributes | 1 + .../src/instrumentation.ts | 6 +-- .../src/instrumentation.ts | 4 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 4 +- .../src/instrumentation.ts | 4 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 8 +-- .../src/instrumentation.ts | 4 +- .../src/instrumentation.ts | 4 +- .../src/instrumentation.ts | 5 +- .../src/instrumentation.ts | 4 +- .../test-react-components/AllLifecycles.tsx | 50 ++++++++++++------- .../MissingComponentDidMount.tsx | 47 ++++++++++------- .../MissingComponentDidUpdate.tsx | 47 ++++++++++------- .../MissingGetSnapshotBeforeUpdate.tsx | 42 ++++++++++------ .../test-react-components/MissingRender.tsx | 41 +++++++++------ .../MissingShouldComponentUpdate.tsx | 43 ++++++++++------ .../ShouldComponentUpdateFalse.tsx | 50 ++++++++++++------- tsconfig.base.json | 1 + 23 files changed, 231 insertions(+), 144 deletions(-) diff --git a/.gitattributes b/.gitattributes index 7d65e84970..1c37b85cd5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,6 +4,7 @@ # JavaScript, TypeScript, c, and h source files *.js text eol=lf *.ts text eol=lf +*.tsx text eol=lf *.h text eol=lf diff=cpp *.c text eol=lf diff=cpp diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts index c65f55b4c2..89f3192189 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -71,11 +71,11 @@ export const traceContextEnvironmentKey = '_X_AMZN_TRACE_ID'; export class AwsLambdaInstrumentation extends InstrumentationBase { private _tracerProvider: TracerProvider | undefined; - constructor(protected _config: AwsLambdaInstrumentationConfig = {}) { + constructor(protected override _config: AwsLambdaInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-aws-lambda', VERSION, _config); } - setConfig(config: AwsLambdaInstrumentationConfig = {}) { + override setConfig(config: AwsLambdaInstrumentationConfig = {}) { this._config = config; } @@ -221,7 +221,7 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { }; } - setTracerProvider(tracerProvider: TracerProvider) { + override setTracerProvider(tracerProvider: TracerProvider) { super.setTracerProvider(tracerProvider); this._tracerProvider = tracerProvider; } diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index b8db62560f..a673a364bd 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -67,11 +67,11 @@ export class BunyanInstrumentation extends InstrumentationBase< ]; } - getConfig(): BunyanInstrumentationConfig { + override getConfig(): BunyanInstrumentationConfig { return this._config; } - setConfig(config: BunyanInstrumentationConfig) { + override setConfig(config: BunyanInstrumentationConfig) { this._config = config; } diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts index 477efd0ca4..d47cf7565b 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts @@ -37,7 +37,7 @@ import { VERSION } from './version'; * Dns instrumentation for Opentelemetry */ export class DnsInstrumentation extends InstrumentationBase { - constructor(protected _config: DnsInstrumentationConfig = {}) { + constructor(protected override _config: DnsInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-dns', VERSION, _config); } diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index a5819b1e87..c4f0bc69df 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -77,7 +77,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { return this._config as GraphQLInstrumentationParsedConfig; } - setConfig(config: GraphQLInstrumentationConfig & InstrumentationConfig = {}) { + override setConfig(config: GraphQLInstrumentationConfig = {}) { this._config = Object.assign({}, DEFAULT_CONFIG, config); } diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts index 4bc30e87df..7ffca113b9 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts @@ -43,7 +43,7 @@ export class Instrumentation extends InstrumentationBase { ); } - setConfig(config: InstrumentationConfig = {}) { + override setConfig(config: InstrumentationConfig = {}) { this._config = Object.assign({}, Instrumentation.DEFAULT_CONFIG, config); } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 6f0dabb803..6872e40ec4 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -48,7 +48,7 @@ const supportedVersions = ['>=3.3 <4']; export class MongoDBInstrumentation extends InstrumentationBase< typeof mongodb > { - constructor(protected _config: MongoDBInstrumentationConfig = {}) { + constructor(protected override _config: MongoDBInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-mongodb', VERSION, _config); } diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts index 301b85e51d..82ea9770d4 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -36,8 +36,8 @@ export class MySQLInstrumentation extends InstrumentationBase< [SemanticAttributes.DB_SYSTEM]: MySQLInstrumentation.COMPONENT, }; - constructor(protected _config: MySQLInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mysql', VERSION, _config); + constructor(config?: MySQLInstrumentationConfig) { + super('@opentelemetry/instrumentation-mysql', VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts index 3a5fcd5f04..16b659f994 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -41,8 +41,8 @@ export class MySQL2Instrumentation extends InstrumentationBase< [SemanticAttributes.DB_SYSTEM]: MySQL2Instrumentation.COMPONENT, }; - constructor(protected _config: MySQL2InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mysql2', VERSION, _config); + constructor(config?: MySQL2InstrumentationConfig) { + super('@opentelemetry/instrumentation-mysql2', VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 9a71741296..8c4fa9abc3 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -33,7 +33,7 @@ import { Socket } from 'net'; import { TLSSocket } from 'tls'; export class NetInstrumentation extends InstrumentationBase { - constructor(protected _config: InstrumentationConfig = {}) { + constructor(_config?: InstrumentationConfig) { super('@opentelemetry/instrumentation-net', VERSION, _config); } diff --git a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts index ae264263b6..292c9b3fa5 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -82,20 +82,20 @@ export class PinoInstrumentation extends InstrumentationBase { ]; } - getConfig(): PinoInstrumentationConfig { + override getConfig(): PinoInstrumentationConfig { return this._config; } - setConfig(config: PinoInstrumentationConfig) { + override setConfig(config: PinoInstrumentationConfig) { this._config = config; } - enable() { + override enable() { super.enable(); this._isEnabled = true; } - disable() { + override disable() { super.disable(); this._isEnabled = false; } diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts index 17e3adeec4..676a9a374b 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts @@ -38,11 +38,11 @@ export class RedisInstrumentation extends InstrumentationBase< > { static readonly COMPONENT = 'redis'; - constructor(protected _config: RedisInstrumentationConfig = {}) { + constructor(protected override _config: RedisInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-redis', VERSION, _config); } - setConfig(config: RedisInstrumentationConfig = {}) { + override setConfig(config: RedisInstrumentationConfig = {}) { this._config = Object.assign({}, DEFAULT_CONFIG, config); } diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index 8cd1ef5d74..16ef6b9a48 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -102,11 +102,11 @@ export class WinstonInstrumentation extends InstrumentationBase { ]; } - getConfig(): WinstonInstrumentationConfig { + override getConfig(): WinstonInstrumentationConfig { return this._config; } - setConfig(config: WinstonInstrumentationConfig) { + override setConfig(config: WinstonInstrumentationConfig) { this._config = config; } diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts index 95399d6111..a91ba7fd63 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts @@ -48,7 +48,6 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { readonly component: string = 'document-load'; readonly version: string = '1'; moduleName = this.component; - protected _config!: InstrumentationConfig; /** * @@ -235,7 +234,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { /** * implements enable function */ - enable() { + override enable() { // remove previously attached load to avoid adding the same event twice // in case of multiple enable calling. window.removeEventListener('load', this._onDocumentLoaded); @@ -245,7 +244,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { /** * implements disable function */ - disable() { + override disable() { window.removeEventListener('load', this._onDocumentLoaded); } } diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts index 2f5663f36c..6e0cbb9283 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts @@ -530,7 +530,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase /** * implements enable function */ - enable() { + override enable() { const ZoneWithPrototype = this.getZoneWithPrototype(); api.diag.debug( 'applying patch to', @@ -599,7 +599,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase /** * implements unpatch function */ - disable() { + override disable() { const ZoneWithPrototype = this.getZoneWithPrototype(); api.diag.debug( 'removing patch from', diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/AllLifecycles.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/AllLifecycles.tsx index 141b8a22a2..41fa913c49 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/AllLifecycles.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/AllLifecycles.tsx @@ -1,28 +1,40 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class AllLifecycles extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } + + override componentDidMount() {} - componentDidMount(){ - } + override componentDidUpdate(prevProps: any) {} - componentDidUpdate(prevProps: any){ - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return true; + } - shouldComponentUpdate(nextProps: any, nextState: any){ - return true; - } - - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidMount.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidMount.tsx index a83121ed0c..43dfd05642 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidMount.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidMount.tsx @@ -1,25 +1,38 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class MissingComponentDidMount extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } + + override componentDidUpdate(prevProps: any) {} - componentDidUpdate(prevProps: any){ - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return true; + } - shouldComponentUpdate(nextProps: any, nextState: any){ - return true; - } - - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidUpdate.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidUpdate.tsx index 6c12ad7fab..e562de995f 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidUpdate.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingComponentDidUpdate.tsx @@ -1,25 +1,38 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class MissingComponentDidUpdate extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } + + override componentDidMount() {} - componentDidMount(){ - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return true; + } - shouldComponentUpdate(nextProps: any, nextState: any){ - return true; - } - - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingGetSnapshotBeforeUpdate.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingGetSnapshotBeforeUpdate.tsx index 27578a78f3..e435d49202 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingGetSnapshotBeforeUpdate.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingGetSnapshotBeforeUpdate.tsx @@ -1,24 +1,36 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class MissingGetSnapshotBeforeUpdate extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } - componentDidMount(){ - } + override componentDidMount() {} - componentDidUpdate(prevProps: any){ - } + override componentDidUpdate(prevProps: any) {} - shouldComponentUpdate(nextProps: any, nextState: any){ - return true; - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return true; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingRender.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingRender.tsx index c1935f0d7d..035037998f 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingRender.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingRender.tsx @@ -1,22 +1,35 @@ +/* + * Copyright The 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 { BaseOpenTelemetryComponent } from '../../src'; export default class MissingRender extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } - componentDidMount(){ - } + override componentDidMount() {} - componentDidUpdate(prevProps: any){ - } + override componentDidUpdate(prevProps: any) {} - shouldComponentUpdate(nextProps: any, nextState: any){ - return true; - } - - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return true; + } + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingShouldComponentUpdate.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingShouldComponentUpdate.tsx index 92ac7c6511..da39013ea8 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingShouldComponentUpdate.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/MissingShouldComponentUpdate.tsx @@ -1,25 +1,36 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class MisingShouldComponentUpdate extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } - - componentDidMount(){ - } + constructor(props: Readonly) { + super(props); + } - componentDidUpdate(prevProps: any){ - } + override componentDidMount() {} - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override componentDidUpdate(prevProps: any) {} + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/ShouldComponentUpdateFalse.tsx b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/ShouldComponentUpdateFalse.tsx index 10beac419b..cec53716e6 100644 --- a/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/ShouldComponentUpdateFalse.tsx +++ b/plugins/web/opentelemetry-plugin-react-load/test/test-react-components/ShouldComponentUpdateFalse.tsx @@ -1,28 +1,40 @@ +/* + * Copyright The 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 React from 'react'; import { BaseOpenTelemetryComponent } from '../../src'; export default class ShouldComponentUpdateFalse extends BaseOpenTelemetryComponent { - constructor(props: Readonly){ - super(props); - } + constructor(props: Readonly) { + super(props); + } + + override componentDidMount() {} - componentDidMount(){ - } + override componentDidUpdate(prevProps: any) {} - componentDidUpdate(prevProps: any){ - } + override shouldComponentUpdate(nextProps: any, nextState: any) { + return false; + } - shouldComponentUpdate(nextProps: any, nextState: any){ - return false; - } - - getSnapshotBeforeUpdate(prevProps: any, prevState: any){ - return null; - } + override getSnapshotBeforeUpdate(prevProps: any, prevState: any) { + return null; + } - render() { - return( -
- ); - } + override render() { + return
; + } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 1b7e8c62dd..8046371bee 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -8,6 +8,7 @@ "module": "commonjs", "noEmitOnError": true, "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, "noImplicitReturns": true, "noUnusedLocals": true, "pretty": true,