Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Aug 16, 2024
1 parent 735726e commit 306260e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Please see each tool's source directory for additional documentation
* Node.js signal handlers that provide a way to shut down long-running application components
gracefully on unhandled exceptions or interrupt signals.

### CPU Profiler

* Fastify server that controls a CPU profiler capable of generating `cpuprofile` snapshot files for
memory usage analysis.

### Logger

* Standardized logger configuration using [pino](https://github.com/pinojs/pino)
Expand Down
9 changes: 6 additions & 3 deletions src/profiler/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Fastify, { FastifyInstance, FastifyPluginCallback, FastifyReply } from 'f
import { Type, TypeBoxTypeProvider } from '@fastify/type-provider-typebox';
import { initCpuProfiling, initHeapSnapshot, ProfilerInstance } from './inspector-util';

const DurationSchema = Type.Number({ minimum: 0 });
const SamplingIntervalSchema = Type.Optional(Type.Number({ minimum: 0 }));

const CpuProfiler: FastifyPluginCallback<Record<never, never>, Server, TypeBoxTypeProvider> = (
fastify,
options,
Expand All @@ -23,8 +26,8 @@ const CpuProfiler: FastifyPluginCallback<Record<never, never>, Server, TypeBoxTy
{
schema: {
querystring: Type.Object({
duration: Type.Number({ minimum: 0 }),
sampling_interval: Type.Optional(Type.Integer({ minimum: 0 })),
duration: DurationSchema,
sampling_interval: SamplingIntervalSchema,
}),
},
},
Expand Down Expand Up @@ -76,7 +79,7 @@ const CpuProfiler: FastifyPluginCallback<Record<never, never>, Server, TypeBoxTy
{
schema: {
querystring: Type.Object({
sampling_interval: Type.Optional(Type.Integer({ minimum: 0 })),
sampling_interval: SamplingIntervalSchema,
}),
},
},
Expand Down

0 comments on commit 306260e

Please sign in to comment.