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

feat: (observability) add spans for BatchTransaction and Table #2115

Conversation

odeke-em
Copy link
Contributor

This change is part of a series of changes to add
OpenTelemetry traces, focused on BatchTransaction and Table.

While here, made the tests for sessionPool spans much more precise to avoid flakes.

Updates #2079
Built from PR #2087
Updates #2114

@odeke-em odeke-em requested review from a team as code owners September 17, 2024 13:09
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Sep 17, 2024
src/table.ts Outdated Show resolved Hide resolved
@surbhigarg92
Copy link
Contributor

@odeke-em I don't see any tests for these spans.

@surbhigarg92 surbhigarg92 changed the title observability: trace BatchTransaction and Table feat: (observability) add spans for BatchTransaction and Table Sep 19, 2024
@odeke-em odeke-em force-pushed the trace-instrument-BatchTransaction+Table branch from e74c73e to ea6d7f2 Compare September 19, 2024 13:11
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Sep 19, 2024
@odeke-em
Copy link
Contributor Author

Hey @surbhigarg92 I hadn't uploaded some of them as I created this PR early morning at around 3AM before bed and in interludes. I've added comprehensive tests, please take a look.

@odeke-em odeke-em force-pushed the trace-instrument-BatchTransaction+Table branch from ea6d7f2 to 38708a8 Compare September 19, 2024 13:15
test/batch-transaction.ts Outdated Show resolved Hide resolved
@@ -285,6 +286,7 @@ export class Snapshot extends EventEmitter {
queryOptions?: IQueryOptions;
resourceHeader_: {[k: string]: string};
requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
observabilityOptions?: ObservabilityOptions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observabilityOptions should be injected by customers from SpannerOptions which should set this property. Do you plan to do that in separate PR ?
I would recommend to add that in the same PR, so that we can test batch-transaction and mutation flow end to end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall have it plumbed in progressively as we get there. The reason being that this PR is bound to balloon if I add it straight from the top inside new Spanner({observabilityOptions: opts}). Just the way for each part I have been adding it in and testing.

test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
test/batch-transaction.ts Outdated Show resolved Hide resolved
1,
'Exactly 1 span should have been exported'
);
assert.strictEqual(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove this check from here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the testing environment, when ran isolated, the checks pass but when ran as a whole this test flakes here and there, a potential problem with OpenTelemetry. Besides, the point of the code was to ensure that the parent span actually has the required annotations which we do have and now it is very well cut out just for that.

@odeke-em odeke-em force-pushed the trace-instrument-BatchTransaction+Table branch 3 times, most recently from db71593 to 7357d35 Compare September 20, 2024 04:09
@odeke-em odeke-em force-pushed the trace-instrument-BatchTransaction+Table branch from 7357d35 to 23032f9 Compare September 20, 2024 04:16
observability-test/batch-transaction.ts Outdated Show resolved Hide resolved
@@ -1367,34 +1352,12 @@ describe('SessionPool', () => {
});

describe('trace annotations on active span', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe for separate PR. But It will be good to extract these tests in observability-test folder

This change is part of a series of changes to add
OpenTelemetry traces, focused on BatchTransaction and Table.

While here, made the tests for sessionPool spans much more
precise to avoid flakes.

Updates googleapis#2079
Built from PR googleapis#2087
Updates googleapis#2114
@odeke-em odeke-em force-pushed the trace-instrument-BatchTransaction+Table branch from 23032f9 to 6adf870 Compare September 20, 2024 05:35
@surbhigarg92 surbhigarg92 added kokoro:run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Sep 20, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 20, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 20, 2024
@surbhigarg92 surbhigarg92 added the automerge Merge the pull request once unit tests and other checks pass. label Sep 20, 2024
@gcf-merge-on-green gcf-merge-on-green bot merged commit d51aae9 into googleapis:main Sep 20, 2024
16 checks passed
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants