Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elastic-apm-http-client

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-apm-http-client - npm Package Compare versions

Comparing version 9.5.0 to 9.5.1

CHANGELOG.md

61

index.js

@@ -105,4 +105,5 @@ 'use strict'

// this uncork reverse the .cork call in the constructor (above)
this.uncork()
// This reverses the cork() call in the constructor above. "Maybe" uncork,
// in case the client has been destroyed before this callback is called.
this._maybeUncork()

@@ -221,3 +222,6 @@ // the `cloud-metadata` event allows listeners to know when the

streamToBuffer(res, (err, buf) => {
if (err) return res.destroy(err)
if (err) {
this.emit('request-error', processConfigErrorResponse(res, buf, err))
return
}

@@ -229,9 +233,12 @@ if (res.statusCode === 200) {

let config
try {
this.emit('config', JSON.parse(buf))
} catch (e) {
res.destroy(e)
config = JSON.parse(buf)
} catch (parseErr) {
this.emit('request-error', processConfigErrorResponse(res, buf, parseErr))
return
}
this.emit('config', config)
} else {
res.destroy(processConfigErrorResponse(res, buf))
this.emit('request-error', processConfigErrorResponse(res, buf))
}

@@ -394,3 +401,14 @@ })

// With the cork/uncork handling on this stream, `this.write`ing on this
// stream when already destroyed will lead to:
// Error: Cannot call write after a stream was destroyed
// when the `_corkTimer` expires.
Client.prototype._isUnsafeToWrite = function () {
return this.destroyed
}
Client.prototype.sendSpan = function (span, cb) {
if (this._isUnsafeToWrite()) {
return
}
this._maybeCork()

@@ -401,2 +419,5 @@ return this.write({ span }, Client.encoding.SPAN, cb)

Client.prototype.sendTransaction = function (transaction, cb) {
if (this._isUnsafeToWrite()) {
return
}
this._maybeCork()

@@ -407,2 +428,5 @@ return this.write({ transaction }, Client.encoding.TRANSACTION, cb)

Client.prototype.sendError = function (error, cb) {
if (this._isUnsafeToWrite()) {
return
}
this._maybeCork()

@@ -413,2 +437,5 @@ return this.write({ error }, Client.encoding.ERROR, cb)

Client.prototype.sendMetricSet = function (metricset, cb) {
if (this._isUnsafeToWrite()) {
return
}
this._maybeCork()

@@ -805,8 +832,22 @@ return this.write({ metricset }, Client.encoding.METRICSET, cb)

function processConfigErrorResponse (res, buf) {
const err = new Error('Unexpected APM Server response when polling config')
// Construct or decorate an Error instance from a failing response from the
// APM server central config endpoint.
//
// @param {IncomingMessage} res
// @param {Buffer|undefined} buf - Optional. A Buffer holding the response body.
// @param {Error|undefined} err - Optional. A cause Error instance.
function processConfigErrorResponse (res, buf, err) {
// This library doesn't have a pattern for wrapping errors yet, so if
// we already have an Error instance, we will just decorate it. That preserves
// the stack of the root cause error.
const errMsg = 'Unexpected APM Server response when polling config'
if (!err) {
err = new Error(errMsg)
} else {
err.message = errMsg + ': ' + err.message
}
err.code = res.statusCode
if (buf.length > 0) {
if (buf && buf.length > 0) {
const body = buf.toString('utf8')

@@ -813,0 +854,0 @@ const contentType = res.headers['content-type']

2

package.json
{
"name": "elastic-apm-http-client",
"version": "9.5.0",
"version": "9.5.1",
"description": "A low-level HTTP client for communicating with the Elastic APM intake API",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc