elastic-apm-http-client
Advanced tools
Comparing version 11.4.0 to 12.0.0
36
index.js
@@ -9,3 +9,2 @@ 'use strict' | ||
const util = require('util') | ||
const os = require('os') | ||
const { performance } = require('perf_hooks') | ||
@@ -26,2 +25,3 @@ const { URL } = require('url') | ||
const { detectHostname } = require('./lib/detect-hostname') | ||
const ndjson = require('./lib/ndjson') | ||
@@ -42,3 +42,2 @@ const { NoopLogger } = require('./lib/logging') | ||
const hostname = os.hostname() | ||
const requiredOpts = [ | ||
@@ -249,3 +248,2 @@ 'agentName', | ||
if (!this._conf.serverUrl) this._conf.serverUrl = 'http://127.0.0.1:8200' | ||
if (!this._conf.hostname) this._conf.hostname = hostname | ||
if (!this._conf.environment) this._conf.environment = process.env.NODE_ENV || 'development' | ||
@@ -272,2 +270,4 @@ if (!this._conf.truncateKeywordsAt) this._conf.truncateKeywordsAt = 1024 | ||
this._conf.detectedHostname = detectHostname() | ||
if (containerInfo) { | ||
@@ -281,3 +281,7 @@ if (!this._conf.containerId && containerInfo.containerId) { | ||
if (!this._conf.kubernetesPodName && containerInfo.podId) { | ||
this._conf.kubernetesPodName = hostname | ||
// https://kubernetes.io/docs/concepts/workloads/pods/#working-with-pods | ||
// suggests a pod name should just be the shorter "DNS label", and my | ||
// guess is k8s defaults a pod name to just the *short* hostname, not | ||
// the FQDN. | ||
this._conf.kubernetesPodName = this._conf.detectedHostname.split('.', 1)[0] | ||
} | ||
@@ -1232,3 +1236,4 @@ } | ||
* | ||
* These `Client#supports...` method names intentionally match those from the Java agent: | ||
* These `Client#supports...` method names, if not always the implementation, | ||
* intentionally match those from the Java agent: | ||
* https://github.com/elastic/apm-agent-java/blob/master/apm-agent-core/src/main/java/co/elastic/apm/agent/report/ApmServerClient.java#L322-L349 | ||
@@ -1255,2 +1260,9 @@ */ | ||
} | ||
Client.prototype.supportsConfiguredAndDetectedHostname = function () { | ||
if (!this._apmServerVersion) { | ||
return true // Optimistically assume APM server is >=7.4. | ||
} else { | ||
return semver.gte(this._apmServerVersion, '7.4.0') | ||
} | ||
} | ||
@@ -1496,3 +1508,2 @@ /** | ||
system: { | ||
hostname: opts.hostname, | ||
architecture: process.arch, | ||
@@ -1506,2 +1517,15 @@ platform: process.platform, | ||
// On `system.*hostname` fields: | ||
// - `hostname` was deprecated in APM server v7.4, replaced by the next two. | ||
// - Around Elastic v8.9, ECS changed `host.name` to prefer the FQDN, | ||
// hence APM agents now prefer FQDN for `detected_hostname`. | ||
if (client.supportsConfiguredAndDetectedHostname()) { | ||
payload.system.detected_hostname = opts.detectedHostname | ||
if (opts.configuredHostname) { | ||
payload.system.configured_hostname = opts.configuredHostname | ||
} | ||
} else { | ||
payload.system.hostname = opts.configuredHostname || opts.detectedHostname | ||
} | ||
if (opts.agentActivationMethod && client.supportsActivationMethodField()) { | ||
@@ -1508,0 +1532,0 @@ payload.service.agent.activation_method = opts.agentActivationMethod |
{ | ||
"name": "elastic-apm-http-client", | ||
"version": "11.4.0", | ||
"version": "12.0.0", | ||
"description": "A low-level HTTP client for communicating with the Elastic APM intake API", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"lint": "standard", | ||
"test": "nyc ./test/run_tests.sh" | ||
"test": "nyc node ./scripts/run-tests.js" | ||
}, | ||
@@ -34,2 +34,3 @@ "engines": { | ||
"devDependencies": { | ||
"glob": "^7.2.3", | ||
"ndjson": "^1.5.0", | ||
@@ -36,0 +37,0 @@ "nyc": "^14.1.1", |
@@ -71,3 +71,4 @@ # elastic-apm-http-client | ||
specific framework, use this config option to log its version | ||
- `hostname` - Custom hostname (default: OS hostname) | ||
- `configuredHostname` - A user-configured hostname, if any, e.g. from the `ELASTIC_APM_HOSTNAME` envvar. | ||
See <https://github.com/elastic/apm/blob/main/specs/agents/metadata.md#hostname>. | ||
- `environment` - Environment name (default: `process.env.NODE_ENV || 'development'`) | ||
@@ -74,0 +75,0 @@ - `containerId` - Docker container id, if not given will be parsed from `/proc/self/cgroup` |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
104355
10
2163
506
5
8
3