开发者社区> 镜像站> NPM> @perform/lambda-powertools-http-client
@perform/lambda-powertools-http-client

HTTP client that supports forwarding correlation IDs (captured via @perform/lambda-powertools-correlation-ids) and auto-records metrics

Moved to @dazn/lambda-powertools-http-client - please migrate to the new package by Tuesday 20th August 2019 as this package will be made private.
Last updated a year ago by dazn-lambda-powertools .
MIT · Original npm · Tarball · package.json
$ cnpm install @perform/lambda-powertools-http-client 
SYNC missed versions from official npm registry.

lambda-powertools-http-client

HTTP client that automatically forwards correlation IDs (captured via @perform/lambda-powertools-correlation-ids), and follows DAZN's convention around recording metrics around integration points.

Main features:

  • auto-forwards any correlation IDs captured with the @perform/lambda-powertools-correlation-ids package as HTTP headers

  • auto-record custom metrics using the @dazn/datadog-metrics package, which defaults to async mode (i.e. writing to stdout in DogStatsD format) but can be configured via the DATADOG_METRICS_MODE environment variable

  • custom metrics include:

    • {hostName}.response.latency [histogram]: e.g. google.com.response.latency

    • {hostName}.response.{statusCode} [count]: e.g. google.com.response.200

    metric names can be overriden with the metricName option (see below for details)

  • all custom metrics include the tags awsRegion, functionName, functionVersion, method (e.g. POST) and path (e.g. /v1/signin)

  • you can add additional tags by passing them in via the metricTags option (see below for details)

  • supports timeout

Getting Started

Install from NPM: npm install @perform/lambda-powertools-http-client

API

Basic usage looks like this:

const HTTP = require('@perform/lambda-powertools-http-client')

const sayIt = async () => {
  const httpRequest = {
    uri: `https://example.com/dev/say`,
    method: 'post',
    body: { message: 'hello world' }
  }

  await HTTP(httpRequest)
}

It's essentially a function that accepts a request of type:

{
  uri     : string
  method  : GET (default) | POST | PUT | HEAD
  headers : object
  qs      : object
  body    : object
  metricName [optional] : string     // override the default metric name, e.g. 'adyenApi', which changes metrics to 'adyenapi.latency' and 'adyenapi.202'
  metricTags [optional] : string []  // additional tags for metrics, e.g. ['request_type:submit', 'load_test']
  timeout [optional] : int (millis)
}

Current Tags

  • 1.8.1                                ...           latest (a year ago)

31 Versions

  • 1.8.1 [deprecated]           ...           a year ago
  • 1.6.1 [deprecated]           ...           a year ago
  • 1.6.0 [deprecated]           ...           a year ago
  • 1.5.2 [deprecated]           ...           a year ago
  • 1.5.0 [deprecated]           ...           a year ago
  • 1.3.0 [deprecated]           ...           a year ago
  • 1.2.0 [deprecated]           ...           2 years ago
  • 1.1.7 [deprecated]           ...           2 years ago
  • 1.1.6 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
  • 0.10.5 [deprecated]           ...           2 years ago
  • 0.10.4 [deprecated]           ...           2 years ago
  • 0.10.3 [deprecated]           ...           2 years ago
  • 0.10.2 [deprecated]           ...           2 years ago
  • 0.10.1 [deprecated]           ...           2 years ago
  • 0.10.0 [deprecated]           ...           2 years ago
  • 0.9.0 [deprecated]           ...           2 years ago
  • 0.8.0 [deprecated]           ...           2 years ago
  • 0.7.0 [deprecated]           ...           2 years ago
  • 0.6.4 [deprecated]           ...           2 years ago
  • 0.6.3 [deprecated]           ...           2 years ago
  • 0.6.2 [deprecated]           ...           2 years ago
  • 0.6.0 [deprecated]           ...           2 years ago
  • 0.5.0 [deprecated]           ...           2 years ago
  • 0.4.0 [deprecated]           ...           2 years ago
  • 0.3.0 [deprecated]           ...           2 years ago
  • 0.2.12 [deprecated]           ...           2 years ago
  • 0.2.11 [deprecated]           ...           2 years ago
  • 0.2.10 [deprecated]           ...           2 years ago
  • 0.2.9 [deprecated]           ...           2 years ago
  • 0.2.8 [deprecated]           ...           2 years ago
Maintainers (358)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (1)
Dependents (0)
None