SimpleMetric - Same name for two metrics applied to different Types

Hi,
I need to use the same SimpleMetric name for two Types and I have the following scenario.

Type Config - fields:

  • flameOnReferenceValue
  • start

Type A:

  • It provides a collection field called assetConfig of Type Config
  • It provides the following metric:
{
    "id": "ReferenceValue_A",
    "name": "ReferenceValue",
    "srcType": "A",
    "tsDecl": {
        "data": "assetConfig",
        "start": "start",
        "treatment": "PREVIOUS",
        "value": "flameOnReferenceValue"
    }
}

Type B:

  • extends Type A

Type C

  • extends Type A
  • It has a reference field to B (called “b”)
  • It provides the following metric:
{
  "id": "ReferenceValue_C",
  "name": "ReferenceValue",
  "srcType": "C",
  "path":"b",
  "tsDecl": {
    "data": "assetConfig",
    "start": "start",
    "treatment": "PREVIOUS",
    "value": "flameOnReferenceValue"
  }
}

Now, when I run the following evalMetric on Type C with id X which has a reference to Type B with id Y I get all empty values (missing).

emr = C.evalMetrics({
	"interval":"FIVE_MINUTE",
	"start":"2019-06-03T14:26:59.254Z",
	"end":"2019-06-04T15:26:59.262Z",
	"include":"start, end, dates, data",
	"ids":["X"],
	"expressions":["ReferenceValue"]
});

On the contrary, if I directly execute the evalMetrics on Type B with id Y, I succeed in getting the values.

emr = B.evalMetrics({
	"interval":"FIVE_MINUTE",
	"start":"2019-06-03T14:26:59.254Z",
	"end":"2019-06-04T15:26:59.262Z",
	"include":"start, end, dates, data",
	"ids":["Y"],
	"expressions":["ReferenceValue"]
});

If you fetch the C object and include the reference field b, do you get back the expected values?

C.get({ id: 'X' }, 'b.assetConfig');

Or does it say it’s an invalid reference?

Yes, moreover, I tried the following command:

sib = C.get({id:'X'}, "this, {b:[{assetConfig:[this]}]}")

sib.b.assetConfig[0].flameOnReferenceValue --> 100

One more detail. If I write the SimpleMetric on Type C with a completely different name, it works. Like below:

{
  "id": "Test_C",
  "name": "Test",
  "srcType": "C",
  "path":"b",
  "tsDecl": {
    "data": "assetConfig",
    "start": "start",
    "treatment": "PREVIOUS",
    "value": "flameOnReferenceValue"
  }
}

Now the point is that I need to use exactly the same name for the metric and I would want the enviroment to understand which metric to use depending on the Type which I call the evalMetric on.

I would expect this to work and its possible that its a bug. Could you raise a ticket with the services person and we’ll ensure that this is tested and works

1 Like