Giter Site home page Giter Site logo

Comments (9)

vmarchaud avatar vmarchaud commented on July 29, 2024

BigInt support has landed on node in 10.4.0 (or 10.8.0 ?) but it's possible to use jsbi as a polyfill in both node and the browser if needed.

from opentelemetry-js.

mayurkale22 avatar mayurkale22 commented on July 29, 2024

I agree with @bg451's approach. Only thing is if they measure type is Long (or Long typed Measure/Measurement.) and provided value with decimals, SDK should either throw an exception or log the error otherwise exporters would crash or throw un handled exceptions.

*this is more like a question/discussion, so removed bug label.

from opentelemetry-js.

draffensperger avatar draffensperger commented on July 29, 2024

I'd like to avoid making BigInt / jsbi a requirement for users, since it would add weight to the JS bundles that get shipped to the browser.

That said, you can't do fully accurate Long type counting with the regular JS number (though for smaller counts they work pretty well). I would be inclined to focus the UI on number, and make BigInt use either not included initially or an optional add-on of some sort.

from opentelemetry-js.

draffensperger avatar draffensperger commented on July 29, 2024

There is also the long.js library, which is likely lighter weight than jsbi since it only needs 64-bit support. Again, something I'd recommend we look at down the road.

from opentelemetry-js.

bg451 avatar bg451 commented on July 29, 2024

Some more food for thought from https://github.com/open-telemetry/opentelemetry-js/pull/105/files#diff-1a629a23a3811f06e38fba44580c10bdR42

Measurements can have a long or double type. However, it looks like
  // the metric timeseries API (according to spec) accepts values instead of
  // Measurements, meaning that if you accept a `number`, the type gets lost.
  // Both java and csharp have gone down the route of having two gauge interfaces,
  // GaugeDoubleTimeseries and GaugeLongTimeseries, with param for that type. It'd
  // be cool to only have a single interface, but maybe having two is necessary?

I guess there's this question of how far we should deviate from the spec, and imo I think this would be a win for API simplicity.

from opentelemetry-js.

draffensperger avatar draffensperger commented on July 29, 2024

What if we have a single interface, and make the type for it accept something like number|bigint?

Then in our implementation, we make sure that the bigint dependency is pluggable in some way (maybe different packages, one with it, one without it?). In the code we can do a typeof value === 'number' check to determine the type of the input value for whether to use a number or bigint, and the number-only implementation could say write a warning log if typeof value !== 'number'

from opentelemetry-js.

rochdev avatar rochdev commented on July 29, 2024

How will metrics be sent to the server? This is important because some formats like JSON simply don't support Long. There are also certain libraries that expect a specific format from a specific library, like msgpack-lite requires int64-buffer and Protobuf has a similar requirement.

from opentelemetry-js.

draffensperger avatar draffensperger commented on July 29, 2024

The way the OpenCensus service's grpc-gateway works is that you can give a value field and a string for the number, something like {value: {int64Value: "string of the 64-bit number"}}. For OpenCensus Node it uses gRPC for the OpenCensus service exporter and for the Stackdriver exporter I think. For OpenCensus Web, I pretty much just used double values for all number on export, but would have done something similar with the wrapper object and string.

from opentelemetry-js.

seemk avatar seemk commented on July 29, 2024

The value type in the newer specs is either 64 bit double or a 64 bit signed integer (sfixed64, which can be passed to protobufjs as a string). So strictly speaking BigInt can't be supported properly, but it might make sense to support the 64 bit integer API, which in the background uses BigInt, e.g. createInt64Counter.

from opentelemetry-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.