Skip to content

Commit

Permalink
Merge branch 'main' into dluna/2905-feat-kafkajs-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Mar 7, 2024
2 parents c2f1d18 + 7a697bc commit 1da35b6
Show file tree
Hide file tree
Showing 21 changed files with 781 additions and 769 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/addToProject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
issues:
types:
- opened, milestoned
permissions:
contents: read

jobs:
add_to_project:
if: github.event.issue && github.event.issue.milestone
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ on:
env:
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}

permissions:
contents: read
# This permission is needed to add labels to issues/PRs per
# https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#add-labels-to-an-issue
issues: write

jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Add agent-nodejs label
- name: Add agent-nodejs label to this issue/PR
uses: AlexanderWert/issue-labeler@v2.3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
Expand All @@ -32,7 +38,7 @@ jobs:
run: |
echo "::debug::isTeamMember: ${{ steps.checkUserMember.outputs.isTeamMember }}"
echo "::debug::isExcluded: ${{ steps.checkUserMember.outputs.isExcluded }}"
- name: Add community and triage lables
- name: Add community and triage labels
if: steps.checkUserMember.outputs.isTeamMember != 'true' && steps.checkUserMember.outputs.isExcluded != 'true'
uses: AlexanderWert/issue-labeler@v2.3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/microbenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
channel: "#apm-agent-nodejs"
channel: "#apm-agent-node"
message: |
:ghost: [${{ github.repository }}] microbenchmark *${{ github.ref_name }}* failed to run in Buildkite.
Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- run: make -C .ci push-docker

- name: Read AWS vault secrets
uses: hashicorp/vault-action@v2.8.0
uses: hashicorp/vault-action@v3.0.0
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
Expand All @@ -56,7 +56,7 @@ jobs:
GH_TOKEN: ${{ github.token }}

- name: Read NPM vault secrets
uses: hashicorp/vault-action@v2.8.0
uses: hashicorp/vault-action@v3.0.0
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions:
contents: read

jobs:

lint:
Expand Down
5 changes: 4 additions & 1 deletion .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mongodb:
node: '>=14.20.1'
commands: node test/instrumentation/modules/mongodb/mongodb.test.js
- versions: '>=6 <7'
node: '>=15.0.0'
node: '>=16.20.1'
commands: node test/instrumentation/modules/mongodb/mongodb.test.js

# Bluebird is effectively deprecated (https://github.com/petkaantonov/bluebird#%EF%B8%8Fnote%EF%B8%8F).
Expand Down Expand Up @@ -335,6 +335,9 @@ tedious:
- versions: '16.0.0 || 16.1.0 || >16.1.0 <17' # first and last majors subset of '16.x'
node: '>=16'
commands: node test/instrumentation/modules/tedious.test.js
- versions: '>=17.0.0 <18' # first and last majors subset of '17.x' (as for now there is only v17.0.0)
node: '18.x || >=20'
commands: node test/instrumentation/modules/tedious.test.js

cassandra-driver:
# 3.1.0 is broken
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ See the <<upgrade-to-v4>> guide.
[float]
===== Features
* Update <<opentelemetry-bridge>> support to `@opentelemetry/api` version 1.8.0.
* Add support for `tedious` version v17. ({pull}3901[#3901])
* Add support for `kafkajs` version v2. ({issues}2905[#2905])
[float]
===== Bug fixes
* Fix instrumentation of mongodb to not break mongodb@6.4.0. Mongodb v6.4.0
included changes that resulted in the APM agent's instrumentation breaking it.
({pull}3897[#3897])
[float]
===== Chores
Expand Down
4 changes: 2 additions & 2 deletions docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Metrics API and Metrics SDK to allow
[options="header"]
|=======================================================================
| Framework | Version
| <<opentelemetry-bridge,@opentelemetry/api>> | >=1.0.0 <1.8.0
| <<opentelemetry-bridge,@opentelemetry/api>> | >=1.0.0 <1.9.0
| https://www.npmjs.com/package/@opentelemetry/sdk-metrics[@opentelemetry/sdk-metrics] | >=1.11.0 <2
|=======================================================================

Expand Down Expand Up @@ -139,7 +139,7 @@ so those should be supported as well.
|https://www.npmjs.com/package/mysql2[mysql2] |>=1.0.0 <4.0.0 |Will instrument all queries
|https://www.npmjs.com/package/pg[pg] |>=4.0.0 <9.0.0 |Will instrument all queries
|https://www.npmjs.com/package/redis[redis] |>=2.0.0 <5.0.0 |Will instrument all queries
|https://www.npmjs.com/package/tedious[tedious] |>=1.9 <17.0.0 | (Excluding v4.0.0.) Will instrument all queries
|https://www.npmjs.com/package/tedious[tedious] |>=1.9 <18.0.0 | (Excluding v4.0.0.) Will instrument all queries
|https://www.npmjs.com/package/undici[undici] | >=4.7.1 <6 | Will instrument undici HTTP requests, except HTTP CONNECT. Requires node v14.17.0 or later, or the user to have installed the https://www.npmjs.com/package/diagnostics_channel['diagnostics_channel' polyfill].
|https://www.npmjs.com/package/ws[ws] |>=1.0.0 <8.0.0 |Will instrument outgoing WebSocket messages
|https://www.npmjs.com/package/kafkajs[kafkajs] |>=2.0.0 <3.0.0 |Will instrument all send methods for producers and message and batch processing for consumers.
Expand Down
10 changes: 9 additions & 1 deletion lib/apm-client/http-apm-client/detect-hostname.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ function detectHostname() {
// https://learn.microsoft.com/en-us/dotnet/api/system.net.dns.gethostentry
out = spawnSync(
'powershell.exe',
['[System.Net.Dns]::GetHostEntry($env:computerName).HostName'],
[
'-NoLogo',
'-NonInteractive',
'-NoProfile',
'-ExecutionPolicy',
'Bypass',
'-Command',
'[System.Net.Dns]::GetHostEntry($env:computerName).HostName',
],
{ encoding: 'utf8', shell: true, timeout: 2000 },
);
if (!out.error) {
Expand Down
11 changes: 6 additions & 5 deletions lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const semver = require('semver');

module.exports = (mod, agent, { version, enabled }) => {
if (!enabled) return mod;
if (!semver.satisfies(version, '>=3.3 <7.0')) {
agent.logger.debug(
'mongodb version %s not instrumented (mongodb <3.3 is instrumented via mongodb-core)',
version,
);
if (!semver.satisfies(version, '>=3.3 <6.4.0')) {
// - mongodb <3.3 is instrumented via mongodb-core
// - mongodb >=6.4.0 now longer requires ConnectionPool#checkOut to be
// patched to fix async context tracking. See discussion at
// https://github.com/elastic/apm-agent-nodejs/pull/3897
return mod;
}
agent.logger.debug('instrumenting mongodb ConnectionPool#checkOut');

if (mod.ConnectionPool) {
class ConnectionPoolTraced extends mod.ConnectionPool {
Expand Down
2 changes: 1 addition & 1 deletion lib/instrumentation/modules/tedious.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var { getDBDestination } = require('../context');

module.exports = function (tedious, agent, { version, enabled }) {
if (!enabled) return tedious;
if (version === '4.0.0' || !semver.satisfies(version, '>=1.9.0 <17')) {
if (version === '4.0.0' || !semver.satisfies(version, '>=1.9.0 <18')) {
agent.logger.debug(
'tedious version %s not supported - aborting...',
version,
Expand Down
Loading

0 comments on commit 1da35b6

Please sign in to comment.