Skip to content

Commit 5b70b70

Browse files
authored
observability: dynamically retrieve TRACER_VERSION from published package.json (#2133)
This change dynamically retrieves the published version of this module from the package.json.version variable. Updates #2079
1 parent 37e0346 commit 5b70b70

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

observability-test/observability.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ describe('startTrace', () => {
122122
);
123123
});
124124

125+
it('sanity check: TRACER_NAME, TRACER_VERSION', () => {
126+
assert.equal(!TRACER_NAME, false, 'TRACER_NAME must be set');
127+
assert.equal(!TRACER_VERSION, false, 'TRACER_VERSION must be set');
128+
});
129+
125130
it('with semantic attributes', () => {
126131
const opts = {tableName: 'table', dbName: 'db'};
127132
startTrace('aSpan', opts, span => {

src/instrument.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface observabilityOptions {
5353
export type {observabilityOptions as ObservabilityOptions};
5454

5555
const TRACER_NAME = 'cloud.google.com/nodejs/spanner';
56-
const TRACER_VERSION = '7.14.0'; // Manually hard coded, TODO: remove
56+
const TRACER_VERSION = require('../../package.json').version;
5757

5858
export {TRACER_NAME, TRACER_VERSION}; // Only exported for testing.
5959

0 commit comments

Comments
 (0)