# Add Devices Statistics to AbstractTagDriver

**URL:** <https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274>\
**Category:** Module Development\
**Tags:** ignition81\
**Created:** [June 28, 2021, 1:00pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274 "2021-06-28T13:00:23Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [June 28, 2021, 1:00pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/1 "2021-06-28T13:00:23Z")

</div>

Hi @Kevin.Herron,

I would like to add **Devices Statistics** like for devices in **Ignition 8.1.7** (Button Details)  
My devices extends **AbstractTagDriver**.  
Is it possible ? what is the process to add it ?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/73ede9abfae7e1e5efb6026402a00ade6537c6a7.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 28, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/2 "2021-06-28T13:14:19Z")

</div>

The device statistics implementation is not part of the SDK. If it ever does become part of the SDK it would only be for implementations against the 8.0 Device API, but I’m not sure it will happen.

You will have to roll your own implementation if you want them for now.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 28, 2021, 1:18pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/3 "2021-06-28T13:18:21Z")

</div>

You can at least get the gateway status diagnostics page by implementing `Driver::getSamplingMetrics`, but there’s no way to get the OPC tags and you do still have to actually implement all the diagnostic gathering yourself.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 28, 2021, 1:23pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/4 "2021-06-28T13:23:42Z")

</div>

I implemented (part of) it for my Modbus driver’s client connection mode. The key was supplying the histograms with **nanoseconds** from System.nanoTime().

It was a pain to add request tracking into the functional paths to obtain the timing information. ):

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 28, 2021, 1:25pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/5 "2021-06-28T13:25:56Z")

</div>

> [@pturmel](#):
>
> It was a pain to add request tracking into the functional paths to obtain the timing information. ):

Yes, and there's no way around that. All of our polling driver implementations take care to track their requests, though we do have some shared code and implementations that make it easier.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 28, 2021, 1:28pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/6 "2021-06-28T13:28:09Z")

</div>

> [@Kevin.Herron](#):
>
> Yes, and there’s no way around that.

Yeah, when I decided to implement, I burned a day looking for shortcuts. No shortcut.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [June 28, 2021, 1:32pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/7 "2021-06-28T13:32:37Z")

</div>

ok I see.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 5, 2021, 3:28pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/8 "2021-07-05T15:28:57Z")

</div>

@Kevin.Herron, @pturmel

How can we configure thread or thread pool in order the thread are counted in the **Devices** item of the **Thread Performance by System** histogram ?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37feaf52efd71baf8321ee0b0d3e2c96a9965e23.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 5, 2021, 4:22pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/9 "2021-07-05T16:22:50Z")

</div>

Check out the docs for `com.inductiveautomation.ignition.common.execution.TPC`.

The easiest way when you are already creating a dedicated thread pool is to use `TPC.newThreadFactory` to create a ThreadFactory that you use with the pool.

Otherwise you just have to manually set/unset the context when doing work on a thread you know belongs to some system.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 5, 2021, 4:46pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/10 "2021-07-05T16:46:07Z")

</div>

> [@Kevin.Herron](#):
>
> use `TPC.newThreadFactory`

Learned something new today. Thanks, Kevin.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 5, 2021, 9:16pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/11 "2021-07-05T21:16:52Z")

</div>

How are calculated diagnostics tags **ActualThroughput** and **IdealThroughput**?  
(I’ve found other diagnostics data with Histogram and Meter but nothing related to those 2 tags ?)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 6, 2021, 12:46am UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/12 "2021-07-06T00:46:05Z")

</div>

There’s a table on this page that describes the newer device diagnostic tags: [OPC UA Drivers - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/OPC+UA+Drivers#OPCUADrivers-SamplingTags)

ActualThroughput is just the one minute rate from a Timer’s Meter.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 10, 2021, 11:14am UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/13 "2021-07-10T11:14:10Z")

</div>

All the devices metrics are exposed by tags. It’s perfect !

It could be usefull to add a **script function system.device.xxx to be able to retrieve the histogram data** of a device, or directly the **Histogram object**.

The pupose is to be able to “reproduce” the device detail gateway web page in the vision or perpsective client !

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [November 22, 2021, 9:15am UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/14 "2021-11-22T09:15:07Z")

</div>

**Ignition 8.1.11**

Hi Kevin,

I have a module based on the **AbstractTagDriver**.  
I have a strange behavior about the metrics tag: **[Diagnostics]/Sampling/MonitoredItemCount**

If I don’t create it, the MonitoredItemCount value is well displayed in the **gateway device diagnostics page** , but I don’t have an opc tag for it.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/809ef4d8aa6ebea86daf291abcfc3806559d3492.png)

If I create, it’s the same. I don’t have this tag created in Ignition OPC UA Server.

**So, I don’t know if I have to create this tag on my side or not ?**

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [November 22, 2021, 1:53pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/15 "2021-11-22T13:53:41Z")

</div>

oops, sorry I missed to fully create the **[Diagnostics]/Sampling/MonitoredItemCount** opc tag

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 22, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/add-devices-statistics-to-abstracttagdriver/48274/16 "2021-11-22T14:02:45Z")

</div>

AbstractTagDriver did not get updated with new diagnostics implementation. Looking at it, I’m not sure how you have any diagnostics tags or the diagnostic page at all, unless you’ve implemented them yourself.
