openconfig / gnmic

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

--calculate-latency does not work in event format #346

Open alibresco opened 10 months ago

alibresco commented 10 months ago

Running gnmic with the --calculate-latency flag does not seem to work work with --format event.

For example:

# this shows latency info
gnmic subscribe --address $ADDRESS --mode once --path "system/config/hostname" --calculate-latency --format json

# this does not show latency info
gnmic subscribe --address $ADDRESS --mode once --path "system/config/hostname" --calculate-latency --format event

Is this intentional? Could the latency info be added to the event format?

karimra commented 10 months ago

Yes it was added just for the default "json" format. I don't see where if would fit in the event format, could you explain how you intend to use it ?

alibresco commented 10 months ago

Sure, I was thinking like:

$ gnmic subscribe --address $ADDRESS --mode once --path "system/config/hostname" --calculate-latency --format event
!! {"name":"default-1704901049","paths":["system/config/hostname"],"mode":"once"}
[
  {
    "name": "default-1704901049",
    "timestamp": 1698699748523989703,
    "recv-timestamp": 1704901052684658561,
    "recv-time": "2024-01-10T10:37:32.684658561-05:00",
    "latency-nano": 6201304160668858,
    "latency-milli": 6201304160,
    "tags": {
      "source": "<ADDRESS>",
      "subscription-name": "default-1704901049"
    },
    "values": {
      "/system/config/hostname": "<ADDRESS>"
    }
  }
]

The use here for me is really in the recv-timestamp field. I want to pass these events along a pipeline, and it would be helpful to know when the message was received by gnmic without needing to override the timestamp (so the previous timestamp is still accessible).