diff --git a/src/check_in/event.ts b/src/check_in/event.ts index 2be3a08a..d56aa9f4 100644 --- a/src/check_in/event.ts +++ b/src/check_in/event.ts @@ -1,8 +1,11 @@ import type { Cron } from "./cron" +/** @internal */ export type EventKind = "start" | "finish" +/** @internal */ export type EventCheckInType = "cron" | "heartbeat" +/** @internal */ export class Event { identifier: string digest?: string diff --git a/src/check_in/heartbeat.ts b/src/check_in/heartbeat.ts index 1cb1297c..11347206 100644 --- a/src/check_in/heartbeat.ts +++ b/src/check_in/heartbeat.ts @@ -2,16 +2,19 @@ import { stubbable } from "../utils" const HEARTBEAT_INTERVAL_MILLISECONDS = 30_000 +/** @internal */ export const heartbeatInterval = stubbable( () => HEARTBEAT_INTERVAL_MILLISECONDS ) let continuousHeartbeats: NodeJS.Timeout[] = [] +/** @internal */ export function addContinuousHeartbeat(interval: NodeJS.Timeout) { continuousHeartbeats.push(interval) } +/** @internal */ export function killContinuousHeartbeats() { continuousHeartbeats.forEach(clearInterval) continuousHeartbeats = [] diff --git a/src/check_in/scheduler.ts b/src/check_in/scheduler.ts index 9ed817ba..ebe68bd3 100644 --- a/src/check_in/scheduler.ts +++ b/src/check_in/scheduler.ts @@ -6,6 +6,7 @@ import { ndjsonStringify, stubbable } from "../utils" const INITIAL_DEBOUNCE_MILLISECONDS = 100 const BETWEEN_TRANSMISSIONS_DEBOUNCE_MILLISECONDS = 10_000 +/** @internal */ export const debounceTime = stubbable( (lastTransmission: number | undefined): number => { if (lastTransmission === undefined) { @@ -33,6 +34,7 @@ class PendingPromiseSet extends Set> { } } +/** @internal */ export class Scheduler { pendingTransmissions: PendingPromiseSet = new PendingPromiseSet() events: Event[] = [] @@ -146,8 +148,10 @@ export class Scheduler { } } +/** @internal */ export let scheduler = new Scheduler() +/** @internal */ export async function resetScheduler() { await scheduler.shutdown() scheduler = new Scheduler() diff --git a/src/config/configmap.ts b/src/config/configmap.ts index 9a731e10..e34dd108 100644 --- a/src/config/configmap.ts +++ b/src/config/configmap.ts @@ -1,5 +1,6 @@ import type { AppsignalOptions } from "./options" +/** @internal */ export const ENV_TO_KEY_MAPPING = { APPSIGNAL_ACTIVE: "active", APPSIGNAL_APP_ENV: "environment", @@ -42,6 +43,7 @@ export const ENV_TO_KEY_MAPPING = { APP_REVISION: "revision" } satisfies Record +/** @internal */ export const PRIVATE_ENV_MAPPING: Record = { _APPSIGNAL_ACTIVE: "active", _APPSIGNAL_APP_ENV: "environment", @@ -79,6 +81,7 @@ export const PRIVATE_ENV_MAPPING: Record = { _APP_REVISION: "revision" } +/** @internal */ export const JS_TO_RUBY_MAPPING: Record = { active: "active", bindAddress: "bind_address", @@ -121,6 +124,7 @@ export const JS_TO_RUBY_MAPPING: Record = { workingDirectoryPath: "working_directory_path" } +/** @internal */ export const BOOL_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_ACTIVE", "APPSIGNAL_ENABLE_HOST_METRICS", @@ -135,6 +139,7 @@ export const BOOL_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_SEND_SESSION_DATA" ] +/** @internal */ export const STRING_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_APP_ENV", "APPSIGNAL_APP_NAME", @@ -156,6 +161,7 @@ export const STRING_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APP_REVISION" ] +/** @internal */ export const LIST_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_DNS_SERVERS", "APPSIGNAL_FILTER_PARAMETERS", @@ -167,10 +173,12 @@ export const LIST_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_REQUEST_HEADERS" ] +/** @internal */ export const LIST_OR_BOOL_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_DISABLE_DEFAULT_INSTRUMENTATIONS" ] +/** @internal */ export const FLOAT_KEYS: (keyof typeof ENV_TO_KEY_MAPPING)[] = [ "APPSIGNAL_CPU_COUNT" ] diff --git a/src/extension.ts b/src/extension.ts index 43336db4..5c357f6b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,6 +6,7 @@ import { Data } from "./internal/data" * The public interface for the extension. * * @class + * @internal */ export class Extension { static isLoaded = extensionLoaded diff --git a/src/extension_wrapper.ts b/src/extension_wrapper.ts index 1ed7ce6a..a6f35b23 100644 --- a/src/extension_wrapper.ts +++ b/src/extension_wrapper.ts @@ -72,4 +72,5 @@ try { } as ExtensionWrapper } +/** @internal */ export = mod diff --git a/src/heartbeat.ts b/src/heartbeat.ts index 932f19e6..c1d27a21 100644 --- a/src/heartbeat.ts +++ b/src/heartbeat.ts @@ -32,6 +32,7 @@ function consoleAndLoggerWarn(message: string) { Client.internalLogger.warn(message) } +/** @internal */ export const heartbeatClassWarnOnce = once( consoleAndLoggerWarn, "The class `Heartbeat` has been deprecated. " + @@ -40,6 +41,7 @@ export const heartbeatClassWarnOnce = once( "in order to remove this message." ) +/** @internal */ export const heartbeatHelperWarnOnce = once( consoleAndLoggerWarn, "The helper `heartbeat` has been deprecated. " + @@ -48,6 +50,7 @@ export const heartbeatHelperWarnOnce = once( "in order to remove this message." ) +/** @deprecated Use `checkIn.cron` (`import { checkIn } from "@appsignal/nodejs"`) instead. */ export function heartbeat(name: string): void export function heartbeat(name: string, fn: () => T): T export function heartbeat(name: string, fn?: () => T): T | undefined { @@ -56,6 +59,7 @@ export function heartbeat(name: string, fn?: () => T): T | undefined { return (cron as (name: string, fn?: () => T) => T | undefined)(name, fn) } +/** @deprecated Use `checkIn.Cron` (`import { checkIn } from "@appsignal/nodejs"`) instead. */ export const Heartbeat = new Proxy(Cron, { construct(target, args: ConstructorParameters) { heartbeatClassWarnOnce() diff --git a/src/internal/data.ts b/src/internal/data.ts index 59e05053..17c26786 100644 --- a/src/internal/data.ts +++ b/src/internal/data.ts @@ -1,5 +1,6 @@ import { datamap, dataarray } from "../extension_wrapper" +/** @internal */ export class Data { public static generate(data: Array | Record) { if (data.constructor.name === "Object") { diff --git a/src/internal_logger.ts b/src/internal_logger.ts index c241dabe..fde237c5 100644 --- a/src/internal_logger.ts +++ b/src/internal_logger.ts @@ -1,6 +1,7 @@ import winston from "winston" const { combine, timestamp, printf } = winston.format +/** @internal */ export interface InternalLogger { error(message: string): void warn(message: string): void @@ -9,6 +10,7 @@ export interface InternalLogger { trace(message: string): void } +/** @internal */ export class BaseInternalLogger { type: string level: string diff --git a/src/noops/internal_logger.ts b/src/noops/internal_logger.ts index fcbed983..9b2e6b84 100644 --- a/src/noops/internal_logger.ts +++ b/src/noops/internal_logger.ts @@ -1,5 +1,6 @@ import { InternalLogger } from "../internal_logger" +/** @internal */ export class NoopInternalLogger implements InternalLogger { error(_message: string) { // noop @@ -18,4 +19,5 @@ export class NoopInternalLogger implements InternalLogger { } } +/** @internal */ export const noopInternalLogger = new NoopInternalLogger() diff --git a/src/noops/logger.ts b/src/noops/logger.ts index 5fd0a984..73383a96 100644 --- a/src/noops/logger.ts +++ b/src/noops/logger.ts @@ -1,5 +1,6 @@ import { Logger, LoggerAttributes } from "../logger" +/** @internal */ export class NoopLogger implements Logger { trace(_message: string, _attributes?: LoggerAttributes) { // noop @@ -21,4 +22,5 @@ export class NoopLogger implements Logger { } } +/** @internal */ export const noopLogger = new NoopLogger() diff --git a/src/noops/metrics.ts b/src/noops/metrics.ts index 11217da9..82e55f7e 100644 --- a/src/noops/metrics.ts +++ b/src/noops/metrics.ts @@ -1,6 +1,7 @@ import { Metrics } from "../metrics" import { Probes } from "../probes" +/** @internal */ export class NoopMetrics extends Metrics { #probes = new Probes({ run: false }) diff --git a/src/probes/index.ts b/src/probes/index.ts index bd982190..ab6679b2 100644 --- a/src/probes/index.ts +++ b/src/probes/index.ts @@ -43,6 +43,7 @@ export class Probes { } } +/** @internal */ type ProbeRunner = { readonly count: number register(name: string, fn: () => void): void @@ -50,6 +51,7 @@ type ProbeRunner = { clear(): void } +/** @internal */ class BaseProbeRunner extends EventEmitter implements ProbeRunner { #timers = new Map() @@ -98,6 +100,7 @@ class BaseProbeRunner extends EventEmitter implements ProbeRunner { } } +/** @internal */ class NoopProbeRunner implements ProbeRunner { readonly count: number = 0 diff --git a/src/probes/v8/index.ts b/src/probes/v8/index.ts index 8ea3a182..36e63497 100644 --- a/src/probes/v8/index.ts +++ b/src/probes/v8/index.ts @@ -3,8 +3,10 @@ import v8 from "v8" import os from "os" import { Client } from "../../client" +/** @internal */ export const PROBE_NAME = "v8_stats" +/** @internal */ export function init(meter: Metrics) { function setGauge(key: string, value: number) { const hostname = Client.config.data.hostname || os.hostname() diff --git a/src/span_processor.ts b/src/span_processor.ts index d0c27116..031e9092 100644 --- a/src/span_processor.ts +++ b/src/span_processor.ts @@ -68,6 +68,7 @@ export class SpanProcessor implements OpenTelemetrySpanProcessor { } } +/** @internal */ export class TestModeSpanProcessor implements OpenTelemetrySpanProcessor { #filePath: string diff --git a/src/transmitter.ts b/src/transmitter.ts index c30c7db2..ebf0712f 100644 --- a/src/transmitter.ts +++ b/src/transmitter.ts @@ -36,6 +36,7 @@ class MaxRedirectsError extends Error { } } +/** @internal */ export class Transmitter { #config: Configuration #url: string diff --git a/src/utils.ts b/src/utils.ts index 511ac570..7f7fefc9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -10,6 +10,7 @@ const SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS) * seconds and nanoseconds. * * @function + * @internal */ export function getAgentTimestamps(timestamp: number) { const sec = Math.round(timestamp / 1000) @@ -21,6 +22,7 @@ export function getAgentTimestamps(timestamp: number) { /** * Checks if the given path is writable by the process. + * @internal */ export function isWritable(path: string) { try { @@ -35,6 +37,7 @@ export function isWritable(path: string) { * Returns a high-resolution time tuple containing the current time in seconds and nanoseconds. * * @function + * @internal */ export function hrTime(performance = perf_hooks.performance): { sec: number @@ -56,23 +59,28 @@ function numberToHrtime(epochMillis: number) { return [seconds, nanoseconds] } +/** @internal */ export function processGetuid() { return (process.getuid ?? (() => -1))() } +/** @internal */ export function ndjsonStringify(elements: any[]): string { return elements.map(element => JSON.stringify(element)).join("\n") } +/** @internal */ export function ndjsonParse(data: string): any[] { return data.split("\n").map(line => JSON.parse(line)) } +/** @internal */ export type Stub any> = F & { set: (fn: F) => void reset: () => void } +/** @internal */ export function stubbable( original: (...args: T) => U ): Stub<(...args: T) => U> { diff --git a/tsconfig.json b/tsconfig.json index 3ebeb809..d6d47be2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,7 @@ ], "compilerOptions": { "rootDir": "./src", - "outDir": "./dist" - }, - "compilerOptions": { + "outDir": "./dist", /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ "target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ @@ -68,5 +66,6 @@ /* Experimental Options */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */ + "stripInternal": true, } }