randomint(0, 9223372036854775807) does not work
Hi,
I want to create a random 64bit unsigned integer in fastly,
and pass it to origin servers so that we can use it as a datadog apm trace id.
I tried
```
declare local var.id INTEGER;
set var.id = randomint(0, 9223372036854775807);
set req.http.x-datadog-trace-id = var.id;
set req.http.x-datadog-parent-id = var.id;
```
but I got `x-datadog-trace-id: 0` in the origin server.
For a time being, I'm creating random integers by every 32bits.
```
declare local var.id INTEGER;
set var.id = randomint(0, 2147483647);
set var.id <<= 32;
set var.id |= randomint(0, 4294967295);
```
I hope that `randomint(0, 9223372036854775807)` works.
Also, if there were more reasonable ways to create datadog apm trace ids in fastly, I would like to know them.
Thanks.
-
Hi,
Despite our type INTEGER being a 64-bit variable, the function randomint() currently only populates 32-bit of value. This is being worked on.
However, if you need to generate a unique identifier, have you tried the randomstr() function or uuid.is_version4()?
Best regards.
-
Hi, Pablo
> This is being worked on.
I'm happy to hear that!
> if you need to generate a unique identifier, have you tried the randomstr() function or uuid.is_version4()?
It seems that datadog apm clients actually hold trace ids as 64bit unsigned integers, not just as strings.
So we cannot use uuid strings as datadog trace ids here.
Please sign in to leave a comment.
Comments
3 comments