pragmaticivan / nestjs-otel

OpenTelemetry (Tracing + Metrics) module for Nest framework (node.js) 🔭
Apache License 2.0
562 stars 48 forks source link

Counter example from the README generating TS errors #471

Closed slia-stryber closed 6 months ago

slia-stryber commented 8 months ago
import { OtelCounter } from 'nestjs-otel';
import { Counter } from '@opentelemetry/api';

@Controller()
export class AppController {
  @Get('/home')
  home(
    @OtelCounter('app_counter_1_inc', { description: 'counter 1 description' }) counter1: Counter
  ) {
    counter1.add(1);
  }
}

TS2345: Argument of type MetricOptions is not assignable to parameter of type string | PipeTransform<any, any> | Type<PipeTransform<any, any>>

It's related to the { description: 'counter 1 description' } argument.

slia-stryber commented 8 months ago

package.json

"dependencies": {
    "@nestjs/common": "^10.3.3",
    "@nestjs/core": "^10.3.3",
    "@nestjs/platform-express": "^10.3.3",
    "@nestjs/swagger": "^7.3.0",
    "@opentelemetry/auto-instrumentations-node": "^0.43.0",
    "@opentelemetry/exporter-prometheus": "^0.49.1",
    "@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
    "@opentelemetry/host-metrics": "^0.35.0",
    "@opentelemetry/instrumentation-express": "^0.36.1",
    "@opentelemetry/instrumentation-nestjs-core": "^0.35.0",
    "@opentelemetry/instrumentation-pino": "^0.36.0",
    "@opentelemetry/sdk-node": "^0.49.1",
    "nestjs-otel": "^5.1.5",
    "nestjs-pino": "^4.0.0",
    "opentelemetry-node-metrics": "^3.0.0",
    "pino": "^8.19.0",
    "pino-http": "^9.0.0",
    "pino-pretty": "^10.3.1",
    "reflect-metadata": "^0.2.1",
    "swagger-ui-express": "^5.0.0",
    "rimraf": "^5.0.5"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.3.2",
    "@nestjs/schematics": "^10.1.1",
    "@nestjs/testing": "^10.3.3",
    "@opentelemetry/api-metrics": "^0.32.0",
    "@types/express": "^4.17.21",
    "@types/jest": "^29.5.12",
    "@types/node": "^20.11.27",
    "@types/supertest": "^6.0.2",
    "@typescript-eslint/eslint-plugin": "^7.2.0",
    "@typescript-eslint/parser": "^7.2.0",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "9.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "jest": "^29.7.0",
    "prettier": "^3.2.5",
    "supertest": "^6.3.4",
    "ts-jest": "^29.1.2",
    "ts-loader": "^9.5.1",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.4.2"
  },
pragmaticivan commented 6 months ago

Fixed