Generating Data Manager COST messages

A Job run can issue a COST message that is picked up by the Data Manager and passed to the corresponding Product/Unit in the attached Account Server. Costs values are interpreted as a COIN value, typically represented by a Python Decimal, but it can be another numeric form like an integer or float.

Integer or Decimal values are encouraged as cost values to avoid any precision issues.

  • Costs are either incremental where each cost is added to a running total or they are considered to be a total (the default) where each cost line’s value represents the current total and replaces any previous cost line.
  • Costs are +ve, non-zero values
  • Cost messages are written by the Pod to stdout.


The im-data-manager-job-utilities PyPI package provides a convenient logging class and method to generate COST lines: -

# Import the DM logging utility
from dm_job_utilities.dm_log import DmLog
from decimal import Decimal
# Issue a total cost  of 5.7 coins
cost: Decimal = Decimal('5.7')

# Issue an incremental cost of 0.5 coins
cost: Decimal = Decimal('0.5')
DmLog.emit_cost(cost, incremental=True)


Cost lines are written to stdout. Any line that matches the following pattern will be interpreted by the Data Manager as a cost: -

<iso8601 date> # <level> -COST- <[+]cost> <sequence number>

  • The date needs to be recognised by the Python python-dateutil package
  • The cost needs to be a number (prefixed with + if it’s incremental)
  • The sequence number must be unique for the all costs generated by the Job