Giter Club home page Giter Club logo

Comments (4)

maxgolov avatar maxgolov commented on August 30, 2024

I disagree with this proposal. It is convenient and generally suitable for a timepoint to be represented in a simple type, such as uint64_t inside the SDK. This is not something that is exposed on API surface to the customer.

from cpp_client_telemetry.

mkoscumb avatar mkoscumb commented on August 30, 2024

How is using a std::chrono type inconvenient?

Not only does it prevent mistakes from assumptions around the period of the data (does the uint64_t represent seconds? milliseconds? nanoseconds? 100ns (like ETW)?), it allows does the time related math for you (e.g. no manually multiplying by 1000 to go from seconds to milliseconds) as well as the useful helpers of:
time_point + duration = time_point;
duration + duration = duration; (check out std::chrono::duration_cast, it's super neato)
time_point - time_point = duration;

All this is done in a type-safe manner, and will produce errors at compile time (rather than run-time) if a conversion cannot be performed. We should not let developer convenience trump correctness, and prevent an easy class of bugs all-together by leveraging the type system.

Addendum: The Mars Climate Orbiter's crash is the best example of why we should take advantage of the type-system to prevent bugs.

from cpp_client_telemetry.

reyang avatar reyang commented on August 30, 2024

Thanks for bringing this up @mkoscumb, good topic!

For interface (e.g. exposed APIs, data types, schema), we should follow something like ISO 8601, we should not expose implementation detail (e.g. types that are specific to OS, runtime or language) via the interface unless we have a good control of the ABI.

For implementation (e.g. the internal data exchange within the SDK), having a consistent data format is great, as long as the data format we choose meets with the following criteria:

  • It is widely adopted and is considered the de facto standard.
  • It has a good performance, and works across the targeted platforms/runtimes.
  • It is language idiomatic.

from cpp_client_telemetry.

maxgolov avatar maxgolov commented on August 30, 2024

@mkoscumb - this one appears to be stale. Do you have some thoughts on further improvements or can we close it?

from cpp_client_telemetry.

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.