https://signoz.io logo
#support
Title
# support
j

Jonathan Sun

01/03/2023, 5:25 AM
hi, does anyone have nestJS + Graphql application example? I followed this one https://signoz.io/blog/monitoring-graphql/ but not working. appreciate any input for this.
v

Vishal Sharma

01/03/2023, 6:15 AM
What errors did you face?
j

Jonathan Sun

01/03/2023, 6:16 AM
hi, actually there was no errors it just cannot elaborate (parse graphql) details for my api request.
I installed packages as blog described and to new GraphQLInstrumentation accordingly.
but when I deploy it on both localhost and cloud there is nothing change.
v

Vishal Sharma

01/03/2023, 6:18 AM
Can you please share your package.json?
j

Jonathan Sun

01/03/2023, 6:18 AM
sure. hold on.
{
“name”: “backend”, “version”: “0.0.1", “description”: “”, “author”: “”, “private”: true, “license”: “UNLICENSED”, “scripts”: { “prebuild”: “rimraf dist”, “build”: “nest build”, “format”: “prettier --write \“src/**/*.ts\” \“test/**/*.ts\“”, “start”: “nest start”, “startdev” “nest start --watch”, “startdebug” “nest start --debug --watch”, “startprod” “node dist/main”, “lint”: “eslint \“{src,apps,libs,test}/**/*.ts\” --fix”, “test”: “jest”, “testwatch” “jest --watch”, “testcov” “jest --coverage”, “testdebug” “node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand”, “teste2e” “jest --config ./test/jest-e2e.json” }, “dependencies”: { “@nestjs/apollo”: “^10.0.9”, “@nestjs/axios”: “^1.0.0”, “@nestjs/class-validator”: “^0.13.1”, “@nestjs/common”: “^8.0.0”, “@nestjs/config”: “^1.2.0”, “@nestjs/core”: “^8.0.0”, “@nestjs/graphql”: “^10.0.2”, “@nestjs/jwt”: “^8.0.0”, “@nestjs/passport”: “^8.2.1”, “@nestjs/platform-express”: “^8.0.0”, “@nestjs/typeorm”: “^8.0.3”, “@opentelemetry/api”: “^1.0.3”, “@opentelemetry/auto-instrumentations-node”: “^0.25.0”, “@opentelemetry/exporter-otlp-grpc”: “^0.26.0”, “@opentelemetry/exporter-trace-otlp-grpc”: “^0.34.0”, “@opentelemetry/instrumentation-graphql”: “0.27.4”, “@opentelemetry/resources”: “^0.24.0”, “@opentelemetry/sdk-node”: “0.27.0”, “@opentelemetry/sdk-trace-base”: “^1.0.1”, “@opentelemetry/sdk-trace-node”: “^1.0.1”, “@opentelemetry/semantic-conventions”: “^0.24.0”, “@superlayer/superlayer-logger”: “^1.1.2”, “apollo-server-core”: “^3.6.4”, “apollo-server-express”: “^3.5.0”, “await-to-js”: “^3.0.0”, “aws-cloudfront-sign”: “^2.2.0”, “aws-sdk”: “^2.1094.0”, “class-transformer”: “^0.5.1”, “class-validator”: “^0.13.2”, “cookie-parser”: “^1.4.6”, “dicer”: “^0.3.1”, “fastify-cookie”: “^5.7.0”, “format-duration”: “^3.0.1”, “get-video-duration”: “^4.1.0”, “graphql”: “^15.8.0”, “graphql-upload”: “^13.0.0”, “m3u8-parser”: “^6.0.0”, “mysql2": “^2.3.3”, “nestjs-library-starter”: “^1.12.0”, “passport”: “^0.5.2”, “passport-headerapikey”: “^1.2.2”, “passport-jwt”: “^4.0.0”, “reflect-metadata”: “^0.1.13”, “rimraf”: “^3.0.2”, “rxjs”: “^7.2.0”, “typeorm”: “^0.2.45”, “uuid”: “^8.3.2”, “winston-cloudwatch”: “^3.1.1” }, “devDependencies”: { “@nestjs/cli”: “^8.0.0", “@nestjs/schematics”: “^8.0.0", “@nestjs/testing”: “^8.0.0", “@types/cookie-parser”: “^1.4.3", “@types/express”: “^4.17.13", “@types/jest”: “27.4.1", “@types/node”: “^16.0.0", “@types/passport-jwt”: “^3.0.6", “@types/supertest”: “^2.0.11", “@typescript-eslint/eslint-plugin”: “^5.0.0", “@typescript-eslint/parser”: “^5.0.0", “eslint”: “^8.0.1", “eslint-config-prettier”: “^8.3.0", “eslint-plugin-prettier”: “^4.0.0", “jest”: “^27.2.5", “prettier”: “^2.3.2", “source-map-support”: “^0.5.20", “supertest”: “^6.1.3", “ts-jest”: “^27.0.3", “ts-loader”: “^9.2.3", “ts-node”: “^10.0.0", “tsconfig-paths”: “^3.10.1", “typescript”: “^4.3.5" }, “jest”: { “moduleFileExtensions”: [ “js”, “json”, “ts” ], “rootDir”: “src”, “testRegex”: “.*\\.spec\\.ts$“, “transform”: { “^.+\\.(t|j)s$“: “ts-jest” }, “collectCoverageFrom”: [ “**/*.(t|j)s” ], “coverageDirectory”: “../coverage”, “testEnvironment”: “node” } }
wrong pacakage.json, let me reproduce the one I was bumped into.
I revert the merge, let me start over.
@Vishal Sharma here is the error msg:
src/tracer.ts:26:7 - error TS2322: Type 'GraphQLInstrumentation' is not assignable to type 'InstrumentationOption'.
Type ‘GraphQLInstrumentation’ is not assignable to type ‘Instrumentation’. Types of property ‘setMeterProvider’ are incompatible. Type ‘(meterProvider: import(“/Users/jonathan/Documents/4i/GitHub/hotline-media-backend/node_modules/@opentelemetry/instrumentation-graphql/node_modules/@opentelemetry/api-metrics/build/src/types/MeterProvider”).MeterProvider) => void’ is not assignable to type ‘(meterProvider: import(“/Users/jonathan/Documents/4i/GitHub/hotline-media-backend/node_modules/@opentelemetry/api/build/src/metrics/MeterProvider”).MeterProvider) => void’. Types of parameters ‘meterProvider’ and ‘meterProvider’ are incompatible. Type ‘import(“/Users/jonathan/Documents/4i/GitHub/hotline-media-backend/node_modules/@opentelemetry/api/build/src/metrics/MeterProvider”).MeterProvider’ is not assignable to type ‘import(“/Users/jonathan/Documents/4i/GitHub/hotline-media-backend/node_modules/@opentelemetry/instrumentation-graphql/node_modules/@opentelemetry/api-metrics/build/src/types/MeterProvider”).MeterProvider’. The types returned by ‘getMeter(...).createObservableGauge(...)’ are incompatible between these types. Property ‘observation’ is missing in type ‘Observable<Attributes>’ but required in type ‘ObservableBase’. 26 new GraphQLInstrumentation({ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27 allowValues: true, ~~~~~~~~~~~~~~~~~~~~~~~~~~ 28 }), ~~~~~~~~ node_modules/@opentelemetry/instrumentation-graphql/node_modules/@opentelemetry/api-metrics/build/src/types/Metric.d.ts855 85 observation: (value: number, attributes?: Attributes) => Observation; ~~~~~~~~~~~ ‘observation’ is declared here. [25501 PM] Found 1 error. Watching for file changes.
and here is my package.json file:
{
“name”: “backend”, “version”: “0.0.1", “description”: “”, “author”: “”, “private”: true, “license”: “UNLICENSED”, “scripts”: { “prebuild”: “rimraf dist”, “build”: “nest build”, “format”: “prettier --write \“src/**/*.ts\” \“test/**/*.ts\“”, “start”: “nest start”, “startdev” “nest start --watch”, “startdebug” “nest start --debug --watch”, “startprod” “node dist/main”, “lint”: “eslint \“{src,apps,libs,test}/**/*.ts\” --fix”, “test”: “jest”, “testwatch” “jest --watch”, “testcov” “jest --coverage”, “testdebug” “node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand”, “teste2e” “jest --config ./test/jest-e2e.json” }, “dependencies”: { “@nestjs/apollo”: “^10.0.9”, “@nestjs/axios”: “^1.0.0”, “@nestjs/class-validator”: “^0.13.1”, “@nestjs/common”: “^8.0.0”, “@nestjs/config”: “^1.2.0”, “@nestjs/core”: “^8.0.0”, “@nestjs/graphql”: “^10.0.2”, “@nestjs/jwt”: “^8.0.0”, “@nestjs/passport”: “^8.2.1”, “@nestjs/platform-express”: “^8.0.0”, “@nestjs/typeorm”: “^8.0.3”, “@opentelemetry/api”: “^1.0.3”, “@opentelemetry/exporter-otlp-grpc”: “^0.26.0”, “@opentelemetry/instrumentation-graphql”: “0.27.4”, “@opentelemetry/sdk-trace-base”: “^1.0.1”, “@opentelemetry/sdk-trace-node”: “^1.0.1”, “@opentelemetry/auto-instrumentations-node”: “^0.35.0”, “@opentelemetry/exporter-trace-otlp-http”: “^0.34.0”, “@opentelemetry/resources”: “^1.8.0”, “@opentelemetry/sdk-node”: “^0.34.0”, “@opentelemetry/semantic-conventions”: “^1.8.0”, “apollo-server-core”: “^3.6.4”, “apollo-server-express”: “^3.5.0”, “await-to-js”: “^3.0.0”, “aws-cloudfront-sign”: “^2.2.0”, “aws-sdk”: “^2.1094.0”, “class-transformer”: “^0.5.1”, “class-validator”: “^0.13.2”, “cookie-parser”: “^1.4.6”, “dicer”: “^0.3.1”, “fastify-cookie”: “^5.7.0”, “format-duration”: “^3.0.1”, “get-video-duration”: “^4.1.0”, “graphql”: “^15.8.0”, “graphql-upload”: “^13.0.0”, “m3u8-parser”: “^6.0.0”, “mysql2": “^2.3.3”, “nestjs-library-starter”: “^1.12.0”, “passport”: “^0.5.2”, “passport-headerapikey”: “^1.2.2”, “passport-jwt”: “^4.0.0”, “reflect-metadata”: “^0.1.13”, “rimraf”: “^3.0.2”, “rxjs”: “^7.2.0”, “typeorm”: “^0.2.45”, “uuid”: “^8.3.2”, “winston-cloudwatch”: “^3.1.1” }, “devDependencies”: { “@nestjs/cli”: “^8.0.0", “@nestjs/schematics”: “^8.0.0", “@nestjs/testing”: “^8.0.0", “@types/cookie-parser”: “^1.4.3", “@types/express”: “^4.17.13", “@types/jest”: “27.4.1", “@types/node”: “^16.0.0", “@types/passport-jwt”: “^3.0.6", “@types/supertest”: “^2.0.11", “@typescript-eslint/eslint-plugin”: “^5.0.0", “@typescript-eslint/parser”: “^5.0.0", “eslint”: “^8.0.1", “eslint-config-prettier”: “^8.3.0", “eslint-plugin-prettier”: “^4.0.0", “jest”: “^27.2.5", “prettier”: “^2.3.2", “source-map-support”: “^0.5.20", “supertest”: “^6.1.3", “ts-jest”: “^27.0.3", “ts-loader”: “^9.2.3", “ts-node”: “^10.0.0", “tsconfig-paths”: “^3.10.1", “typescript”: “^4.3.5" }, “jest”: { “moduleFileExtensions”: [ “js”, “json”, “ts” ], “rootDir”: “src”, “testRegex”: “.*\\.spec\\.ts$“, “transform”: { “^.+\\.(t|j)s$“: “ts-jest” }, “collectCoverageFrom”: [ “**/*.(t|j)s” ], “coverageDirectory”: “../coverage”, “testEnvironment”: “node” } }
@Vishal Sharma and by doing so the service is not showing on dashboard as well.
v

Vishal Sharma

01/03/2023, 7:27 AM
Apollo graphQL supports otel instrumentation. We have tested it earlier.
j

Jonathan Sun

01/03/2023, 7:30 AM
there is an empty column which indicates my graphql call.
checking!
v

Vishal Sharma

01/03/2023, 7:34 AM
@Jonathan Sun I also see that you are using older version of below packages:
Copy code
"@opentelemetry/exporter-otlp-grpc": "^0.26.0",
    "@opentelemetry/instrumentation-graphql": "0.27.4",
    "@opentelemetry/sdk-trace-base": "^1.0.1",
    "@opentelemetry/sdk-trace-node": "^1.0.1",
But using latest versions of some other packages. Please use latest version of all otel packages.
Or use version specified in blog.
j

Jonathan Sun

01/03/2023, 7:52 AM
let me try!
issue solved! we found we can not call the start() function in another wrapped function.
77 Views