Skip to content

How to represent 64bit integers as attribute value? #5680

@jmorrell-cloudflare

Description

@jmorrell-cloudflare

The OpenTelemetry spec says valid attribute types include signed 64bit integers:

A primitive type: string, boolean, double precision floating point (IEEE 754-1985) or signed 64 bit integer.

However in opentelemetry-js attribute values are represented as number which has a max safe value of 2^53 – 1.

There was a previous request for supporting BigInt as an attribute value here though it was marked as not planned. This makes some sense to me since it could represent much larger numbers, but still leaves a gap between 2^53-1 and 2^63-1 IIUC.

If we need to attach a 64 bit integer (say, received from an external system) to an attribute today that exceeds Number.MAX_SAFE_INTEGER, what is the recommended approach? Serialize it to a string? Or is there maybe some alternative I am missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions