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

pg instrumentation: enhancedDatabaseReporting value is not parsable #1235

Closed
blumamir opened this issue Oct 19, 2022 · 6 comments · Fixed by #1453
Closed

pg instrumentation: enhancedDatabaseReporting value is not parsable #1235

blumamir opened this issue Oct 19, 2022 · 6 comments · Fixed by #1453
Assignees
Labels
bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect stale up-for-grabs Good for taking. Extra help will be provided by maintainers

Comments

@blumamir
Copy link
Member

What version of OpenTelemetry are you using?

"@opentelemetry/instrumentation-pg": "0.31.1"

What version of Node are you using?

16

What did you do?

Executed the following pg query with instrumentation config enhancedDatabaseReporting: true

    const res = await client.query('SELECT $1::text as message1, $2::text as message2', ['Hello,World', 'foo,bar']);

What did you expect to see?

I expected to be able to tell what the query values are for this operation.

What did you see instead?

I got this value in the db.postgresql.values attribute: "[Hello,World,foo,bar]"
This text is not reversible. all of these arrays will yield the same attribute value and there is no way to differentiate them in a deterministic way:

['Hello,World', 'foo,bar']
['Hello', 'World,foo,bar']
['Hello,World,foo', 'bar']

Additional context

The reason is that this data is serialized in a non-standard, non-reversible way:

function arrayStringifyHelper(arr: Array<unknown>): string {
  return '[' + arr.toString() + ']';
}

I suggest using JSON.stringify

@blumamir blumamir added the bug Something isn't working label Oct 19, 2022
@blumamir
Copy link
Member Author

This serialization also fails to distinguish between types:

['foo', 6]
['foo', '6']

are both serialized into the attribute with the same value: "[foo,6]"

@dyladan dyladan added priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect up-for-grabs Good for taking. Extra help will be provided by maintainers labels Oct 19, 2022
@github-actions
Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Dec 19, 2022
@haddasbronfman
Copy link
Member

Can you assign this to me?

@haddasbronfman
Copy link
Member

after this pr open-telemetry/opentelemetry-specification#3092 will be merged, the function arrayStringifyHelper is no more needed because bd.bind.values will be an array anyway. The fix will be to just use the arr as is, and delete the function arrayStringifyHelper from pg (and mysql) instrumentations.

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label May 1, 2023
@haddasbronfman
Copy link
Member

Currently in work in this PR: #1453

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:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect stale up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
3 participants