Builder
Allows piecemeal creation of events.
Constructor Summary
Private Constructor | ||
private |
|
Member Summary
Public Members | ||
public |
The hostname for the Honeycomb API server to which to send events created through this builder. |
|
public |
The name of the Honeycomb dataset to which to send these events. |
|
public |
The rate at which to sample events. |
|
public |
The Honeycomb authentication token. |
Private Members | ||
private |
_dyn_fields: * |
|
private |
_fields: * |
|
private |
_libhoney: * |
Method Summary
Public Methods | ||
public |
adds a group of field->values to the events created from this builder. |
|
public |
addDynamicField(name: string, fn: function(): any): Builder adds a single field->dynamic value function, which is invoked to supply values when events are created from this builder. |
|
public |
adds a single field->value mapping to the events created from this builder. |
|
public |
creates and returns a clone of this builder, merged with fields and dyn_fields passed as arguments. |
|
public |
creates and returns a new Event containing all fields/dyn_fields from this builder, that can be further fleshed out and sent on its own. |
|
public |
creates and sends an event, including all builder fields/dyn_fields, as well as anything in the optional data parameter. |
Private Constructors
private constructor() source
Public Members
public apiHost: string source
The hostname for the Honeycomb API server to which to send events created through this builder. default: https://api.honeycomb.io/
public dataset: string source
The name of the Honeycomb dataset to which to send these events. If it is specified during libhoney initialization, it will be used as the default dataset for all events. If absent, dataset must be explicitly set on a builder or event.
public sampleRate: number source
The rate at which to sample events. Default is 1, meaning no sampling. If you want to send one event out of every 250 times send() is called, you would specify 250 here.
public writeKey: string source
The Honeycomb authentication token. If it is set on a libhoney instance it will be used as the default write key for all events. If absent, it must be explicitly set on a Builder or Event. Find your team write key at https://ui.honeycomb.io/account
Private Members
private _dyn_fields: * source
private _fields: * source
private _libhoney: * source
Public Methods
public add(data: Object | Map<string, any>): Builder source
adds a group of field->values to the events created from this builder.
Example:
var honey = new libhoney();
var builder = honey.newBuilder();
builder.add ({
component: "web",
depth: 200
});
let map = new Map();
map.set("component", "web");
map.set("depth", 200);
builder.add (map);
public addDynamicField(name: string, fn: function(): any): Builder source
adds a single field->dynamic value function, which is invoked to supply values when events are created from this builder.
Example:
builder.addDynamicField("process_heapUsed", () => process.memoryUsage().heapUsed);
public addField(name: string, val: any): Builder source
adds a single field->value mapping to the events created from this builder.
Params:
Name | Type | Attribute | Description |
name | string | ||
val | any |
Example:
builder.addField("component", "web");
public newBuilder(fields: Object | Map<string, any>, dyn_fields: Object | Map<string, any>): Builder source
creates and returns a clone of this builder, merged with fields and dyn_fields passed as arguments.
Example:
let anotherBuilder = builder.newBuilder();
let anotherBuilder = builder.newBuilder({ requestId },
{
process_heapUsed: () => process.memoryUsage().heapUsed
});
public newEvent(): Event source
creates and returns a new Event containing all fields/dyn_fields from this builder, that can be further fleshed out and sent on its own.
Example:
let ev = builder.newEvent();
ev.addField("additionalField", value);
ev.send();
public sendNow(data: Object | Map<string, any>) source
creates and sends an event, including all builder fields/dyn_fields, as well as anything in the optional data parameter.
Example:
builder.sendNow(); // sends just the data that has been added via add/addField/addDynamicField.
builder.sendNow({
additionalField: value
});