elastic-apm-http-client
Advanced tools
Comparing version 11.2.0 to 11.3.0
39
index.js
@@ -132,2 +132,11 @@ 'use strict' | ||
// `_apmServerVersion` is one of: | ||
// - `undefined`: the version has not yet been fetched | ||
// - `null`: the APM server version is unknown, could not be determined | ||
// - a semver.SemVer instance | ||
this._apmServerVersion = this._conf.apmServerVersion ? semver.SemVer(this._conf.apmServerVersion) : undefined | ||
if (!this._apmServerVersion) { | ||
this._fetchApmServerVersion() | ||
} | ||
const numExtraMdOpts = [ | ||
@@ -170,11 +179,2 @@ this._conf.cloudMetadataFetcher, | ||
// `_apmServerVersion` is one of: | ||
// - `undefined`: the version has not yet been fetched | ||
// - `null`: the APM server version is unknown, could not be determined | ||
// - a semver.SemVer instance | ||
this._apmServerVersion = this._conf.apmServerVersion ? semver.SemVer(this._conf.apmServerVersion) : undefined | ||
if (!this._apmServerVersion) { | ||
this._fetchApmServerVersion() | ||
} | ||
this._chopper = new StreamChopper({ | ||
@@ -318,4 +318,2 @@ size: this._conf.size, | ||
this._conf.metadata = getMetadata(this._conf) | ||
// fixes bug where cached/memoized _encodedMetadata wouldn't be | ||
@@ -364,3 +362,3 @@ // updated when client was reconfigured | ||
/** | ||
* (Re)set `_encodedMetadata` from this._conf.metadata, this._cloudMetadata, | ||
* (Re)set `_encodedMetadata` from this._conf, this._cloudMetadata, | ||
* this._extraMetadata and possible this._metadataFilters. | ||
@@ -372,3 +370,3 @@ */ | ||
// cycle for cloning should suffice. | ||
let metadata = deepClone(this._conf.metadata) | ||
let metadata = metadataFromConf(this._conf, this) | ||
if (this._cloudMetadata) { | ||
@@ -1147,2 +1145,11 @@ metadata.cloud = deepClone(this._cloudMetadata) | ||
} | ||
Client.prototype.supportsActivationMethodField = function () { | ||
// APM server 8.7.0 had a bug where sending `activation_method` is *harmful*, | ||
// therefore, if we don't *know* we are >=8.7.1, then assume no. | ||
if (!this._apmServerVersion) { | ||
return false | ||
} else { | ||
return semver.gte(this._apmServerVersion, '8.7.1') | ||
} | ||
} | ||
@@ -1208,2 +1215,3 @@ /** | ||
this._apmServerVersion = null // means "unknown version" | ||
this._resetEncodedMetadata() | ||
if (isLambdaExecutionEnvironment) { | ||
@@ -1265,2 +1273,3 @@ // In a Lambda environment, where the process can be frozen, it is not | ||
} | ||
this._resetEncodedMetadata() | ||
this._log.debug({ apmServerVersion: verStr }, 'fetched APM Server version') | ||
@@ -1356,3 +1365,3 @@ } else { | ||
function getMetadata (opts) { | ||
function metadataFromConf (opts, client) { | ||
var payload = { | ||
@@ -1393,3 +1402,3 @@ service: { | ||
if (opts.agentActivationMethod) { | ||
if (opts.agentActivationMethod && client.supportsActivationMethodField()) { | ||
payload.service.agent.activation_method = opts.agentActivationMethod | ||
@@ -1396,0 +1405,0 @@ } |
{ | ||
"name": "elastic-apm-http-client", | ||
"version": "11.2.0", | ||
"version": "11.3.0", | ||
"description": "A low-level HTTP client for communicating with the Elastic APM intake API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,2 @@ # elastic-apm-http-client | ||
[![Test status in GitHub Actions](https://github.com/elastic/apm-nodejs-http-client/workflows/Test/badge.svg)](https://github.com/elastic/apm-nodejs-http-client/actions) | ||
[![Build Status in Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-nodejs%2Fapm-nodejs-http-client-mbp%2Fmain)](https://apm-ci.elastic.co/job/apm-agent-nodejs/job/apm-nodejs-http-client-mbp/job/main/) | ||
@@ -311,2 +310,10 @@ A low-level HTTP client for communicating with the Elastic APM intake | ||
### `client.supportsActivationMethodField()` | ||
This method returns a boolean indicating whether the remote APM Server (per | ||
the configured `serverUrl`) is of a version that supports the | ||
`metadata.service.agent.activation_method` field. | ||
This defaults to `false` if the remote APM server version is not known. | ||
### `client.addMetadataFilter(fn)` | ||
@@ -313,0 +320,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95206
1979
468