Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Switch instrumentation code to return version stored in NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION #672

Merged
merged 4 commits into from
Nov 7, 2022
Merged
Changes from 1 commit
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
20 changes: 2 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
setInstrumentationStatus,
createDiagnosticEntry,
} from '@google-cloud/logging/build/src/utils/instrumentation';
import path = require('path');

// Export the express middleware as 'express'.
export {express};
Expand Down Expand Up @@ -75,9 +74,6 @@ export const LOGGING_SAMPLED_KEY = 'logging.googleapis.com/trace_sampled';
*/
export const NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION = '4.2.0'; // {x-release-please-version}

// The variable to hold cached library version
let libraryVersion: string;

/**
* Gets the current fully qualified trace ID when available from the
* @google-cloud/trace-agent library in the LogEntry.trace field format of:
Expand Down Expand Up @@ -477,23 +473,11 @@ export class LoggingBunyan extends Writable {
}

/**
* Method used to retrieve the current logging-bunyan library version
* Method used to retrieve the current logging-bunyan library version stored in NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION
* @returns The version of this library
*/
getNodejsLibraryVersion() {
if (libraryVersion) {
return libraryVersion;
}
try {
libraryVersion = require(path.resolve(
__dirname,
'../../',
'package.json'
)).version;
} catch (err) {
libraryVersion = NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION;
}
return libraryVersion;
return NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION;
}
}

Expand Down