-
Notifications
You must be signed in to change notification settings - Fork 422
refactor: Refactor child_process instrumentation to use tracing channel instead of Shim
#4212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amychisholm03
wants to merge
6
commits into
newrelic:main
Choose a base branch
from
amychisholm03:core-subscribers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5311183
Refactor `child_process` instrumentation to use tracing channel inste…
amychisholm03 2ef6c25
Add unit test if no `child_process`
amychisholm03 5b832b5
Address PR feedback: Refactor to `ChildProcessInstrumentation`; add d…
amychisholm03 ab569ba
Add proper teardown
amychisholm03 1330ce0
Refactor to use a new base subscriber, `tc-base`
amychisholm03 c853544
Add more tests
amychisholm03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright 2020 New Relic Corporation. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| 'use strict' | ||
|
|
||
| const test = require('node:test') | ||
| const assert = require('node:assert') | ||
| const sinon = require('sinon') | ||
| const helper = require('#testlib/agent_helper.js') | ||
| const logger = require('#agentlib/logger.js') | ||
| const childProcessInstrumentation = require('#agentlib/instrumentation/core/child_process.js') | ||
|
|
||
| test('child_process instrumentation', async (t) => { | ||
| const agent = helper.loadMockedAgent() | ||
| t.after(() => { | ||
| helper.unloadAgent(agent) | ||
| }) | ||
|
|
||
| await t.test('should log and return false when child_process is not available', (t) => { | ||
| const proto = Object.getPrototypeOf(logger.child({})) | ||
| const debugStub = sinon.stub(proto, 'debug') | ||
| t.after(() => { | ||
| debugStub.restore() | ||
| }) | ||
|
|
||
| const result = childProcessInstrumentation(agent, null) | ||
|
|
||
| assert.equal(result, false) | ||
| assert.ok(debugStub.calledWith('Could not find child_process, not instrumenting')) | ||
| }) | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.