{"record":{"id":"ed2b1f0d4a31c79f","repo":"Unitech/pm2","slug":"servicename-is-required","errorCode":null,"errorMessage":"serviceName is required","messagePattern":"serviceName is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/pm2-io-bpm/features/tracing.js","lineNumber":139,"sourceCode":"                return false\n              }\n              return this.options.ignoreOutgoingUrls.some((matcher) => applyMatcher(matcher, request))\n            }\n          }\n        })\n      ]\n    })\n\n    this.otel.start()\n\n    Configuration.configureModule({\n      otel_tracing: true\n    })\n  }\n\n  getTracer () {\n    if (!this.options.serviceName) {\n      throw new Error('serviceName is required')\n    }\n    const { trace } = require('@opentelemetry/api')\n    return trace.getTracer(this.options.serviceName)\n  }\n\n  destroy () {\n    if (!this.otel) return\n    this.logger('stop otel tracer')\n    this.otel.shutdown()\n\n    Configuration.configureModule({\n      otel_tracing: false\n    })\n  }\n}\n\nfunction applyMatcher (matcher, request) {\n  if (!matcher) {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/Unitech/pm2/blob/31adee8048dbbc1ee36a7df7cdbcaca2559708df/modules/pm2-io-bpm/features/tracing.js#L121-L157","documentation":"The BPM tracing feature's getTracer() returns an OpenTelemetry tracer that must be labeled with a serviceName — the identity of the instrumented service. Without serviceName, spans have no service identity, so the method throws to prevent emitting unattributed telemetry.","triggerScenarios":"Calling getTracer() (or enabling OTel tracing) without setting serviceName in the tracing options.","commonSituations":"Enabling tracing with a partial config; forgetting the serviceName key when initializing the agent; copying a config sample that omitted it.","solutions":["Pass serviceName in the tracing options (a stable identifier for your service).","Set it at init, e.g. apm.init({ tracing: { serviceName: 'my-api' } })."],"exampleFix":"// before\napm.init({ tracing: { enabled: true } });\n// after\napm.init({ tracing: { enabled: true, serviceName: 'my-api' } });","handlingStrategy":"validation","validationCode":"if (!tracingOpts || typeof tracingOpts.serviceName !== 'string' || !tracingOpts.serviceName.trim()) {\n  throw new Error('serviceName is required for OpenTelemetry tracing');\n}","typeGuard":"const hasServiceName = (o) => Boolean(o && typeof o.serviceName === 'string' && o.serviceName.trim());","tryCatchPattern":"try {\n  const tracer = apm.getTracer();\n} catch (e) {\n  if (/serviceName is required/.test(e.message)) {\n    apm.options.serviceName = process.env.npm_package_name || 'default-service';\n    tracer = apm.getTracer();\n  } else throw e;\n}","preventionTips":["Set serviceName at agent init, sourced from package.json name or an env var.","Treat serviceName as required config for any service emitting traces."],"tags":["tracing","opentelemetry","configuration"],"backgroundTag":null,"analyzedSha":"31adee8048dbbc1ee36a7df7cdbcaca2559708df","analyzedAt":"2026-08-13T03:49:51.765Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}