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

Possible incorrect type in HostMetrics #2274

Closed
rowanmanning opened this issue Jun 13, 2024 · 0 comments · Fixed by #2300
Closed

Possible incorrect type in HostMetrics #2274

rowanmanning opened this issue Jun 13, 2024 · 0 comments · Fixed by #2300
Assignees
Labels
bug Something isn't working pkg:host-metrics priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization

Comments

@rowanmanning
Copy link

What version of OpenTelemetry are you using?

@opentelemetry/host-metrics@0.35.2

What version of Node are you using?

20.10.0

What did you do?

In an app with TypeScript type checking, I'm doing the following:

const { HostMetrics } = require('@opentelemetry/host-metrics');
const hostMetrics = new HostMetrics({});

What did you expect to see?

I expected to see no type errors as the name option of HostMetrics is defaulted in the base class here.

What did you see instead?

I get a type error:

Argument of type '{}' is not assignable to parameter of type 'MetricsCollectorConfig'.
  Property 'name' is missing in type '{}' but required in type 'MetricsCollectorConfig'.

This is because the MetricsCollectorConfig type does not specify that name is optional (see here).

Additional context

I'd be happy with any of the following:

  • Adjust the types to indicate that name is optional. If so, then should the entire config object be optional too?
  • Adjust the code so that name isn't defaulted, possibly throwing an error if name is not configured
  • Do nothing and close this issue so at least somebody knows the current behaviour is intentional if that's the case
@rowanmanning rowanmanning added the bug Something isn't working label Jun 13, 2024
@pichlermarc pichlermarc added pkg:host-metrics priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization labels Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:host-metrics priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization
Projects
None yet
3 participants