openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
190 stars 57 forks source link

event-override-ts: Add changing precision of event timestamp #152

Open smalenfant opened 1 year ago

smalenfant commented 1 year ago

Override TS can change the precision of an event using "now". It would be great to add an option to change the precision of event original timestamp.

This is what I'm currently using in Starlark to change the timestamp from ns to ms.

  change-ts-precision:
    event-starlark:
      source: |
        def apply(*events):
          for e in events:
            # change timestmap to ms
            e.timestamp = int(e.timestamp / 1000 /1000)
          return events
karimra commented 1 year ago

My issue with implementing this is having to "guess" the unit of the original timestamp. Making it a configurable attribute (from: ns) feels a bit too rigid of an option to me.

smalenfant commented 1 year ago

Isn't the original timestamp already known and using a "ns"? Can the from: ns be ignored for that case?

karimra commented 1 year ago

Yes, for servers which behave according to the spec. I guess we can ignore misbehaving servers in this case.

smalenfant commented 1 year ago

I can see possibly issues when using gnmic -> nats -> gnmic.