Skip to content

Commit

Permalink
Merge branch 'main' into fix-win
Browse files Browse the repository at this point in the history
  • Loading branch information
Flarna authored Feb 21, 2022
2 parents 8194d92 + 0a557e8 commit a471673
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions plugins/node/opentelemetry-instrumentation-mysql2/.tav.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
mysql2:
versions: 2.*
commands: npm run test
- versions: 2.*
commands: npm run test

# Fix missing `test-utils` package
pretest: npm run --prefix ../../../ lerna:link
# Fix missing `test-utils` package
pretest: npm run --prefix ../../../ lerna:link
- versions: 1.4.2 || 1.5.0 || 1.5.1 || 1.5.2 || 1.5.3 || 1.6.0 || 1.6.3 || 1.6.4 || 1.6.5 || 1.7.0
# Skip v1.6.2, which is broken
commands: npm run test

# Fix missing `test-utils` package
pretest: npm run --prefix ../../../ lerna:link
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ npm install --save @opentelemetry/instrumentation-mysql2

## Supported Versions

- `2.x`
- `>= 1.4.2, < 3.0`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@
"@opentelemetry/contrib-test-utils": "^0.29.0",
"@opentelemetry/sdk-trace-base": "1.0.1",
"@types/mocha": "7.0.2",
"@types/mysql2": "github:types/mysql2",
"@types/node": "16.11.21",
"@types/semver": "7.3.8",
"gts": "3.1.0",
"mocha": "7.2.0",
"mysql2": "2.3.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"semver": "7.3.5",
"test-all-versions": "5.0.1",
"ts-mocha": "8.0.0",
"typescript": "4.3.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class MySQL2Instrumentation extends InstrumentationBase<
return [
new InstrumentationNodeModuleDefinition<typeof mysqlTypes>(
'mysql2',
['2.*'],
['>= 1.4.2 < 3.0'],
(moduleExports: any, moduleVersion) => {
api.diag.debug(`Patching mysql@${moduleVersion}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as semver from 'semver';
import { context, trace, SpanStatusCode } from '@opentelemetry/api';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
Expand Down Expand Up @@ -669,5 +670,5 @@ function assertSpan(
function isPoolClusterEndIgnoreCallback() {
// Since v2.2.0 `end` function respect callback
// https://github.com/sidorares/node-mysql2/commit/1481015626e506754adc4308e5508356a3a03aa0
return ['2.0.0', '2.0.1', '2.0.2', '2.1.0'].includes(LIB_VERSION);
return semver.lt(LIB_VERSION, '2.2.0');
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export const getTracedInternalSendCommand = (
responseHook(span, cmd.command, cmd.args, reply);
},
err => {
diag.error('Error executing responseHook', err);
if (err) {
diag.error('Error executing responseHook', err);
}
},
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ registerInstrumentations({
new WinstonInstrumentation({
// Optional hook to insert additional context to log metadata.
// Called after trace context is injected to metadata.
logHook: (record, span) => {
logHook: (span, record) => {
record['resource.service.name'] = provider.resource.attributes['service.name'];
},
}),
Expand Down

0 comments on commit a471673

Please sign in to comment.