简体   繁体   English

通过段发送时将源添加到Librato数据

[英]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. 我试图弄清楚如何通过细分发送信息时在Librato中向指标添加来源。 I am using the python library and have tried creating a property for source (below) but it doesn't seem to be working properly. 我正在使用python库,并尝试为source创建一个属性(如下),但它似乎无法正常工作。

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. 我还尝试将'source'和'Librato.source'作为属性,在Segment的文档中进行了引用。 Any suggestions? 有什么建议么?

Similarly for ruby, using the segment gem you can specify a source like so: 对于红宝石,使用段gem可以类似地指定来源:

require 'analytics-ruby'

segment_token = 'asdfasdf' # The secret write key for my project

Analytics.init({
    secret: segment_token,
    #Optional error handler
    on_error: Proc.necd giw { |status, msg| print msg } })

Analytics.track(
    user_id: 123, 
    writeKey: segment_token, 
    event: 'segment.librato', 
    properties: { value: 42 }, context: { source:'my.source.name' })

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指标的来源,您需要将其作为上下文元数据的一部分进行发送。 Librato does not accept any properties other than 'value' so nothing else you send as a property will be recorded. Librato不接受“值”以外的任何属性,因此不会记录您作为属性发送的其他任何内容。 To set the source using the python library, the code needs to be as follows: 要使用python库设置源,代码需要如下:

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

If you are are using javascript, it would be: 如果您使用的是javascript,则可能是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM