Giter VIP home page Giter VIP logo

Comments (7)

tigrannajaryan avatar tigrannajaryan commented on June 26, 2024 1

How are timestamps supposed to be serialized when exporting OpenTelemetry metrics in JSON format? Is it nanoseconds since epoch or RFC 3339?

It is not RFC 3339. See the time_unix_nano field definition here:

  // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January
  // 1970.

There seems to be conflicting guidelines in the spec:

  1. OpenTelemetry file exporter provides examples where timestamps are serialized as the number of nanoseconds since epoch, e.g. "endTimeUnixNano":"1581452773000000789" - The file is https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md

The example is correct.

  1. In the JSON protobuf encoding, there is a link to https://protobuf.dev/programming-guides/proto3/#json, which states timestamps should be encoded as RFC 3339, e.g., "1972-01-01T10:00:20.021Z"

This guidance is not applicable to OTLP. The timestamp fields in OTLP are fixed64. The guidance you are referring to is about Timestamp data type that is distinct from fixed64.

The applicable language in OTLP spec is the following:

Note that according to [Protobuf specs](
https://developers.google.com/protocol-buffers/docs/proto3#json) 64-bit integer
numbers in JSON-encoded payloads are encoded as decimal strings, and either
numbers or strings are accepted when decoding.

We can add clarification to the spec to make it clearer, I created an issue for that: #460

from opentelemetry-proto.

joaopgrassi avatar joaopgrassi commented on June 26, 2024 1

I have a bunch of metrics and logs examples in JSON, that I use to try things out, as it's easier to create arbitrary JSON OTLP. If you want I can try working on this :)

from opentelemetry-proto.

tigrannajaryan avatar tigrannajaryan commented on June 26, 2024 1

I have a bunch of metrics and logs examples in JSON, that I use to try things out, as it's easier to create arbitrary JSON OTLP. If you want I can try working on this :)

It would be great to have some examples. Please feel free to submit a PR.

from opentelemetry-proto.

abitrolly avatar abitrolly commented on June 26, 2024

Zipkin also shows how it would be rendered in GUI https://zipkin.io/pages/data_model.html

from opentelemetry-proto.

sebastien-rosset avatar sebastien-rosset commented on June 26, 2024

How are timestamps supposed to be serialized when exporting OpenTelemetry metrics in JSON format? Is it nanoseconds since epoch or RFC 3339? There seems to be conflicting guidelines in the spec:

  1. OpenTelemetry file exporter provides examples where timestamps are serialized as the number of nanoseconds since epoch, e.g. "endTimeUnixNano":"1581452773000000789" - The file is https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md
  2. In the JSON protobuf encoding, there is a link to https://protobuf.dev/programming-guides/proto3/#json, which states timestamps should be encoded as RFC 3339, e.g., "1972-01-01T10:00:20.021Z"

Presumably the JSON protobuf encoding section is normative (hence RFC 3339), whereas the examples in the "file exporter" section are just examples that may not have been updated? Or maybe the intent was that somehow the timestamps for the file exporter in JSON format are supposed to use the number of nanoseconds since the epoch?

from opentelemetry-proto.

tigrannajaryan avatar tigrannajaryan commented on June 26, 2024

I moved this issue to https://github.com/open-telemetry/opentelemetry-proto since that's where the OTLP spec is now.

from opentelemetry-proto.

joaopgrassi avatar joaopgrassi commented on June 26, 2024

I put up a PR for it #463.

from opentelemetry-proto.

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.