Skip to content

influxdb: Add session.data with connection status#459

Merged
BrianJKoopman merged 2 commits intomainfrom
koopman/influxdb-session-data
Apr 3, 2026
Merged

influxdb: Add session.data with connection status#459
BrianJKoopman merged 2 commits intomainfrom
koopman/influxdb-session-data

Conversation

@BrianJKoopman
Copy link
Copy Markdown
Member

@BrianJKoopman BrianJKoopman commented Mar 24, 2026

Description

This PR adds a session.data object for the InfluxDB Publisher agents. This contains just the InfluxDB connection state and a timestamp at the moment, but can easily be expanded.

The implementation differs a bit between the v1 and v2 agents, but connection status was added to the driver's Publisher class as an attribute, and the connection state is used to set the session as 'degraded' or not.

Motivation and Context

Resolves #326.

How Has This Been Tested?

I have tested this with a local test setup that includes InfluxDB, the Publisher agents, and other supporting ocs infrastructure like crossbar. I've checked the session output:

In [2]: client.record.status().session['data']
Out[2]: {'connected': True, 'last_updated': 1774389203.53926}

And the degraded state:

In [7]: client.record.status().session['degraded']
Out[7]: True

In [8]: client.record.status().session['degraded']
Out[8]: False

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@BrianJKoopman BrianJKoopman requested a review from mhasself March 24, 2026 22:11
@BrianJKoopman
Copy link
Copy Markdown
Member Author

BrianJKoopman commented Mar 25, 2026

Connection tracking is a bit trickier in v2 due to the batch writing happening in a separate background thread. Working on it, but I'd ignore a220e74 and beyond if you look at this before it's "ready for review".

@BrianJKoopman BrianJKoopman force-pushed the koopman/influxdb-session-data branch from a220e74 to 2d6a730 Compare March 26, 2026 20:25
@BrianJKoopman BrianJKoopman marked this pull request as ready for review March 26, 2026 20:31
@BrianJKoopman
Copy link
Copy Markdown
Member Author

This is ready for review now. The implementations differ between v1 and v2 because in the v2 client they use a background thread to do all the writes -- they even seem to cache things for a time and retry the writes if it can reconnect in time. I don't distinguish between a retry-able connection loss and a more serious one, just mark it as not connected as soon as we can't successfully write.

@BrianJKoopman
Copy link
Copy Markdown
Member Author

Going to go ahead with this merge, as I'm building the new tagging features on top of this branch, and I'm happy with its functionality.

@BrianJKoopman BrianJKoopman force-pushed the koopman/influxdb-session-data branch from 2d6a730 to 9b642b5 Compare April 3, 2026 13:50
@BrianJKoopman BrianJKoopman merged commit 5c897dd into main Apr 3, 2026
11 checks passed
@BrianJKoopman BrianJKoopman deleted the koopman/influxdb-session-data branch April 3, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

influxdb needs session.data

1 participant