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: Open telemetry integration and span Id fix for nodejs logging library #1497

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

cindy-peng
Copy link
Contributor

@cindy-peng cindy-peng commented Apr 13, 2024

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1490 🦕

This change is to add OpenTelemetry support for nodejs-logging library and fix trace-span correlation issue.
More context about this change: https://b.corp.google.com/issues/270985947

Here are the overall and nodejs-logging design doc for this change:
go/logging-otel-span-support
go/logging-otel-span-support-nodejs

@cindy-peng cindy-peng added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 13, 2024
@cindy-peng cindy-peng requested review from a team as code owners April 13, 2024 01:23
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: logging Issues related to the googleapis/nodejs-logging API. labels Apr 13, 2024
@cindy-peng cindy-peng removed the request for review from gkevinzheng April 13, 2024 01:24
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Apr 16, 2024
@cindy-peng cindy-peng removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 16, 2024
@cindy-peng cindy-peng self-assigned this Apr 16, 2024
Copy link

@gkevinzheng gkevinzheng left a comment

Choose a reason for hiding this comment

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

Could you put the changes in protos/ in a separate PR? Not sure how related they are to the current changes.

package.json Outdated
@@ -45,6 +45,8 @@
"postpublish": "./.kokoro/publish-min.sh"
},
"dependencies": {
"@opentelemetry/api": "^1.7.0",

Choose a reason for hiding this comment

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

Could you change this to be a peerDependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @gkevinzheng,
It looks like our kokoro tests ran on NPM 6.14.18 which doesn't support auto-installment for peer-dependencies: https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/#

This is causing system test module not found test failure.

I have posted in JS-Team chat but it doesn't look like there is any solution so far. There is a plan to upgrade kokoro infra to Node18 but not sure when it will be done.

We will probably need to move this back to Dependencies instead of peerDependencies due to this limitation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the limitation of low NPM version in kokoro system test infra, JS language team suggested us to import OpenTelemetry/api and re-export it for now to avoid test failure and guarantee compatibility : https://chat.google.com/room/AAAAW_Lho4o/ljx6XogZJMI
Once NPM version in Kokoro infra has upgraded, I will change this to peer dependency again.

package.json Show resolved Hide resolved
src/utils/context.ts Outdated Show resolved Hide resolved
system-test/logging.ts Outdated Show resolved Hide resolved
test/entry.ts Outdated Show resolved Hide resolved
test/utils/context.ts Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, but see if you can reduce those dependencies

@cindy-peng
Copy link
Contributor Author

Could you put the changes in protos/ in a separate PR? Not sure how related they are to the current changes.

Yea I was trying to remove these as well, but it looks like owlbot committed this automatically to this PR after I removed them: c254669

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Apr 25, 2024
Copy link

@gkevinzheng gkevinzheng left a comment

Choose a reason for hiding this comment

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

LGTM

@cindy-peng cindy-peng added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 29, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 29, 2024
@cindy-peng
Copy link
Contributor Author

Could you put the changes in protos/ in a separate PR? Not sure how related they are to the current changes.

Yea I was trying to remove these as well, but it looks like owlbot committed this automatically to this PR after I removed them: c254669

Removed proto changes.

Copy link

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Didn't look at the tests too closely but LGTM from an OTel perspective

@@ -59,7 +59,8 @@
"on-finished": "^2.3.0",
"pumpify": "^2.0.1",
"stream-events": "^1.0.5",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"@opentelemetry/api": "^1.7.0"
Copy link

Choose a reason for hiding this comment

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

Would peerDependency work better 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.

Yea there was some back and forth discussions here: #1497 (comment)

Basically system test would fail for now if it is imported as peer dependency since our kokoro runs on NPM 6, which doesn't install peer dependency automatically. JS language team suggested us to import OpenTelemetry/api and re-export it for now to avoid test failure and guarantee compatibility : https://chat.google.com/room/AAAAW_Lho4o/ljx6XogZJMI
Once NPM version in Kokoro infra has upgraded, I can change this to peer dependency again.

src/utils/context.ts Outdated Show resolved Hide resolved
@product-auto-label product-auto-label bot added the stale: old Pull request is old and needs attention. label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging API. size: l Pull request size is large. stale: old Pull request is old and needs attention.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logging: OpenTelemetry spans are ignored as parents for LogRecords
5 participants