Skip to content

Commit

Permalink
Add types for two internal functions (#4)
Browse files Browse the repository at this point in the history
Adds type declarations for `deterministicSampler` and `getTraceContext`
that we intend to import from our TypeScript wrapper libraries.
  • Loading branch information
richardlarocque authored Nov 2, 2021
1 parent bc7ad0e commit 3dacf6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/deterministic_sampler.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SamplerResponse } from "./types";

// Note that this is more specific than upstream `types.d.ts`. They define the
// samplerHook function's argument as `event: unknown`. We're more opinionated.
interface SamplerFn {
(data: {[key: string]: any}): SamplerResponse;
}

export default function(sampleRate: number) : SamplerFn;
8 changes: 8 additions & 0 deletions lib/instrumentation/trace-util.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IncomingMessage } from 'http';
import { TraceContext } from '../types';

// TODO: There are lots more functions exported by this file. We did not bother
// to declare types for all of them, but we should, if we decide that we need to
// `import` them into TypeScript projects.

export function getTraceContext(traceIdSource: any, req: IncomingMessage): TraceContext
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": "12.22.1"
},
"license": "Apache-2.0",
"version": "2.8.1-outreach2",
"version": "2.8.1-outreach3",
"repository": {
"type": "git",
"url": "https://github.com/getoutreach/beeline-nodejs.git"
Expand Down

0 comments on commit 3dacf6f

Please sign in to comment.