jembi / openhim-core-js

The Open Health Information Mediator core component. OpenHIM Support: Post your query on OpenHIE Discourse using the #openhim tag https://discourse.ohie.org/
http://openhim.org
Mozilla Public License 2.0
69 stars 69 forks source link

Report metrics on behalf of mediators #187

Closed rcrichton closed 9 years ago

rcrichton commented 10 years ago

Mediators can report metrics via the mediator response object as described here: https://wiki.ohie.org/display/SUB/OpenHIM+pluggable+mediators+design

These metrics should be extracted and submitted to the metrics service when a response is received. This issue depends on #148 and #104

debonair commented 9 years ago

@rcrichton this is the new mediator response

{
  "x-mediator-urn": "urn:uuid:ff932010-b028-11e4-9ace-d549eeec0f4shgd",
  "status": "Successful",
  "response": {
    "status": 200,
    "headers": {
      "content-type": "application\/json"
    },
    "body": "Primary Route Reached",
    "timestamp": 1423489768398
  },
  "metrics": [
    {
      "type": "counter",
      "name": "mediator-counter-name",
      "value": 1 //value to increment by
    },
    {
      "type": "timer",
      "name": "mediator-timer-name",
      "value": 100 //in seconds
    },
    {
      "type": "gauge",
      "name": "mediatior-gauge-name",
      "value": 10
    }
  ],
  "orchestrations": [
    {
      "name": "Primary Route",
      "request": {
        "path": "\/hello",
        "headers": {
          "host": "localhost:4001",
          "connection": "keep-alive",
          "accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8",
          "user-agent": "Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/40.0.2214.111 Safari\/537.36",
          "accept-encoding": "gzip, deflate, sdch",
          "accept-language": "en-US,en;q=0.8",
          "cookie": "wp-settings-time-1=1421770848"
        },
        "querystring": "",
        "method": "GET",
        "timestamp": 1423489768398
      },
      "response": {
        "status": 200,
        "body": "Primary Route Reached",
        "timestamp": 1423489778398
      },
      "metrics": [
        {
          "type": "counter",
          "name": "orchestration-counter-name",
          "value": 10
        },
        {
          "type": "timer",
          "name": "orchestration-timer-name",
          "value": 10
        },
        {
          "type": "gauge",
          "name": "orchestration-gauge-name",
          "value": 10
        }
      ]
    }
  ],
  "properties": {
    "name": "Primary Route"
  }
}
debonair commented 9 years ago

whereby mediator can have an arrayt of custom metrics as well as an array of individual orchestration metrics @devcritter @armageddon what do you think?

hnnesv commented 9 years ago

Very cool!

Would core take care of the namespacing for orchestrations (i.e. you can just name it "name": "addEvent")? Or does the mediator need to specify names like: "name": "momconnect.dhis.addEvent"?

debonair commented 9 years ago

@devcritter in a word yes, if mediator.property.name = "momconnect" && orchestration.name = "dhis.addEvent'' 'then the name spacing will happen automatically like "momconnect.dhis.addEvent"

The values are concatenated together to build the namespacing

rcrichton commented 9 years ago

Nice @debonair, looks good to me! I think you can proceed with this as it is defined here.