Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing invariate timestamps due to addMetric generating the default time in the method signature #398

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions python/core/sparkplug_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def initTemplateMetric(payload, name, alias, templateRef):
# Helper method for adding metrics to a container which can be a
# payload or a template
######################################################################
def addMetric(container, name, alias, type, value, timestamp=int(round(time.time() * 1000))):
def addMetric(container, name, alias, type, value, timestamp=None):
if timestamp is None:
timestamp = int(round(time.time() * 1000))
metric = container.metrics.add()
if name is not None:
metric.name = name
Expand Down Expand Up @@ -317,13 +319,15 @@ def addHistoricalMetric(container, name, alias, type, value):
# Helper method for adding metrics to a container which can be a
# payload or a template
######################################################################
def addNullMetric(container, name, alias, type):
def addNullMetric(container, name, alias, type, timestamp=None):
if timestamp is None:
timestamp = int(round(time.time() * 1000))
metric = container.metrics.add()
if name is not None:
metric.name = name
if alias is not None:
metric.alias = alias
metric.timestamp = int(round(time.time() * 1000))
metric.timestamp = timestamp
metric.is_null = True

# print( "Type: " + str(type))
Expand Down