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

fmt.Stringer support for user attributes (especially for SQL query parameters) #834

Open
siketyan opened this issue Dec 8, 2023 · 0 comments

Comments

@siketyan
Copy link

siketyan commented Dec 8, 2023

Summary

User attributes in segments does not support types other than primitive types.

switch v := val.(type) {
case string, bool,
uint8, uint16, uint32, uint64, int8, int16, int32, int64,
uint, int, uintptr:
case float32:
if err := validateFloat(float64(v), key); err != nil {
return nil, err
}
case float64:
if err := validateFloat(v, key); err != nil {
return nil, err
}
default:
return nil, errInvalidAttributeType{
key: key,
val: val,
}
}

I am using the pgx tracer from nrpgx5 package, the querying segment cannot be sent successfully because some of the query parameters are not primitive:

unable to end datastore segment collection=user operation=select product=Postgres reason="attribute '$1' value of type uuid.UUID is invalid"

uuid.UUID are not primitive, but it implements fmt.Stringer interface.
It would be great if we can handle fmt.Stringer for attributes.

Desired Behaviour

Attributes on a segment accept fmt.Stringer implemented types.

Possible Solution

Add a case to the switch statement:

case fmt.Stringer:
    val = val.String()

Additional context

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant