Gathering detailed insights and metrics for seek-datadog-custom-metrics
Gathering detailed insights and metrics for seek-datadog-custom-metrics
Gathering detailed insights and metrics for seek-datadog-custom-metrics
Gathering detailed insights and metrics for seek-datadog-custom-metrics
npm install seek-datadog-custom-metrics
70.3
Supply Chain
98.6
Quality
77.9
Maintenance
100
Vulnerability
98.9
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
291 Commits
2 Forks
7 Watching
5 Branches
16 Contributors
Updated on 24 Sept 2024
Minified
Minified + Gzipped
TypeScript (99.76%)
JavaScript (0.24%)
Cumulative downloads
Total Downloads
Last day
-7%
581
Compared to previous day
Last week
-22.1%
3,558
Compared to previous week
Last month
-2%
16,476
Compared to previous month
Last year
-18%
181,453
Compared to previous year
1
2
5
Helpers for sending Datadog custom metrics via hot-shots.
1yarn add seek-datadog-custom-metrics
All custom metrics are prefixed by AppConfig.name
.
Two global tags are also added to every custom metric:
AppConfig.environment
becomes env:${value}
AppConfig.version
becomes version:${value}
These tags are consistent with tags sent by Gantry via Datadog's AWS integration.
createStatsDClient
createStatsDClient
creates a hot-shots client configured with our tagging convention.
This is intended for containerized services, particularly those deployed with Gantry.
1import { StatsD } from 'hot-shots'; 2import { createStatsDClient } from 'seek-datadog-custom-metrics'; 3 4// Expects `name`, `version`, `environment` and `metricsServer` properties 5import config from '../config'; 6 7// This example assumes Bunyan/pino 8import { rootLogger } from '../logger'; 9const errorHandler = (err: Error) => { 10 rootLogger.error('StatsD error', err); 11}; 12 13// Returns a standard hot-shots StatsD instance 14const metricsClient = createStatsDClient(StatsD, config, errorHandler);
createLambdaExtensionClient
createLambdaExtensionClient
creates a Lambda extension client.
This is intended for AWS Lambda functions and is a replacement for createCloudWatchClient
.
This client will only submit metrics as a distribution which enables globally accurate aggregations for percentiles (p50, p75, p90, etc).
1import { createLambdaExtensionClient } from 'seek-datadog-custom-metrics'; 2 3// Expects `name` and `metrics` properties 4import config from '../config'; 5 6// Returns a standard hot-shots StatsD instance 7const { metricsClient, withLambdaExtension } = 8 createLambdaExtensionClient(config); 9 10export const handler = withLambdaExtension((event, _ctx) => { 11 try { 12 logger.info('request'); 13 14 await lambdaFunction(event); 15 } catch (err) { 16 logger.error({ err }, 'request'); 17 18 metricsClient.increment('invocation_error'); 19 20 throw new Error('invoke error'); 21 } 22});
createNoOpClient
createNoOpClient
returns a no-op client.
This is intended for use where a MetricsClient interface is expected but you do not wish to provide one, e.g in tests.
1import { createNoOpClient } from 'seek-datadog-custom-metrics'; 2 3// Returns a `MetricsClient` subset of the full StatsD interface 4const metricsClient = createNoOpClient();
createTimedSpan
createTimedSpan
wraps an asynchronous closure and records custom Datadog metrics about its performance.
This is intended as a lightweight alternative to APM where nested spans aren't required.
1import { createTimedSpan } from 'seek-datadog-custom-metrics'; 2 3// Takes a StatsD instance or `MetricsClient` 4const timedSpan = createTimedSpan(metricsClient); 5 6const loadPrivateKey = async (): Promise<PrivateKey> => 7 await timedSpan( 8 // Prefix for the custom metrics 9 'secrets.load_private_key', 10 // Closure to be timed 11 () => client.getSecretValue({ SecretId }).promise(), 12 );
httpTracingConfig
The dd-trace package can instrument your application and trace its outbound HTTP requests.
However, its emitted trace.http.request
metric only captures the HTTP method against the resource.name
tag,
which is not useful if your application makes HTTP requests to multiple resources and you want to inspect latency by resource.
This configuration object adds a hook to replace the resource.name
with a HTTP method and semi-normalised URL.
For example, if your application makes the following HTTP request:
1PUT https://www.example.com/path/to/123?idempotencyKey=c1083fb6-519c-42bf-8619-08dfd6229954
The trace.http.request
metric will see the following tag change:
1- resource_name:put 2+ resource_name:put_https://www.example.com/path/to/number?idempotencyKey=uuid
Apply the configuration object where you bootstrap your application with the Datadog tracer:
1import { httpTracingConfig } from 'seek-datadog-custom-metrics'; 2 3// DataDog/dd-trace-js#1118 4datadogTracer?.use('http', httpTracingConfig);
This configuration may be superseded in future if the underlying dd-trace implementation is corrected.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
all changesets reviewed
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
1 existing vulnerabilities detected
Details
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More