Perspective Script Execution Profiler & Analysis Suite

Hi everyone,

I wanted to share a new open-source resource I published to the Ignition Exchange to help track script runtimes and catch unhandled exceptions across Ignition projects without cluttering Gateway logs.

The Perspective Script Execution Profiler & Analysis Suite allows you to wrap Jython functions, Perspective transforms, or Gateway events with a simple @profiler decorator. It captures execution durations, errors, and stack traces into MS SQL Server, and includes a built-in Perspective UI to analyze runtime performance in real time.

Features

  • Universal @profiler Decorator: Import the script library, then add the decorator to your function. Drop it on Project Library scripts, Perspective transforms, or event handlers to measure latency.

  • Database Logging: Captures durations, status, and full stack traces directly to MS SQL Server.

  • Perspective Dashboard: Includes dynamic XY time-series charts and filterable data tables for quick troubleshooting.

  • Zero-Config Setup: Automatically initializes its database schema on Gateway startup.

  • Maintenance Utility: Built-in views to quickly clean up historical performance logs.

Links & Resources

Feel free to reply here or submit an issue directly on GitHub. I hope that you find this resource useful.

v1.1.0 with performance improvements and UI tweaks is submitted and currently pending review.

  • You are using import with project library scripts. This is unwise, and not entirely safe, especially in Ignition v8.1.
  • You are importing system in your project scripts. This is unnecessary.
  • Your try - except clauses will only catch jython errors, not any java errors. Since you are wrapping database operations that typically only throw java errors, it suggests that much of this is untested.

Or vibe-coded. :frowning:

1 Like
  1. You are using import with project library scripts. This is unwise, and not entirely safe, especially in Ignition v8.1.
  2. You are importing system in your project scripts. This is unnecessary.

I actually import system and my project scripts (usually via my vscode extension and only in the Project Library scripts) to get intellisense on IDEs. I remember reading something about issues on the forum but have yet to run into anything.

Importing system at the top level of a library script is unnecessary but harmless--a tiny bit of wasted time.

Importing across project library scripts is dangerous, particularly in v8.1 and older. Mainly because of this longstanding bug:

This extension is actively promoting importing profiler, where it should be directing users to reference the fully-qualified scriptProfiler.profiler everywhere.

2 Likes

At this point, I feel like we need "Phil's Big List of Do's and Dont's" where we can track all of these things in a single location. :sweat_smile:

1 Like
4 Likes

That's the link! Thanks!

Not to derail the topic but I have some composition functionality that probably has 60 selective imports and I use this across the entire project without issue (8.1.45 -> 8.3.10). This is anecdotal so I guess YMMV.

Example:

# `composition`

from someservice import SomeService
from system.date import now

def composeSomeService(dependency1=None, dependency2=None):
    ...
    return SomeService(dependency1, dependency2)

# someservice
class SomeService(object):
    SOME_CONST = "1234"

    def __init__(self, dependency1, dependency2):
        ...

    def doWork(self):
        ...
# Client call tag event script, perspective, etc.
someService = composition.composeSomeService()
someService.doWork()

If I understand correctly from the post referenced, you should be able to do selective imports or module imports as long as it is at the top level of the script and it is 8.3. Scripts that are not in Project Library should not use any imports except modules that are in site-packages/stdlib and java libraries.

I also know that calling import in the designer scope has caused many headaches for me so I try not to do that.

1 Like

v1.1.1 Robustness and Test Plan — Published / Awaiting Approval

  • Updated try/except blocks to catch Java throwables alongside python exceptions so database errors are properly logged.
  • Standardized decorator usage across the project to reference @scriptProfiler.profiler directly.
  • Removed redundant system import from the project library.
  • Added an executable test and validation script to the repo.

I appreciate the feedback!

1 Like