Meaghan Fitzgerald Meaghan Fitzgerald - 7 months ago 8
Python Question

Adding a Source to Librato Data When Sending through Segment

I am trying to figure out how to add a source to a metric in Librato when sending the information via Segment. I am using the python library and have tried creating a property for source (below) but it doesn't seem to be working properly.

Here's what I've got:

userID = '12345'
analytics.track(userID, 'event', {
'value': 1,
'integrations.Librato.source': userID
})


I've also tried 'source' and 'Librato.source' as properties, which were referenced in Segment's documentation. Any suggestions?

Answer

You can't set the source of the Librato metric in the properties when sending from Segment, you need to send it as part of the context meta data. Librato does not accept any properties other than 'value' so nothing else you send as a property will be recorded. To set the source using the python library, the code needs to be as follows:

     userID = '12345'
     analytics.track(userID, 'event', {
          'value': 1
     }, {
          'Librato': {
               'source': userID
               }
     })

If you are are using javascript, it would be:

analytics.track({
  userId: '12345',
  event: 'event'
  properties: {
    value: 1
  },
  context: {
     'Librato': {
        'source': userID
     }
  }
});
Comments