Skip to content

Commit

Permalink
observability: dynamically retrieve TRACER_VERSION from published pac…
Browse files Browse the repository at this point in the history
…kage.json (#2133)

This change dynamically retrieves the published version of this module from the package.json.version variable.

Updates #2079
  • Loading branch information
odeke-em authored Sep 29, 2024
1 parent 37e0346 commit 5b70b70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions observability-test/observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ describe('startTrace', () => {
);
});

it('sanity check: TRACER_NAME, TRACER_VERSION', () => {
assert.equal(!TRACER_NAME, false, 'TRACER_NAME must be set');
assert.equal(!TRACER_VERSION, false, 'TRACER_VERSION must be set');
});

it('with semantic attributes', () => {
const opts = {tableName: 'table', dbName: 'db'};
startTrace('aSpan', opts, span => {
Expand Down
2 changes: 1 addition & 1 deletion src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface observabilityOptions {
export type {observabilityOptions as ObservabilityOptions};

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

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

Expand Down

0 comments on commit 5b70b70

Please sign in to comment.