-
Notifications
You must be signed in to change notification settings - Fork 954
feat(sdk-logs,sdk-trace-base,sdk-metrics): add configuration for console.dir depth in ConsoleSpanExporter, ConsoleMetricExporter, and ConsoleLogRecordExporter #6056
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
base: main
Are you sure you want to change the base?
Conversation
|
It's worth noting a few things:
|
I agree, and I also don't think
On a second reading, I see that you are right. I misunderstood the conversation. Would something like this be a better change? import { inspect } from 'node:util';
console.log(inspect(obj, { depth: null, colors: true })); |
In Node, that general approach would likely be fine because that's how |
|
In general, the idea of that exporter is to provide enough info for diagnostics use, if it's not doing that then that's a problem - it should not need configuration to work properly. Since a significant chunk of users use this exporter for troubleshooting via To solve both the problems of depth for GenAI SemConv and the compatibliity with CloudFlare workers, I'd suggest the following approach:
We will loose the fancy formatting we get with |
|
@pichlermarc thank you for providing that context. What do you think about a solution that relies on console.dir with null depth where available, and that falls back to JSON.stringify and console.log? |
e159e4b to
0a034af
Compare
|
@pichlermarc, I have updated logging to use, in order of preference:
This should resolve everyone's issues. |
pichlermarc
left a comment
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.
Looks like we're trying to solve two distinct issues here with completely different requirements which makes this PR stall and take longer than needed:
- output is insufficient for AI semconv (no issue created yet, AFAIK)
- cloudflare workers does not implement the WhatWG console spec correctly (cloudflare/workerd#2247, #5800)
Consider solving one at a time to limit discussions:
- just extending the
console.dir()to usedepth: nullcan be one PR. - Solving the Cloudflare Workers issue can be another PR
| /* eslint-disable-next-line no-console */ | ||
| if (typeof console?.dir === 'function') { | ||
| /* eslint-disable-next-line no-console */ | ||
| console.dir(payload, { depth: null }); | ||
| return; | ||
| } |
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 think the issue in Cloudflare workers is that the function exists but it just does not do anything. So if we want to do feature-detection we have to do it another way - otherwise the issue won't be solved here.
ref #5800
ref cloudflare/workerd#2247
|
@pichlermarc thank you for reviewing. You're right that I'm trying to solve two different problems. Solving #5800 should also solve the issue with Semantic Conventions for Generative AI, so would you prefer that I remove |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6056 +/- ##
==========================================
- Coverage 95.16% 95.14% -0.02%
==========================================
Files 316 316
Lines 9198 9247 +49
Branches 2057 2086 +29
==========================================
+ Hits 8753 8798 +45
- Misses 445 449 +4
🚀 New features to boost your workflow:
|
yes, I think that works :) |
|
@pichlermarc, by default
What is the preferred approach? |
I prefer Option 3 - in OTLP an empty attribute value should be encoded as a KeyValue that includes the key as well as a zero-length value. An empty string/empty object could also work to convey that, but |
0a034af to
9a12bd9
Compare
ConsoleSpanExporter, ConsoleMetricExporter, and ConsoleLogRecordExporter use console.log instead of console.dir
9a12bd9 to
925d6dc
Compare
|
@pichlermarc thanks for all your help with this. I have updated the PR, and I believe that the commit should now resolve #5800. Please let me know if you have further feedback on the change. In particular, please review the comment in |
|
@pichlermarc just following up on this PR. Are there any other changes required? |
Which problem is this PR solving?
This PR makes console.dir depth configurable in ConsoleSpanExporter, ConsoleMetricExporter, and ConsoleLogRecordExporter to resolve problem using with Cloudflare (excessive depth), and Semantic Conventions for Generative AI (insufficient depth).
Fixes #5800
Short description of the changes
console.dir().Type of change
NB: ConsoleSpanExporter, ConsoleMetricExporter, and ConsoleLogRecordExporter are not well documented, only used in examples, so there was no existing documentation to update.
How Has This Been Tested?
Checklist: