Skip to content

Commit

Permalink
Merge branch 'main' into renovate/codecov-codecov-action-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 authored Apr 12, 2022
2 parents 151998a + 9a58648 commit eb4d24c
Show file tree
Hide file tree
Showing 25 changed files with 265 additions and 86 deletions.
2 changes: 1 addition & 1 deletion karma.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
listenAddress: 'localhost',
hostname: 'localhost',
browsers: ['ChromeHeadless'],
frameworks: ['mocha'],
frameworks: ['mocha', 'webpack'],
coverageIstanbulReporter: {
reports: ['json'],
dir: '.nyc_output',
Expand Down
4 changes: 2 additions & 2 deletions karma.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const webpackNodePolyfills = require('./webpack.node-polyfills.js');
module.exports = {
mode: 'development',
target: 'web',
output: { filename: 'bundle.js' },
name: 'bundle',
resolve: { extensions: ['.ts', '.js', '.tsx'] },
devtool: 'inline-source-map',
module: {
Expand All @@ -31,7 +31,7 @@ module.exports = {
exclude: /(node_modules|\.test\.[tj]sx?$)/,
test: /\.ts$/,
use: {
loader: 'istanbul-instrumenter-loader',
loader: '@jsdevtools/coverage-istanbul-loader',
options: { esModules: true }
}
},
Expand Down
21 changes: 20 additions & 1 deletion metapackages/auto-instrumentations-web/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2020, OpenTelemetry Authors
* 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.
Expand All @@ -14,10 +14,29 @@
* limitations under the License.
*/

const webpack = require('webpack');

const karmaWebpackConfig = require('../../karma.webpack');
const karmaBaseConfig = require('../../karma.base');

module.exports = (config) => {
{
const plugins = karmaWebpackConfig.plugins = [];
plugins.push(new webpack.ProvidePlugin({
process: 'process/browser',
}));
}

{
const plugins = karmaBaseConfig.plugins = [];
const toAdd = Object.keys(require('./package.json').devDependencies)
.filter((packageName) => packageName.startsWith('karma-'))
.map((packageName) => require(packageName));
plugins.push(
...toAdd
);
}

config.set(Object.assign({}, karmaBaseConfig, {
webpack: karmaWebpackConfig
}))
Expand Down
17 changes: 10 additions & 7 deletions metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,32 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@opentelemetry/api": "1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"assert": "2.0.0",
"babel-loader": "8.2.2",
"gts": "3.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "6.3.16",
"karma-chrome-launcher": "3.1.0",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "4.0.2",
"karma-spec-reporter": "0.0.33",
"karma-webpack": "5.0.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
"process": "0.11.10",
"rimraf": "3.0.2",
"sinon": "13.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"typescript": "4.3.5",
"webpack": "4.46.0",
"webpack-cli": "4.7.2",
"util": "0.12.4",
"webpack": "5.72.0",
"webpack-cli": "4.9.2",
"webpack-merge": "5.8.0"
},
"dependencies": {
Expand Down
29 changes: 23 additions & 6 deletions packages/opentelemetry-id-generator-aws-xray/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@
* limitations under the License.
*/

const webpack = require('webpack');

const karmaWebpackConfig = require('../../karma.webpack');
const karmaBaseConfig = require('../../karma.base');

module.exports = config => {
config.set(
Object.assign({}, karmaBaseConfig, {
webpack: karmaWebpackConfig,
})
);
module.exports = (config) => {
{
const plugins = karmaWebpackConfig.plugins = [];
plugins.push(new webpack.ProvidePlugin({
process: 'process/browser',
}));
}

{
const plugins = karmaBaseConfig.plugins = [];
const toAdd = Object.keys(require('./package.json').devDependencies)
.filter((packageName) => packageName.startsWith('karma-'))
.map((packageName) => require(packageName));
plugins.push(
...toAdd
);
}

config.set(Object.assign({}, karmaBaseConfig, {
webpack: karmaWebpackConfig
}))
};
14 changes: 8 additions & 6 deletions packages/opentelemetry-id-generator-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,29 @@
"@opentelemetry/api": "^1.0.2"
},
"devDependencies": {
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@opentelemetry/api": "1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"assert": "2.0.0",
"gts": "3.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "6.3.16",
"karma-chrome-launcher": "3.1.0",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "4.0.2",
"karma-spec-reporter": "0.0.33",
"karma-webpack": "5.0.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
"process": "0.11.10",
"rimraf": "3.0.2",
"sinon": "13.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"typescript": "4.3.5",
"webpack": "4.46.0"
"webpack": "5.72.0"
},
"dependencies": {
"@opentelemetry/core": "^1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { TediousInstrumentation } from '../src';
import makeApi from './api';
import type { Connection, ConnectionConfig } from 'tedious';

process.env.RUN_MSSQL_TESTS = 'true';

const port = Number(process.env.MSSQL_PORT) || 1433;
const database = process.env.MSSQL_DATABASE || 'master';
const host = process.env.MSSQL_HOST || '127.0.0.1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('CassandraDriverInstrumentation', () => {

after(async function () {
this.timeout(60000);
await client.shutdown();
await client?.shutdown?.();
if (testCassandraLocally) {
testUtils.cleanUpDocker('cassandra');
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-instrumentation-pino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ registerInstrumentations({
instrumentations: [
new PinoInstrumentation({
// Optional hook to insert additional context to log object.
logHook: (span, record) => {
logHook: (span, record, level) => {
record['resource.service.name'] = provider.resource.attributes['service.name'];
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.27.0",
"pino": "7.2.0",
"pino": "7.10.0",
"semver": "^7.3.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class PinoInstrumentation extends InstrumentationBase {
const instrumentation = this;
const patchedPino = Object.assign((...args: unknown[]) => {
if (args.length == 0) {
return pinoModule({ mixin: instrumentation._getMixinFunction() });
return pinoModule({
mixin: instrumentation._getMixinFunction(),
});
}

if (args.length == 1) {
Expand Down Expand Up @@ -84,15 +86,15 @@ export class PinoInstrumentation extends InstrumentationBase {
this._config = config;
}

private _callHook(span: Span, record: Record<string, string>) {
private _callHook(span: Span, record: Record<string, string>, level: number) {
const hook = this.getConfig().logHook;

if (!hook) {
return;
}

safeExecuteInTheMiddle(
() => hook(span, record),
() => hook(span, record, level),
err => {
if (err) {
diag.error('pino instrumentation: error calling logHook', err);
Expand All @@ -104,7 +106,7 @@ export class PinoInstrumentation extends InstrumentationBase {

private _getMixinFunction() {
const instrumentation = this;
return function otelMixin() {
return function otelMixin(_context: object, level: number) {
if (!instrumentation.isEnabled()) {
return {};
}
Expand All @@ -127,7 +129,7 @@ export class PinoInstrumentation extends InstrumentationBase {
trace_flags: `0${spanContext.traceFlags.toString(16)}`,
};

instrumentation._callHook(span, record);
instrumentation._callHook(span, record, level);

return record;
};
Expand All @@ -146,8 +148,11 @@ export class PinoInstrumentation extends InstrumentationBase {
const originalMixin = options.mixin;
const otelMixin = this._getMixinFunction();

options.mixin = () => {
return Object.assign(otelMixin(), originalMixin());
options.mixin = (context: object, level: number) => {
return Object.assign(
otelMixin(context, level),
originalMixin(context, level)
);
};

return options;
Expand Down
6 changes: 5 additions & 1 deletion plugins/node/opentelemetry-instrumentation-pino/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import type { pino } from 'pino';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type LogHookFunction = (span: Span, record: Record<string, any>) => void;
export type LogHookFunction = (
span: Span,
record: Record<string, any>,
level?: number // Available in pino >= 7.9.0
) => void;

export interface PinoInstrumentationConfig extends InstrumentationConfig {
logHook?: LogHookFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import { Writable } from 'stream';
import * as assert from 'assert';
import * as sinon from 'sinon';
import * as semver from 'semver';
import type { pino as Pino } from 'pino';

import { PinoInstrumentation } from '../src';
Expand Down Expand Up @@ -112,8 +113,11 @@ describe('PinoInstrumentation', () => {
const span = tracer.startSpan('abc');
instrumentation.setConfig({
enabled: true,
logHook: (_span, record) => {
logHook: (_span, record, level) => {
record['resource.service.name'] = 'test-service';
if (semver.satisfies(pino.version, '>= 7.9.0')) {
assert.strictEqual(level, 30);
}
},
});
context.with(trace.setSpan(context.active(), span), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,29 @@
* limitations under the License.
*/

const webpack = require('webpack');

const karmaWebpackConfig = require('../../../karma.webpack');
const karmaBaseConfig = require('../../../karma.base');

module.exports = (config) => {
{
const plugins = karmaWebpackConfig.plugins = [];
plugins.push(new webpack.ProvidePlugin({
process: 'process/browser',
}));
}

{
const plugins = karmaBaseConfig.plugins = [];
const toAdd = Object.keys(require('./package.json').devDependencies)
.filter((packageName) => packageName.startsWith('karma-'))
.map((packageName) => require(packageName));
plugins.push(
...toAdd
);
}

config.set(Object.assign({}, karmaBaseConfig, {
webpack: karmaWebpackConfig
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,32 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@opentelemetry/api": "1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"assert": "2.0.0",
"babel-loader": "8.2.2",
"gts": "3.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "6.3.16",
"karma-chrome-launcher": "3.1.0",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "4.0.2",
"karma-spec-reporter": "0.0.33",
"karma-webpack": "5.0.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
"process": "0.11.10",
"rimraf": "3.0.2",
"sinon": "13.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"typescript": "4.3.5",
"webpack": "4.46.0",
"webpack-cli": "4.7.2",
"util": "0.12.4",
"webpack": "5.72.0",
"webpack-cli": "4.9.2",
"webpack-merge": "5.8.0"
},
"dependencies": {
Expand Down
Loading

0 comments on commit eb4d24c

Please sign in to comment.