Skip to content

Commit

Permalink
added missing tracing instrumentations + permissions missing export
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandra-c committed Jul 30, 2024
1 parent 32433b8 commit b7afd34
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 29 deletions.
15 changes: 9 additions & 6 deletions generators/app/templates/infrastructure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<%_} _%>
},
"lint-staged": {
"**/*.+(js|md|css|graphql|json)": "prettier --write"
"**/*.+(js|md|css|graphql|json)": "prettier --write"
},
"author": "",
"license": "ISC",
Expand Down Expand Up @@ -65,6 +65,10 @@
"mssql": "^8.1.2",
"knex": "^0.95.0",
"async-mutex": "^0.4.0",
"colors": "^1.4.0",
<%_ if(addTracing){ _%>
"@opentelemetry/instrumentation-knex": "^0.38.0",
<%_} _%>
<%_ if(withMultiTenancy && hasSharedDb) {_%>
"@totalsoft/knex-filters": "^2.4.1",
<%_} _%>
Expand All @@ -74,7 +78,6 @@
"@totalsoft/messaging-host": "^2.5.0",
<%_}_%>
"bluebird": "^3.7.2",
"colors": "^1.4.0",
"console-stamp": "^3.1.2",
"dotenv": "^16.4.5",
"graphql": "^16.9.0",
Expand All @@ -84,6 +87,10 @@
"graphql-ws": "^5.16.0",
"ioredis": "^5.4.1",
"ws": "^8.18.0",
<%_ if(addTracing){ _%>
"@opentelemetry/instrumentation-ioredis": "^0.42.0",
"@totalsoft/opentelemetry-instrumentation-ws": "^2.0.0",
<%_}_%>
<%_}_%>
<%_ if(withRights){ _%>
"graphql-middleware": "^6.1.35",
Expand All @@ -103,14 +110,11 @@
"@opentelemetry/instrumentation-dataloader": "^0.11.0",
"@opentelemetry/instrumentation-graphql": "^0.42.0",
"@opentelemetry/instrumentation-http": "^0.52.1",
"@opentelemetry/instrumentation-ioredis": "^0.42.0",
"@opentelemetry/instrumentation-knex": "^0.38.0",
"@opentelemetry/instrumentation-koa": "^0.42.0",
"@opentelemetry/instrumentation-pino": "^0.41.0",
"@opentelemetry/sdk-trace-base": "^1.25.1",
"@opentelemetry/sdk-trace-node": "^1.25.1",
"@opentelemetry/propagator-jaeger": "^1.25.1",
"@totalsoft/opentelemetry-instrumentation-ws": "^2.0.0",
"@totalsoft/pino-opentelemetry": "^2.0.0",
<%_}_%>
"jsonwebtoken": "9.0.2",
Expand All @@ -134,7 +138,6 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-node": "^11.1.0",
"graphql-schema-linter": "^3.0.1",
"husky": "^9.1.1",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,22 @@
<%_}_%>
}

input PagerInput {
afterId: ID
sortBy: String
direction: Int
pageSize: Int
}

type Page {
afterId: ID
sortBy: String
direction: Int
pageSize: Int
}

type Pagination {
totalCount: Int
prevPage: Page
nextPage: Page
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ const tenantIdentification = require("./tenantIdentification");
const tracingMiddleware = require('./tracing/tracingMiddleware');
<%_}_%>
const loggingMiddleware = require('./logger/loggingMiddleware')
<%_ if(withRights){ _%>
const permissionsMiddleware = require('./permissions')
<%_}_%>


module.exports = {
...validateToken,
<%_ if(withRights){ _%>
...permissionsMiddleware,
<%_}_%>
<%_ if(dataLayer == "knex") {_%>
contextDbInstance,
<%_}_%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { makeExecutableSchema } = require('@graphql-tools/schema'),

<%_ if(withRights){ _%>
const { applyMiddleware } = require('graphql-middleware'),
{ permissionsMiddleware } = require('../middleware/permissions/index')
{ permissionsMiddleware } = require('../middleware')
<%_}_%>


Expand Down
13 changes: 10 additions & 3 deletions generators/app/templates/infrastructure/src/startup/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ const { Resource } = require("@opentelemetry/resources")
const { JaegerPropagator } = require("@opentelemetry/propagator-jaeger")
<%_ if(addSubscriptions) {_%>
const { WSInstrumentation } = require("@totalsoft/opentelemetry-instrumentation-ws")
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis')
<%_} _%>
const { SEMRESATTRS_SERVICE_NAME, SEMATTRS_PEER_SERVICE } = require('@opentelemetry/semantic-conventions')
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc')
const { ParentBasedSampler, AlwaysOnSampler } = require('@opentelemetry/sdk-trace-node')
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http')
const { PinoInstrumentation } = require('@opentelemetry/instrumentation-pino')
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis')
<%_ if(dataLayer == 'knex') {_%>
const { KnexInstrumentation } = require("@opentelemetry/instrumentation-knex");
<%_}_%>
const { DataloaderInstrumentation } = require("@opentelemetry/instrumentation-dataloader");
const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql')
const { context, trace } = require('@opentelemetry/api')
const { getRPCMetadata, RPCType } = require('@opentelemetry/core')
Expand Down Expand Up @@ -54,15 +58,18 @@ const sdk = new opentelemetry.NodeSDK({
mergeItems: true,
responseHook: (span, _) => {
const rpcMetadata = getRPCMetadata(context.active())

if (rpcMetadata?.type === RPCType.HTTP) {
rpcMetadata?.span?.updateName(`${rpcMetadata?.span?.name} ${span.name}`)
}
}
}),
new PinoInstrumentation(),
new IORedisInstrumentation(),
<%_ if(dataLayer == 'knex') {_%>
new KnexInstrumentation(),
<%_} _%>
new DataloaderInstrumentation(),
<%_ if(addSubscriptions) {_%>
new IORedisInstrumentation(),
new WSInstrumentation(),
<%_} _%>
<%_ if(dataLayer == 'prisma') {_%>
Expand Down

0 comments on commit b7afd34

Please sign in to comment.