Home Reference Source
import Event from 'libhoney/src/event.js'
public class | source

Event

Represents an individual event to send to Honeycomb.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

The hostname for the Honeycomb API server to which to send this event.

public

data: *

public

The name of the Honeycomb dataset to which to send this event.

public
public

The rate at which to sample this event.

public

If set, specifies the timestamp associated with this event.

public

The Honeycomb authentication token for this event.

Private Members
private

Method Summary

Public Methods
public

add(data: Object | Map): Event

adds a group of field->values to this event.

public

addField(name: string, val: any): Event

adds a single field->value mapping to this event.

public

addMetadata(md: any): Event

attaches data to an event that is not transmitted to honeycomb, but instead is available when checking the send responses.

public

send()

Sends this event to honeycomb, sampling if necessary.

public

Dispatch an event to be sent to Honeycomb.

Public Constructors

public constructor() source

Public Members

public apiHost: string source

The hostname for the Honeycomb API server to which to send this event. default: https://api.honeycomb.io/

public data: * source

public dataset: string source

The name of the Honeycomb dataset to which to send this event.

public metadata: * source

public sampleRate: number source

The rate at which to sample this event.

public timestamp: Date source

If set, specifies the timestamp associated with this event. If unset, defaults to Date.now();

public writeKey: string source

The Honeycomb authentication token for this event. Find your team write key at https://ui.honeycomb.io/account

Private Members

private _libhoney: * source

Public Methods

public add(data: Object | Map): Event source

adds a group of field->values to this event.

Params:

NameTypeAttributeDescription
data Object | Map

field->value mapping.

Return:

Event

this event.

Example:

using an object
  builder.newEvent()
    .add ({
      responseTime_ms: 100,
      httpStatusCode: 200
    })
    .send();
using an ES2015 map
  let map = new Map();
  map.set("responseTime_ms", 100);
  map.set("httpStatusCode", 200);
  let event = honey.newEvent();
  event.add (map);
  event.send();

public addField(name: string, val: any): Event source

adds a single field->value mapping to this event.

Params:

NameTypeAttributeDescription
name string
val any

Return:

Event

this event.

Example:

  builder.newEvent()
    .addField("responseTime_ms", 100)
    .send();

public addMetadata(md: any): Event source

attaches data to an event that is not transmitted to honeycomb, but instead is available when checking the send responses.

Params:

NameTypeAttributeDescription
md any

Return:

Event

this event.

public send() source

Sends this event to honeycomb, sampling if necessary.

public sendPresampled() source

Dispatch an event to be sent to Honeycomb. Assumes sampling has already happened, and will send every event handed to it.