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

ConsoleMetricExporter only outputs shallowly #4061

Closed
anuraaga opened this issue Aug 15, 2023 · 2 comments · Fixed by #4522
Closed

ConsoleMetricExporter only outputs shallowly #4061

anuraaga opened this issue Aug 15, 2023 · 2 comments · Fixed by #4522
Labels
bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization up-for-grabs Good for taking. Extra help will be provided by maintainers

Comments

@anuraaga
Copy link
Contributor

anuraaga commented Aug 15, 2023

What happened?

Steps to Reproduce

Enable ConsoleMetricExporter

Expected Result

See a full dump of metrics

Actual Result

Only see a shallow dump. For example, attributes are not visible

{
  descriptor: {
    name: 'http.client.duration',
    description: 'Measures the duration of outbound HTTP requests.',
    type: 'HISTOGRAM',
    unit: 'ms',
    valueType: 1
  },
  dataPointType: 1,
  dataPoints: [
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    },
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    },
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    },
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    },
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    },
    {
      attributes: [Object],
      startTime: [Array],
      endTime: [Array],
      value: [Object]
    }
  ]
}

Additional Details

console.dir is used to output, but it seems {depth: null} needs to be passed to it to get full output

https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/sdk-metrics/src/export/ConsoleMetricExporter.ts#L74

OpenTelemetry Setup Code

No response

package.json

No response

Relevant log output

No response

@anuraaga anuraaga added bug Something isn't working triage labels Aug 15, 2023
@anuraaga
Copy link
Contributor Author

anuraaga commented Aug 15, 2023

I can open another issue but since it's so related, another point is that the scope / resource aren't logged at all. This can make it harder to debug using console exporter. I wonder if both issues can be fixed by just changing to console.dir(resourceMetrics, {depth: null})?

For context, what I'm doing right now is introducing nestjs-otel to have server duration metrics with route information, while the default server duration metrics from HTTP library are generic. So being able to see what metrics are from what instrumentation would help debugging when doing things like that, it would tell me exactly what to put in the view to drop one set of metrics.

@pichlermarc pichlermarc added priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization and removed triage labels Aug 16, 2023
@pichlermarc
Copy link
Member

open-telemetry/opentelemetry-specification#3565 and by extension #3990 propose introducing a unified format or spec guidance on which items to include. For now, I think we should increase the depth because the console exporter is not very useful if the exported values can't even be seen.

@pichlermarc pichlermarc added the up-for-grabs Good for taking. Extra help will be provided by maintainers label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants