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
fix(host-metrics): semcov alignment & macOS fix #2071
base: main
Are you sure you want to change the base?
Conversation
|
@@ -14,12 +14,12 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
import * as SI from 'systeminformation'; | |||
import { networkStats } from 'systeminformation/lib/network'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about systeminformation
but deep-imports like this are usually not covered by stability guarantees. would this work for you?
import { networkStats } from 'systeminformation/lib/network'; | |
import { networkStats } from 'systeminformation'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pichlermarc Sadly not, it still imports the /lib/cpu
file for some reason. Resulting in having to add the unnecessary dependency osx-temperature-sensor
, which is not even used by networkStats()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resulting in having to add the unnecessary dependency
osx-temperature-sensor
,
Why "having to add"? It looks like lib/cpu.js lazily does require('osx-temperature-sensor')
only if cpuTemperature()
is called.
CI/CD should be fixed now :) (btw; npm install fails with Node 20 due to grpc) |
Hi @Netail Thank you for contributing to OTEL :) We can leverage this PR to help effort the group is doing to update the semantic conventions. Currently we're in a step we need to use the exported strings as you did in this PR and also document which version of the semantic conventions is using. Would you please add a section in the README file with this info. Here is an example of what I'm referring to. |
Hi @david-luna |
Just checked regarding opentelemetry-semantic-conventions package; it fetches the specifications from opentelemetry-specification, but the specifications folder got removed in v1.21.0, so the generator is broken... :( |
Semantic conventions already has these enums but the package is not updated yet so no need to contribute to https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-semantic-conventions. Actually this package is generated from the models in https://github.com/open-telemetry/semantic-conventions We need to inform which version of semantic conventions model (not package) host metrics is using and list them. In this case the package uses v1.24.0 of the model
You could add a section with this message
|
Shall I pull up a PR which generates the semantic concentions from the new repo? |
Updated the generator here: open-telemetry/opentelemetry-js#4606 |
this is indeed one of the tasks to be done for updating semantic conventions but since it a big leap in versions we expect breaking changes. This was discussed in the JavaScript SIG and planned. The plan is summarised and tracked in open-telemetry/opentelemetry-js#4572 the PR looks good but 1st we need to prepare the packages in contrib to be ready for the change. You can help us with these preparation tasks :) Also you can join the SIG to discuss this topic and others. Here is the doc with the MoMs and also with the info to join https://docs.google.com/document/d/1tCyoQK49WVcE-x8oryZOTTToFm7sIeUhxFPm9g-qL1k/edit |
What kind of preparation do all the packages need? Updated open-telemetry/opentelemetry-js#4606 to include v1.25.0 Semantic Conventions. As all packages within the same repo have a different version specified, we can merge that PR, and create different PRs for the packages who use the semantic-conventions package Added the semantic conventions table to the README |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess with the change suggested by @pichlermarc in ./src/stats/si.ts
- import { networkStats } from 'systeminformation/lib/network';
+ import { networkStats } from 'systeminformation';
this file is no needed. I see the .d.ts
file from systeminformation
exporting networkStats
function already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I use import { networkStats } from 'systeminformation';
, it still tries to import the underlying cpu.js file, thus throwing an error on macOS. :( By targeting the file directly it won't.
The systeminformation/lib/cpu.js file tries to import osx-temperature-sensor
for macOS, which you additionally have to install for macOS temperatures as it's not included in the dependencies, however osx-temp-sensor package breaks something else. But the cpu.js file isn't even used for host-metrics, so installing this package besides systeminformation is unecessary
@Netail please check open-telemetry/opentelemetry-js#4572 for more info on the update plan, thanks :) |
0b09d19
to
f28832f
Compare
f28832f
to
8f65520
Compare
@trentm in theory yes, but when I try to use the package it somehow triggers the require ;/ |
Can you run it again with |
Doesn't show anything relevant regarding
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Please run 'npm run lint:fix' to update style / reflow-indentation after your changes. That is why the "Lint" check is failing.
-
I also got a failure in
npm run compile
. This fixed it for me:
--- a/packages/opentelemetry-host-metrics/src/stats/common.ts
+++ b/packages/opentelemetry-host-metrics/src/stats/common.ts
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-import { type CpuInfo, cpus, totalmem, freemem } from 'os';
+import type { CpuInfo } from 'os';
+import { cpus, totalmem, freemem } from 'os';
- I don't know what you are experiencing with the
osx-temperature-sensor
thing. Things work fine for me (I am on macOS) after this change:
--- a/packages/opentelemetry-host-metrics/src/stats/si.ts
+++ b/packages/opentelemetry-host-metrics/src/stats/si.ts
@@ -14,10 +14,7 @@
* limitations under the License.
*/
-// Import from network file directly as importing from the root imports the /lib/cpu file,
-// resulting in also having to add osx-temperature-sensor as a dependency for macOS,
-// while /lib/cpu isn't even used by this package (deep-importing not working as expected)
-import { networkStats } from 'systeminformation/lib/network';
+import { networkStats } from 'systeminformation';
In fact, the tests fail if I don't make that change, because the tests are currently mocking systeminformation.networkStats
(see
opentelemetry-js-contrib/packages/opentelemetry-host-metrics/test/metric.test.ts
Line 140 in b903bce
sandbox.stub(SI, 'networkStats').callsFake(mockedSI.networkStats); |
import { networkStats } from 'systeminformation/lib/network';
is used.
Can you try with the above changes and see if npm run compile
and npm test
(in the packages/opentelemetry-host-metrics dir) work for you now?
If not, can you please provide more details on what exactly what commands you are running that lead to the attempt and failure to require('osx-temperature-sensor')
.
Thanks for the feedback @trentm , 3 still doesn't work for me, so I created a demo project; https://github.com/Netail/host-metrics-macos
|
@trentm were you able to reproduce the issue? |
Ah, Next.js. When I ran first time
Which included this in the output:
There is also this error output:
The After an edit to "node_modules/@opentelemetry/host-metrics/build/src/stats/si.js" to use: const SI = require("systeminformation/lib/network"); I get: after edit
This again exits with status 0, and has the Does that So my (limited) understanding and guess is that this is related to Next.js doing bundling? Could the Next.js app be configured to stub out or mock that package? (I understand it would be poor of OTel JS to require Next.js users of |
|
Actually there are a bunch of (closed) issues on systeminformation: https://github.com/sebhildebrandt/systeminformation/issues?q=osx-temperature-sensor that all (at least the 5 or so that I read) point to this issue of getting
when using this module with webpack. That error message is from webpack code here: (Side note: There is a comment about removing that in webpack 6, for what it is worth. I'm not sure exactly what is implied by that.) (Side note: The amount of confusion that webpack could reduce or could have reduced by just putting "webpack" in their error messages is large.) |
My mistake, oopsie. Changed the function name in instrumentation.ts before pushing, should be fixed now. But at least you were able to reproduce my issue with osx-temp. :) I think targetting the network file directly in host-metrics for now should be the better solution instead of users having to modify stuff in their webpack @trentm what do you think? |
As far as I know, Also recommended according to the docs; https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration |
I noticed the Which uses Ubuntu 22.04.4 LTS |
Getting same error: ✓ Starting...
○ Compiling /instrumentation ...
⚠ ./node_modules/.pnpm/systeminformation@5.22.8/node_modules/systeminformation/lib/cpu.js
Module not found: Can't resolve 'osx-temperature-sensor' in '/Users/seitasanov/ownProjects/profile/node_modules/.pnpm/systeminformation@5.22.8/node_modules/systeminformation/lib'
Import trace for requested module:
./node_modules/.pnpm/systeminformation@5.22.8/node_modules/systeminformation/lib/cpu.js
./node_modules/.pnpm/systeminformation@5.22.8/node_modules/systeminformation/lib/index.js
./node_modules/.pnpm/@opentelemetry+host-metrics@0.35.1_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/host-metrics/build/src/stats/si.js
./node_modules/.pnpm/@opentelemetry+host-metrics@0.35.1_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/host-metrics/build/src/metric.js
./node_modules/.pnpm/@opentelemetry+host-metrics@0.35.1_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/host-metrics/build/src/index.js |
@Netail You can also get rid of this message by modifying nextjs webpack config: webpack: (config, { webpack }) => {
config.plugins.push(
new webpack.IgnorePlugin({ resourceRegExp: /osx-temperature-sensor/ }),
);
return config;
}, |
I know, but does bloat your next config. Would prefer a solution to mitigate this closer at the source and removes the error for everyone at once |
Which problem is this PR solving?
Short description of the changes