Skip to content

Commit

Permalink
fix: remove warnings from package install
Browse files Browse the repository at this point in the history
also upgrade jest
  • Loading branch information
davemooreuws committed Jul 26, 2024
1 parent 68fda3c commit df8d218
Show file tree
Hide file tree
Showing 4 changed files with 912 additions and 2,005 deletions.
6 changes: 4 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pathsToModuleNameMapper } from 'ts-jest/utils';
import { pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions } from './tsconfig.json';

module.exports = {
Expand All @@ -8,5 +8,7 @@ module.exports = {
roots: ['<rootDir>'],
coveragePathIgnorePatterns: ['src/gen/'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths,/*, { prefix: '<rootDir>/' } */),
moduleNameMapper: pathsToModuleNameMapper(
compilerOptions.paths /*, { prefix: '<rootDir>/' } */
),
};
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
"dependencies": {
"@grpc/grpc-js": "1.10.0",
"@nitric/grpc-error-status": "^0.0.2",
"@opentelemetry/api": "^1.4.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.48.0",
"@opentelemetry/instrumentation": "^0.48.0",
"@opentelemetry/instrumentation-grpc": "^0.48.0",
"@opentelemetry/instrumentation-http": "^0.48.0",
"@opentelemetry/resources": "^1.21.0",
"@opentelemetry/sdk-trace-node": "^1.21.0",
"@opentelemetry/semantic-conventions": "^1.21.0",
"google-protobuf": "3.14.0",
"portfinder": "^1.0.32",
"tslib": "^2.1.0"
Expand All @@ -57,7 +49,7 @@
},
"devDependencies": {
"@types/google-protobuf": "^3.15.6",
"@types/jest": "^26.0.15",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.17",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
Expand All @@ -67,13 +59,13 @@
"glob-run": "^0.1.7",
"grpc-tools": "^1.11.3",
"husky": "^6.0.0",
"jest": "^26.6.1",
"jest": "^29.0.10",
"license-check-and-add": "^4.0.2",
"licensee": "^8.2.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"standard-version": "^9.0.0",
"ts-jest": "^26.4.3",
"ts-jest": "^29.1.5",
"ts-node": "^10.9.1",
"ts-protoc-gen": "^0.15.0",
"tsconfig-paths": "^4.2.0",
Expand Down
96 changes: 48 additions & 48 deletions src/traceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,58 @@
// 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 {
BatchSpanProcessor,
NodeTracerProvider,
NoopSpanProcessor,
} from '@opentelemetry/sdk-trace-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { GrpcInstrumentation } from '@opentelemetry/instrumentation-grpc';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-node';
// import {
// BatchSpanProcessor,
// NodeTracerProvider,
// NoopSpanProcessor,
// } from '@opentelemetry/sdk-trace-node';
// import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
// import { Resource } from '@opentelemetry/resources';
// import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
// import { GrpcInstrumentation } from '@opentelemetry/instrumentation-grpc';
// import { registerInstrumentations } from '@opentelemetry/instrumentation';
// import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
// import { TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-node';

/**
* Creates a new node tracer provider
* If it is a local run, it will output to the console. If it is run on the cloud it will output to localhost:4317
*
* @returns a tracer provider
*/
const newTracerProvider = (): NodeTracerProvider => {
// Add trace provider
const localRun = !process.env.OTELCOL_BIN;
const samplePercentage = localRun
? 100 // local default to 100
: Number.parseInt(process.env.NITRIC_TRACE_SAMPLE_PERCENT) || 0;
// /**
// * Creates a new node tracer provider
// * If it is a local run, it will output to the console. If it is run on the cloud it will output to localhost:4317
// *
// * @returns a tracer provider
// */
// const newTracerProvider = (): NodeTracerProvider => {
// // Add trace provider
// const localRun = !process.env.OTELCOL_BIN;
// const samplePercentage = localRun
// ? 100 // local default to 100
// : Number.parseInt(process.env.NITRIC_TRACE_SAMPLE_PERCENT) || 0;

const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: process.env.NITRIC_STACK ?? '',
[SemanticResourceAttributes.SERVICE_VERSION]:
process.env.npm_package_version ?? '0.0.1',
}),
sampler: new TraceIdRatioBasedSampler(samplePercentage),
});
// const provider = new NodeTracerProvider({
// resource: new Resource({
// [SemanticResourceAttributes.SERVICE_NAME]: process.env.NITRIC_STACK ?? '',
// [SemanticResourceAttributes.SERVICE_VERSION]:
// process.env.npm_package_version ?? '0.0.1',
// }),
// sampler: new TraceIdRatioBasedSampler(samplePercentage),
// });

registerInstrumentations({
instrumentations: [new HttpInstrumentation(), new GrpcInstrumentation()],
tracerProvider: provider,
});
// registerInstrumentations({
// instrumentations: [new HttpInstrumentation(), new GrpcInstrumentation()],
// tracerProvider: provider,
// });

const processor = localRun
? new NoopSpanProcessor()
: new BatchSpanProcessor(
new OTLPTraceExporter({
url: 'http://localhost:4317',
})
);
// const processor = localRun
// ? new NoopSpanProcessor()
// : new BatchSpanProcessor(
// new OTLPTraceExporter({
// url: 'http://localhost:4317',
// })
// );

provider.addSpanProcessor(processor);
provider.register();
// provider.addSpanProcessor(processor);
// provider.register();

return provider;
};
// return provider;
// };

export default newTracerProvider;
// export default newTracerProvider;
Loading

0 comments on commit df8d218

Please sign in to comment.