diff --git a/CHANGELOG.md b/CHANGELOG.md index 32a67c5a..c77af772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ [1]: https://www.npmjs.com/package/nodejs-logging?activeTab=versions +## [10.3.1](https://github.com/googleapis/nodejs-logging/compare/v10.3.0...v10.3.1) (2022-11-07) + + +### Bug Fixes + +* Switch instrumentation code to work with NODEJS_DEFAULT_LIBRARY_VERSION only ([#1373](https://github.com/googleapis/nodejs-logging/issues/1373)) ([32b22b4](https://github.com/googleapis/nodejs-logging/commit/32b22b4c17376a51f413481b3e412a88c0f83f06)) + ## [10.3.0](https://github.com/googleapis/nodejs-logging/compare/v10.2.3...v10.3.0) (2022-11-04) diff --git a/package.json b/package.json index 51bc5a80..878d7f90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@google-cloud/logging", - "version": "10.3.0", + "version": "10.3.1", "description": "Cloud Logging Client Library for Node.js", "keywords": [ "google apis client", @@ -78,7 +78,7 @@ "codecov": "^3.6.5", "gts": "^3.1.0", "http2spy": "^2.0.0", - "jsdoc": "^3.6.3", + "jsdoc": "^4.0.0", "jsdoc-fresh": "^2.0.0", "jsdoc-region-tag": "^2.0.0", "linkinator": "^4.0.0", diff --git a/samples/generated/v2/snippet_metadata.google.logging.v2.json b/samples/generated/v2/snippet_metadata.google.logging.v2.json index 57ff7075..81eb2eff 100644 --- a/samples/generated/v2/snippet_metadata.google.logging.v2.json +++ b/samples/generated/v2/snippet_metadata.google.logging.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-logging", - "version": "10.3.0", + "version": "10.3.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/samples/package.json b/samples/package.json index 0aa22715..fa11277d 100644 --- a/samples/package.json +++ b/samples/package.json @@ -14,7 +14,7 @@ "test": "mocha --timeout 60000" }, "dependencies": { - "@google-cloud/logging": "^10.3.0", + "@google-cloud/logging": "^10.3.1", "@google-cloud/storage": "^6.0.0", "express": "^4.16.3", "fluent-logger": "^3.0.0", diff --git a/src/utils/instrumentation.ts b/src/utils/instrumentation.ts index 4b21482b..896739ca 100644 --- a/src/utils/instrumentation.ts +++ b/src/utils/instrumentation.ts @@ -15,7 +15,6 @@ */ import arrify = require('arrify'); -import path = require('path'); import {Entry} from '../entry'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -29,16 +28,18 @@ global.instrumentationAdded = false; // The global variable to avoid records inspection once instrumentation already written to prevent perf impact global.shouldSkipInstrumentationCheck = false; -// The variable to hold cached library version -let libraryVersion: string; - // Max length for instrumentation library name and version values const maxDiagnosticValueLen = 14; export const DIAGNOSTIC_INFO_KEY = 'logging.googleapis.com/diagnostic'; export const INSTRUMENTATION_SOURCE_KEY = 'instrumentation_source'; export const NODEJS_LIBRARY_NAME_PREFIX = 'nodejs'; -export const NODEJS_DEFAULT_LIBRARY_VERSION = '10.3.0'; // {x-release-please-version} +/** + * Default library version to be used + * Using release-please annotations to update DEFAULT_INSTRUMENTATION_VERSION with latest version. + * See https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files + */ +export const NODEJS_DEFAULT_LIBRARY_VERSION = '10.3.1'; // {x-release-please-version} export const MAX_INSTRUMENTATION_COUNT = 3; export type InstrumentationInfo = {name: string; version: string}; @@ -184,24 +185,11 @@ function truncateValue(value: object | string, maxLen: number) { } /** - * The helper function to retrieve current library version from 'package.json' file. Note that - * since we use {path.resolve}, the search for 'package.json' could be impacted by current working directory. + * The helper function to retrieve current library version from annotated NODEJS_DEFAULT_LIBRARY_VERSION * @returns {string} A current library version. */ export function getNodejsLibraryVersion() { - if (libraryVersion) { - return libraryVersion; - } - try { - libraryVersion = require(path.resolve( - __dirname, - '../../../', - 'package.json' - )).version; - } catch (err) { - libraryVersion = NODEJS_DEFAULT_LIBRARY_VERSION; - } - return libraryVersion; + return NODEJS_DEFAULT_LIBRARY_VERSION; } /**