Skip to content

Commit

Permalink
feat: Add support for instrumentation version annotations (#1370)
Browse files Browse the repository at this point in the history
* feat: Add support for instrumentation version annotations

* 馃 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Fix tests

* Add exclude to owlbot.py

* Add newline

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
losalex and gcf-owl-bot[bot] committed Nov 4, 2022
1 parent bf4f824 commit c039022
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
handleGHRelease: true
releaseType: node
extraFiles: ["src/utils/instrumentation.ts"]
3 changes: 2 additions & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
".eslintignore",
".prettierignore",
"CONTRIBUTING.md",
".github/auto-label.yaml"
".github/auto-label.yaml",
".github/release-please.yml"
]
)

Expand Down
4 changes: 2 additions & 2 deletions src/utils/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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 = 'unknown';
export const NODEJS_DEFAULT_LIBRARY_VERSION = '1.0.0'; // {x-release-please-version}
export const MAX_INSTRUMENTATION_COUNT = 3;
export type InstrumentationInfo = {name: string; version: string};

Expand Down Expand Up @@ -173,7 +173,7 @@ function truncateValue(value: object | string, maxLen: number) {
// Ignore error since flow should continue
}
}
// Return 'unknown' if version cannot be retrieved
// Return NODEJS_DEFAULT_LIBRARY_VERSION if version cannot be retrieved
if (typeof value !== 'string') {
return NODEJS_DEFAULT_LIBRARY_VERSION;
}
Expand Down
4 changes: 2 additions & 2 deletions test/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('instrumentation_info', () => {
);
});

it('should set library version to unknown', () => {
it('should set library version to NODEJS_DEFAULT_LIBRARY_VERSION', () => {
const data = {some: 'value'};
const entry = instrumentation.createDiagnosticEntry(
undefined,
Expand All @@ -70,7 +70,7 @@ describe('instrumentation_info', () => {
entry.data?.[instrumentation.DIAGNOSTIC_INFO_KEY]?.[
instrumentation.INSTRUMENTATION_SOURCE_KEY
]?.[0]?.[VERSION],
'unknown'
instrumentation.NODEJS_DEFAULT_LIBRARY_VERSION
);
});

Expand Down

0 comments on commit c039022

Please sign in to comment.