Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [7.2.1] - 2025-09-08
### Fixed
- Ensure `global.metrics` is initialized in both master and worker processes to prevent undefined errors in status tracking and metrics reporting

## [7.2.0] - 2025-09-08
### Changed
- Add metrics instrumentation based on diagnostics lib
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/api",
"version": "7.2.0",
"version": "7.2.1",
"description": "VTEX I/O API client",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
13 changes: 13 additions & 0 deletions src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import { initializeTelemetry } from './telemetry'
import cluster from 'cluster'

import { HTTP_SERVER_PORT } from '../constants'
import { MetricsAccumulator } from '../metrics/MetricsAccumulator'
import { getServiceJSON } from './loaders'
import { LogLevel, logOnceToDevConsole } from './logger'

export const startApp = async () => {
await initializeTelemetry()

// Initialize global.metrics for both master and worker processes
global.metrics = new MetricsAccumulator()

const serviceJSON = getServiceJSON()
try {
// if it is a master process then call setting up worker process
Expand All @@ -27,3 +32,11 @@ export const startApp = async () => {

export { appPath } from './loaders'

declare global {
namespace NodeJS {
interface Global {
metrics: MetricsAccumulator
}
}
}

10 changes: 0 additions & 10 deletions src/service/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,3 @@ export const startWorker = (serviceJSON: ServiceJSON) => {

return app
}

global.metrics = new MetricsAccumulator()

declare global {
namespace NodeJS {
interface Global {
metrics: MetricsAccumulator
}
}
}
Loading