Skip to content

Commit

Permalink
Expand type definitions to include all libhoney options (#502)
Browse files Browse the repository at this point in the history
The specific one I wanted to use was apiHost, but I figured I'd
add them all while I was here.
  • Loading branch information
glenjamin committed Dec 3, 2021
1 parent 2334c7f commit 569886e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
11 changes: 9 additions & 2 deletions lib/api/libhoney.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,23 @@ module.exports = class LibhoneyEventAPI {

this.defaultDataset = opts.dataset || process.env["HONEYCOMB_DATASET"] || defaultName;

const libhoneyOpts = getFilteredOptions(opts);

let userAgentAddition = `honeycomb-beeline/${pkg.version}`;
if (libhoneyOpts.userAgentAddition) {
userAgentAddition += " " + libhoneyOpts.userAgentAddition;
}

this.honey = new libhoney(
Object.assign(
{
apiHost,
proxy,
dataset: this.defaultDataset,
writeKey: process.env["HONEYCOMB_WRITEKEY"],
userAgentAddition: `honeycomb-beeline/${pkg.version}`,
},
getFilteredOptions(opts)
libhoneyOpts,
{ userAgentAddition }
)
);
this.honey.add({
Expand Down
23 changes: 18 additions & 5 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,32 @@ declare namespace beeline {
}

export interface BeelineOpts {
// Options passed through to libhoney
apiHost?: string;
proxy?: string;
writeKey?: string;
dataset?: string;
serviceName?: string;
sampleRate?: number;
batchSizeTrigger?: number;
batchTimeTrigger?: number;
maxConcurrentBatches?: number;
pendingWorkCapacity?: number;
maxResponseQueueSize?: number;
timeout?: number;
disabled?: false;
userAgentAddition?: string;
transmission?: string;

// Beeline-specific options
serviceName?: string;
enabledInstrumentations?: string[];
impl?: "libhoney-event" | "mock";

samplerHook?(event: unknown): SamplerResponse;
presendHook?(event: unknown): void;
httpTraceParserHook?: HttpTraceParserHook;
httpTracePropagationHook?: HttpTracePropagationHook;

/** @deprecated use enabledInstrumentations: [] */
disableInstrumentation?: boolean;

Expand All @@ -35,10 +52,6 @@ declare namespace beeline {
mongodb?: {
includeDocuments?: boolean;
};

httpTraceParserHook?: HttpTraceParserHook;
httpTracePropagationHook?: HttpTracePropagationHook;
transmission?: string;
}

export interface Schema {
Expand Down

0 comments on commit 569886e

Please sign in to comment.