├── .c8rc.json
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── config.yml
│ └── feature_request.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── add-to-board.yml
│ ├── ci-workflow.yml
│ ├── prepare-release.yml
│ └── repolinter.yml
├── .gitignore
├── .husky
└── pre-commit
├── .lintstagedrc.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── THIRD_PARTY_NOTICES.md
├── THIRD_PARTY_NOTICES_FOOTER.md
├── bin
└── update-third-party-notices.sh
├── cla.md
├── lerna.json
├── package-lock.json
├── package.json
├── packages
├── pino-log-enricher
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── THIRD_PARTY_NOTICES.md
│ ├── THIRD_PARTY_NOTICES_FOOTER.md
│ ├── bin
│ │ └── update-third-party-notices.sh
│ ├── index.js
│ ├── lib
│ │ ├── createFormatter.js
│ │ └── truncate.js
│ ├── package-lock.json
│ ├── package.json
│ ├── tests
│ │ ├── unit
│ │ │ └── messageTruncate.tap.js
│ │ └── versioned
│ │ │ ├── newrelic.js
│ │ │ ├── package.json
│ │ │ └── pino.tap.js
│ └── third_party_manifest.json
└── winston-log-enricher
│ ├── .github
│ ├── ISSUE_TEMPLATE
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows
│ │ ├── ci-workflow.yaml
│ │ └── repolinter.yml
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── THIRD_PARTY_NOTICES.md
│ ├── THIRD_PARTY_NOTICES_FOOTER.md
│ ├── bin
│ └── update-third-party-notices.sh
│ ├── index.js
│ ├── lib
│ ├── createFormatter.js
│ └── truncate.js
│ ├── package-lock.json
│ ├── package.json
│ ├── tests
│ ├── types
│ │ └── index.test-d.ts
│ ├── unit
│ │ └── messageTruncate.tap.js
│ └── versioned
│ │ ├── newrelic.js
│ │ ├── package.json
│ │ ├── utils.js
│ │ └── winston.tap.js
│ ├── third_party_manifest.json
│ └── types
│ └── index.d.ts
└── third_party_manifest.json
/.c8rc.json:
--------------------------------------------------------------------------------
1 | {
2 | "reporter": ["html", "lcov"],
3 | "all": true,
4 | "exclude": ["packages/*/tests/*", "coverage/*", "packages/*/types/*", ".eslintrc.js"]
5 | }
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | module.exports = {
9 | extends: '@newrelic',
10 | overrides: [
11 | {
12 | files: ['packages/**/tests/versioned/**/**'],
13 | rules: {
14 | 'node/no-extraneous-require': 'off',
15 | 'node/no-missing-require': 'off',
16 | 'node/no-unpublished-require': 'off'
17 | }
18 | },
19 | {
20 | files: ['packages/**/tests/**/**/**'],
21 | rules: {
22 | 'func-names': 'off',
23 | 'max-nested-callbacks': 'off',
24 | 'no-shadow': ['warn', { allow: ['t', 'err', 'shim', 'error'] }]
25 | }
26 | }
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Bug report \U0001F41B"
3 | about: Describe a scenario in which this project behaves unexpectedly
4 | title: ''
5 | labels: bug, needs-triage
6 | assignees: ''
7 |
8 | ---
9 |
10 | [NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )
11 |
12 | ## Description
13 |
14 | [NOTE]: # ( Describe the problem you're encountering. )
15 | [TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )
16 |
17 | ## Steps to Reproduce
18 |
19 | [NOTE]: # ( Please be as specific as possible. )
20 |
21 | ## Expected Behavior
22 |
23 | [NOTE]: # ( Tell us what you expected to happen. )
24 |
25 | ## Relevant Logs / Console output
26 |
27 | [NOTE]: # ( Please provide specifics of the local error logs, Browser Dev Tools console, etc. if appropriate and possible. )
28 |
29 | ## Your Environment
30 |
31 | [TIP]: # ( Include as many relevant details about your environment as possible. )
32 |
33 | * ex: Browser name and version:
34 | * ex: Operating System and version:
35 |
36 | ## Additional context
37 |
38 | [TIP]: # ( Add any other context about the problem here. )
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Troubleshooting
4 | url: https://github.com/newrelic/newrelic-node-log-extensions/blob/main/README.md#support
5 | about: Check out the README for troubleshooting directions
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: feature-request, needs-triage
6 | assignees: ''
7 | priority: ''
8 | ---
9 |
10 | ## Is your feature request related to a problem? Please describe.
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | ## Feature Description
14 | A clear and concise description of the feature you want or need.
15 |
16 | ## Describe Alternatives
17 | A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to?
18 |
19 | ## Additional context
20 | Add any other context here.
21 |
22 | ## Priority
23 | Please help us better understand this feature request by choosing a priority from the following options:
24 | [Nice to Have, Really Want, Must Have, Blocker]
25 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
14 |
15 | ## Proposed Release Notes
16 |
17 | ## Links
18 |
19 | ## Details
20 |
--------------------------------------------------------------------------------
/.github/workflows/add-to-board.yml:
--------------------------------------------------------------------------------
1 | name: Auto Assign to Project(s)
2 |
3 | on:
4 | issues:
5 | types: [opened]
6 | pull_request_target:
7 | types: [opened]
8 |
9 | jobs:
10 | add-to-board:
11 | uses: newrelic/node-newrelic/.github/workflows/board.yml@main
12 | # See board.yml explaining why this has to be done
13 | secrets:
14 | gh_token: ${{ secrets.NODE_AGENT_GH_TOKEN }}
15 |
--------------------------------------------------------------------------------
/.github/workflows/ci-workflow.yml:
--------------------------------------------------------------------------------
1 | name: Log Extensions CI
2 |
3 | on:
4 | push:
5 | pull_request:
6 | workflow_dispatch:
7 | schedule:
8 | # Run every Monday at 9AM PST (16 UTC)
9 | - cron: '0 16 * * 1'
10 |
11 | jobs:
12 | lint:
13 | runs-on: ubuntu-latest
14 |
15 | strategy:
16 | matrix:
17 | node-version: [lts/*]
18 |
19 | steps:
20 | - uses: actions/checkout@v3
21 | - name: Use Node.js ${{ matrix.node-version }}
22 | uses: actions/setup-node@v3
23 | with:
24 | node-version: ${{ matrix.node-version }}
25 | - name: Install Dependencies
26 | run: |
27 | npm ci
28 | npx lerna bootstrap
29 | - name: Run Linting
30 | run: npm run lint
31 | - name: Inspect Lockfile
32 | run: npm run lint:lockfile
33 |
34 | types:
35 | runs-on: ubuntu-latest
36 |
37 | strategy:
38 | matrix:
39 | node-version: [lts/*]
40 |
41 | steps:
42 | - uses: actions/checkout@v3
43 | - name: Use Node.js ${{ matrix.node-version }}
44 | uses: actions/setup-node@v3
45 | with:
46 | node-version: ${{ matrix.node-version }}
47 | - name: Install Dependencies
48 | run: |
49 | npm ci
50 | npx lerna bootstrap
51 | - name: Run Type Checking (TSD)
52 | run: |
53 | cd packages/winston-log-enricher
54 | npm run types
55 |
56 | unit:
57 | runs-on: ubuntu-latest
58 |
59 | strategy:
60 | matrix:
61 | node-version: [16.x, 18.x, 20.x]
62 |
63 | steps:
64 | - uses: actions/checkout@v3
65 | - name: Use Node.js ${{ matrix.node-version }}
66 | uses: actions/setup-node@v3
67 | with:
68 | node-version: ${{ matrix.node-version }}
69 | - name: Install Dependencies
70 | run: |
71 | npm ci
72 | npx lerna bootstrap
73 | - name: Run Unit Tests
74 | run: npm run unit
75 | - name: Post Unit Test Coverage
76 | uses: codecov/codecov-action@v3
77 | with:
78 | directory: ./coverage/unit
79 | token: ${{ secrets.CODECOV_TOKEN }}
80 | files: lcov.info
81 | flags: unit-tests-${{ matrix.node-version }}
82 |
83 | versioned:
84 | runs-on: ubuntu-latest
85 |
86 | strategy:
87 | matrix:
88 | node-version: [16.x, 18.x, 20.x]
89 |
90 | steps:
91 | - uses: actions/checkout@v3
92 | - name: Use Node.js ${{ matrix.node-version }}
93 | uses: actions/setup-node@v3
94 | with:
95 | node-version: ${{ matrix.node-version }}
96 | - name: Install Dependencies
97 | run: |
98 | npm ci
99 | npx lerna bootstrap
100 | - name: Run Versioned Tests
101 | run: npm run versioned
102 | - name: Post Versioned Test Coverage
103 | uses: codecov/codecov-action@v3
104 | with:
105 | directory: ./coverage/versioned
106 | token: ${{ secrets.CODECOV_TOKEN }}
107 | files: lcov.info
108 | flags: versioned-tests-${{ matrix.node-version }}
109 |
--------------------------------------------------------------------------------
/.github/workflows/prepare-release.yml:
--------------------------------------------------------------------------------
1 | name: Prepare Release PR
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | release_type:
7 | description: Type of release. patch or minor (major if breaking)
8 | required: true
9 | default: patch
10 |
11 | jobs:
12 | release-notes:
13 | uses: newrelic/node-newrelic/.github/workflows/prep-release.yml@main
14 | with:
15 | release_type: ${{ github.event.inputs.release_type }}
16 | changelog_file: CHANGELOG.md
17 |
--------------------------------------------------------------------------------
/.github/workflows/repolinter.yml:
--------------------------------------------------------------------------------
1 | # NOTE: This file should always be named `repolinter.yml` to allow
2 | # workflow_dispatch to work properly
3 | name: Repolinter Action
4 |
5 | # NOTE: This workflow will ONLY check the default branch!
6 | # Currently there is no elegant way to specify the default
7 | # branch in the event filtering, so branches are instead
8 | # filtered in the "Test Default Branch" step.
9 | on: [push, workflow_dispatch]
10 |
11 | jobs:
12 | repolint:
13 | name: Run Repolinter
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Test Default Branch
17 | id: default-branch
18 | uses: actions/github-script@v6
19 | with:
20 | script: |
21 | const data = await github.rest.repos.get(context.repo)
22 | return data.data && data.data.default_branch === context.ref.split('/').slice(-1)[0]
23 | - name: Checkout Self
24 | if: ${{ steps.default-branch.outputs.result == 'true' }}
25 | uses: actions/checkout@v3
26 | - name: Run Repolinter
27 | if: ${{ steps.default-branch.outputs.result == 'true' }}
28 | uses: newrelic/repolinter-action@v1
29 | with:
30 | config_url: https://raw.githubusercontent.com/newrelic/.github/main/repolinter-rulesets/community-plus.yml
31 | output_type: issue
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | newrelic_agent.log
3 | .coverage_data
4 | cover_html
5 | npm-debug.log
6 | *.key
7 | *.crt
8 | ca-index*
9 | ca-serial*
10 | .DS_Store
11 | .idea
12 | out
13 | .vscode
14 | .nyc_output
15 | test/**/package-lock.json
16 | coverage/
17 |
18 | # Needed for testing
19 | !test/integration/moduleLoading/node_modules
20 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 | . "$(dirname "$0")/../bin/update-third-party-notices.sh"
4 |
5 | npx lint-staged
6 |
--------------------------------------------------------------------------------
/.lintstagedrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "**/**/*.js": [
3 | "eslint --fix"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | For changelogs specific to particular log enrichers, try the following:
4 |
5 | * [winston-log-enricher changelog](./packages/winston-log-enricher/CHANGELOG.md)
6 | * [pino-log-enricher changelog](./packages/pino-log-enricher/CHANGELOG.md)
7 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are always welcome. Before contributing please read the
4 | [code of conduct](https://github.com/newrelic/.github/blob/main/CODE_OF_CONDUCT.md) and [search the issue tracker](issues); your issue may have already been discussed or fixed in `main`. To contribute,
5 | [fork](https://help.github.com/articles/fork-a-repo/) this repository, commit your changes, and [send a Pull Request](https://help.github.com/articles/using-pull-requests/).
6 |
7 | Note that our [code of conduct](https://github.com/newrelic/.github/blob/main/CODE_OF_CONDUCT.md) applies to all platforms and venues related to this project; please follow it in all your interactions with the project and its participants.
8 |
9 | ## Feature Requests
10 |
11 | Feature requests should be submitted in the [Issue tracker](../../issues), with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest, [e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), has been [shown by the community](../../issues?q=label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
12 | Before submitting an Issue, please search for similar ones in the
13 | [closed issues](../../issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement).
14 |
15 | ## Pull Requests
16 |
17 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
18 | 2. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
19 | 3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.
20 |
21 | ## Contributor License Agreement
22 |
23 | Keep in mind that when you submit your Pull Request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at opensource@newrelic.com.
24 |
25 | For more information about CLAs, please check out Alex Russell’s excellent post,
26 | [“Why Do I Need to Sign This?”](https://infrequently.org/2008/06/why-do-i-need-to-sign-this/).
27 |
28 | ## Slack
29 |
30 | We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, see https://newrelicusers-signup.herokuapp.com/.
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | _**This is repository is no longer maintained. This functionality is in the New Relic Node.js agent as of [8.16.0](https://github.com/newrelic/node-newrelic/releases/tag/v8.16.0). Follow our [docs](https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-nodejs/)**_
2 |
3 |
4 |
5 | # New Relic Node.js logging extensions
6 |
7 | [![npm status badge][5]][6] [![npm status badge][7]][8] [![Log Extensions CI][1]][2] [![codecov][9]][10]
8 |
9 | The New Relic logging plugins are extensions for common Node.js logging frameworks. They are designed to capture app,
10 | transaction trace, and span information as part of your application log messages.
11 |
12 | For the latest information, please see the [New Relic Documentation](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-apm-agents).
13 |
14 | We support:
15 |
16 | * [Winston](packages/winston-log-enricher/README.md)
17 | * [Pino](packages/pino-log-enricher/README.md)
18 |
19 | ## Testing
20 |
21 | This module includes a list of unit and functional tests. To run these tests, use the following command
22 |
23 | ```sh
24 | npm test
25 | ```
26 |
27 | You may also run individual test suites with the following commands
28 |
29 | ```sh
30 | npm run unit # Unit tests
31 | npm run versioned # Functional tests
32 | ```
33 |
34 | ## Support
35 |
36 | New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:
37 |
38 | **Support Channels**
39 |
40 | * [New Relic Documentation](https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/logs-context-nodejs/nodejs-configure-winston): Comprehensive guidance for using our platform
41 | * [New Relic Community](https://forum.newrelic.com/): The best place to engage in troubleshooting questions
42 | * [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
43 | * [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
44 | * **[For Community Plus repositories]** [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
45 |
46 | ## Contribute
47 |
48 | We encourage your contributions to improve New Relic's Node.js logging extensions! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
49 |
50 | If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
51 |
52 | **A note about vulnerabilities**
53 |
54 | As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
55 |
56 | If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
57 |
58 | If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
59 |
60 | To all contributors, we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node.js logging extensions](https://opensource.newrelic.com/projects/newrelic-node-log-extensions).
61 |
62 | ## License
63 | The New Relic Node.js loggin extensions are licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
64 |
65 | [1]: https://github.com/newrelic/newrelic-node-log-extensions/workflows/Log%20Extensions%20CI/badge.svg
66 | [2]: https://github.com/newrelic/newrelic-node-log-extensions/actions
67 | [5]: https://img.shields.io/npm/v/@newrelic/winston-enricher.svg?label=@newrelic/winston-enricher
68 | [6]: https://www.npmjs.com/package/@newrelic/winston-enricher
69 | [7]: https://img.shields.io/npm/v/@newrelic/pino-enricher.svg?label=@newrelic/pino-enricher
70 | [8]: https://www.npmjs.com/package/@newrelic/pino-enricher
71 | [9]: https://codecov.io/gh/newrelic/newrelic-node-log-extensions/branch/main/graph/badge.svg?token=QUFKIFMGO5
72 | [10]: https://codecov.io/gh/newrelic/newrelic-node-log-extensions
73 |
--------------------------------------------------------------------------------
/THIRD_PARTY_NOTICES_FOOTER.md:
--------------------------------------------------------------------------------
1 | -----
2 |
3 | Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,your systems may call externally maintained libraries in addition to those listed above. See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE) for additional details regarding externally maintained libraries and certain related licenses and notices.
--------------------------------------------------------------------------------
/bin/update-third-party-notices.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Checks all staged files for
4 | # package.json. If it changes
5 | # it will re-run `oss third-party manifest`
6 | # and `oss third-party notices` to keep
7 | # these files up to date as deps get updated
8 |
9 | STAGED_FILES=$(git diff-index --cached --name-only HEAD)
10 |
11 | for FILE in $STAGED_FILES
12 | do
13 | if [[ $FILE == *"package.json" ]]; then
14 | echo "- $FILE changed."
15 | RUN_THIRD_PARTY=1
16 | break
17 | fi
18 | done
19 |
20 | if [ -n "$RUN_THIRD_PARTY" ]; then
21 | echo "One or more package.json files changed, running oss manifest and notices"
22 | npm run third-party-updates
23 | fi
24 |
--------------------------------------------------------------------------------
/cla.md:
--------------------------------------------------------------------------------
1 | # NEW RELIC, INC.
2 | ## INDIVIDUAL CONTRIBUTOR LICENSE AGREEMENT
3 | Thank you for your interest in contributing to the open source projects of New Relic, Inc. (“New Relic”). In order to clarify the intellectual property license granted with Contributions from any person or entity, New Relic must have a Contributor License Agreement ("Agreement") on file that has been signed by each Contributor, indicating agreement to the license terms below. This Agreement is for your protection as a Contributor as well as the protection of New Relic; it does not change your rights to use your own Contributions for any other purpose.
4 |
5 | You accept and agree to the following terms and conditions for Your present and future Contributions submitted to New Relic. Except for the licenses granted herein to New Relic and recipients of software distributed by New Relic, You reserve all right, title, and interest in and to Your Contributions.
6 |
7 | ## Definitions.
8 | 1. "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is entering into this Agreement with New Relic. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
9 | 2. "Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to New Relic for inclusion in, or documentation of, any of the products managed or maintained by New Relic (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to New Relic or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, New Relic for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
10 | 3. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to New Relic and to recipients of software distributed by New Relic a perpetual, worldwide, non-exclusive, no-charge, royalty-free, transferable, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
11 | 4. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to New Relic and to recipients of software distributed by New Relic a perpetual, worldwide, non-exclusive, no-charge, royalty-free, transferable, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contributions alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that Your Contribution, or the Work to which You have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
12 | 5. You represent that You are legally entitled to grant the above licenses. If Your employer(s) has rights to intellectual property that You create that includes Your Contributions, You represent that You have received permission to make Contributions on behalf of that employer, that Your employer has waived such rights for Your Contributions to New Relic, or that Your employer has executed a separate Agreement with New Relic.
13 | 6. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which You are personally aware and which are associated with any part of Your Contributions.
14 | 7. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
15 | 8. Should You wish to submit work that is not Your original creation, You may submit it to New Relic separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which You are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
16 | 9. You agree to notify New Relic of any facts or circumstances of which You become aware that would make these representations inaccurate in any respect.
17 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": [
3 | "packages/*"
4 | ],
5 | "version": "independent"
6 | }
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "newrelic-node-log-extensions",
3 | "version": "0.1.0",
4 | "description": "The New Relic logging plugins are extensions for common Node.js logging frameworks",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "lerna run test",
8 | "prepare": "husky install",
9 | "lint": "eslint .",
10 | "lint:fix": "eslint . --fix",
11 | "lint:lockfile": "lerna run lint:lockfile",
12 | "third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json && lerna run third-party-updates",
13 | "unit": "c8 -o ./coverage/unit lerna run unit",
14 | "versioned": "c8 -o ./coverage/versioned lerna run versioned"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/newrelic/newrelic-node-log-extensions.git"
19 | },
20 | "author": "New Relic Node.js Agent Team ",
21 | "license": "Apache-2.0",
22 | "bugs": {
23 | "url": "https://github.com/newrelic/newrelic-node-log-extensions/issues"
24 | },
25 | "homepage": "https://github.com/newrelic/newrelic-node-log-extensions#readme",
26 | "devDependencies": {
27 | "@newrelic/eslint-config": "^0.0.4",
28 | "@newrelic/newrelic-oss-cli": "^0.1.2",
29 | "c8": "^7.12.0",
30 | "eslint": "^7.32.0",
31 | "eslint-plugin-header": "^3.1.1",
32 | "eslint-plugin-node": "^11.1.0",
33 | "eslint-plugin-prettier": "^3.4.0",
34 | "husky": "^7.0.4",
35 | "lerna": "^6.0.0",
36 | "lint-staged": "^12.1.2",
37 | "lockfile-lint": "^4.9.6",
38 | "prettier": "^2.4.1"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | newrelic_agent.log
3 | .coverage_data
4 | cover_html
5 | npm-debug.log
6 | *.key
7 | *.crt
8 | ca-index*
9 | ca-serial*
10 | .DS_Store
11 | .idea
12 | out
13 | .vscode
14 | .nyc_output
15 | test/**/package-lock.json
16 | coverage/
17 |
18 | # Needed for testing
19 | !test/integration/moduleLoading/node_modules
20 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | ## 1.1.1 (12/15/2022)
4 |
5 | * Fixed an issue where logging non-standard error objects under the err key causes APM to throw.
6 |
7 | ## 1.1.0 (10/17/2022)
8 |
9 | * Updated pino-enricher to define agent peer dependency of >=8.13.0 so you can install 9.x of agent to get Node.js 18 support.
10 |
11 | ## 1.0.0 (07/27/2022)
12 |
13 | * **BREAKING** Removed support for Node 12.
14 |
15 | The minimum supported version is now Node v14. For further information on our support policy, see: https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.
16 |
17 | * Added support for Node 18.
18 | * Resolved several dev-dependency audit warnings.
19 |
20 |
21 | ## 0.1.0 (01/04/2022)
22 |
23 | * Initial release of `@newrelic/pino-enricher`.
24 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # @newrelic/pino-enricher
4 |
5 | New Relic's official `pino` log enricher for use with the
6 | [Node Agent](https://github.com/newrelic/node-newrelic).
7 |
8 | The `pino-enricher` log format adds additional app, distributed trace and span information output as JSON-formatted log messages. This is most commonly used with the New Relic Logs product.
9 |
10 | For the latest information, please see [the New Relic docs](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-apm-agents).
11 |
12 | ## Installation
13 |
14 | ```bash
15 | npm install @newrelic/pino-enricher
16 | ```
17 |
18 | ## Usage
19 |
20 | ```js
21 | // index.js
22 | const nrPino = require('@newrelic/pino-enricher')
23 | const pino = require('pino')
24 | const logger = pino(nrPino())
25 | ```
26 |
27 | The New Relic formatter can be used individually or combined with other
28 | formatters as the final format.
29 |
30 | **Note for unhandledException log messages:**
31 |
32 | The stack trace will be written to the `error.stack` property.
33 |
34 | To accommodate the New Relic Logs 4000 character log line limit, the `stack` and `trace` properties will be removed and the `error.message` and `error.stack` values will be truncated to 1024 characters.
35 |
36 | ### Version Requirements
37 |
38 | `pino` versions 7.0.0 and greater are supported.
39 |
40 | For more information, including currently supported Node versions, please see the agent [compatibility and requirements](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent).
41 |
42 | For general agent setup, please see the agent [installation guide](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/install-nodejs-agent).
43 |
44 | ## Support
45 |
46 | New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:
47 |
48 | **Support Channels**
49 |
50 | * [New Relic Documentation](https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/logs-context-nodejs/nodejs-configure-winston): Comprehensive guidance for using our platform
51 | * [New Relic Community](https://forum.newrelic.com/): The best place to engage in troubleshooting questions
52 | * [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
53 | * [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
54 | * **[For Community Plus repositories]** [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
55 |
56 | ## Contribute
57 |
58 | We encourage your contributions to improve New Relic's Node.js logging extensions! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
59 |
60 | If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
61 |
62 | **A note about vulnerabilities**
63 |
64 | As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
65 |
66 | If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
67 |
68 | If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
69 |
70 | To all contributors, we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node.js logging extensions](https://opensource.newrelic.com/projects/newrelic-node-log-extensions).
71 |
72 | ## License
73 | The New Relic Node.js loggin extensions are licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
74 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/THIRD_PARTY_NOTICES.md:
--------------------------------------------------------------------------------
1 | # Third Party Notices
2 |
3 | The New Relic Pino Log Enricher uses source code from third party libraries which carry
4 | their own copyright notices and license terms. These notices are provided
5 | below.
6 |
7 | In the event that a required notice is missing or incorrect, please notify us
8 | by e-mailing [open-source@newrelic.com](mailto:open-source@newrelic.com).
9 |
10 | For any licenses that require the disclosure of source
11 | code, the source code can be found at [https://github.com/newrelic/newrelic-node-pino-logenricher](https://github.com/newrelic/newrelic-node-pino-logenricher).
12 |
13 | ## Content
14 |
15 | **[dependencies](#dependencies)**
16 |
17 |
18 | **[devDependencies](#devDependencies)**
19 |
20 | * [@newrelic/test-utilities](#newrelictest-utilities)
21 | * [flush-write-stream](#flush-write-stream)
22 | * [newrelic](#newrelic)
23 | * [split2](#split2)
24 | * [tap](#tap)
25 |
26 |
27 | ## dependencies
28 |
29 |
30 | ## devDependencies
31 |
32 | ### @newrelic/test-utilities
33 |
34 | This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.3.2](https://github.com/newrelic/node-test-utilities/tree/v7.3.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v7.3.2/LICENSE):
35 |
36 | ```
37 | Apache License
38 | Version 2.0, January 2004
39 | http://www.apache.org/licenses/
40 |
41 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
42 |
43 | 1. Definitions.
44 |
45 | "License" shall mean the terms and conditions for use, reproduction,
46 | and distribution as defined by Sections 1 through 9 of this document.
47 |
48 | "Licensor" shall mean the copyright owner or entity authorized by
49 | the copyright owner that is granting the License.
50 |
51 | "Legal Entity" shall mean the union of the acting entity and all
52 | other entities that control, are controlled by, or are under common
53 | control with that entity. For the purposes of this definition,
54 | "control" means (i) the power, direct or indirect, to cause the
55 | direction or management of such entity, whether by contract or
56 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
57 | outstanding shares, or (iii) beneficial ownership of such entity.
58 |
59 | "You" (or "Your") shall mean an individual or Legal Entity
60 | exercising permissions granted by this License.
61 |
62 | "Source" form shall mean the preferred form for making modifications,
63 | including but not limited to software source code, documentation
64 | source, and configuration files.
65 |
66 | "Object" form shall mean any form resulting from mechanical
67 | transformation or translation of a Source form, including but
68 | not limited to compiled object code, generated documentation,
69 | and conversions to other media types.
70 |
71 | "Work" shall mean the work of authorship, whether in Source or
72 | Object form, made available under the License, as indicated by a
73 | copyright notice that is included in or attached to the work
74 | (an example is provided in the Appendix below).
75 |
76 | "Derivative Works" shall mean any work, whether in Source or Object
77 | form, that is based on (or derived from) the Work and for which the
78 | editorial revisions, annotations, elaborations, or other modifications
79 | represent, as a whole, an original work of authorship. For the purposes
80 | of this License, Derivative Works shall not include works that remain
81 | separable from, or merely link (or bind by name) to the interfaces of,
82 | the Work and Derivative Works thereof.
83 |
84 | "Contribution" shall mean any work of authorship, including
85 | the original version of the Work and any modifications or additions
86 | to that Work or Derivative Works thereof, that is intentionally
87 | submitted to Licensor for inclusion in the Work by the copyright owner
88 | or by an individual or Legal Entity authorized to submit on behalf of
89 | the copyright owner. For the purposes of this definition, "submitted"
90 | means any form of electronic, verbal, or written communication sent
91 | to the Licensor or its representatives, including but not limited to
92 | communication on electronic mailing lists, source code control systems,
93 | and issue tracking systems that are managed by, or on behalf of, the
94 | Licensor for the purpose of discussing and improving the Work, but
95 | excluding communication that is conspicuously marked or otherwise
96 | designated in writing by the copyright owner as "Not a Contribution."
97 |
98 | "Contributor" shall mean Licensor and any individual or Legal Entity
99 | on behalf of whom a Contribution has been received by Licensor and
100 | subsequently incorporated within the Work.
101 |
102 | 2. Grant of Copyright License. Subject to the terms and conditions of
103 | this License, each Contributor hereby grants to You a perpetual,
104 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
105 | copyright license to reproduce, prepare Derivative Works of,
106 | publicly display, publicly perform, sublicense, and distribute the
107 | Work and such Derivative Works in Source or Object form.
108 |
109 | 3. Grant of Patent License. Subject to the terms and conditions of
110 | this License, each Contributor hereby grants to You a perpetual,
111 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
112 | (except as stated in this section) patent license to make, have made,
113 | use, offer to sell, sell, import, and otherwise transfer the Work,
114 | where such license applies only to those patent claims licensable
115 | by such Contributor that are necessarily infringed by their
116 | Contribution(s) alone or by combination of their Contribution(s)
117 | with the Work to which such Contribution(s) was submitted. If You
118 | institute patent litigation against any entity (including a
119 | cross-claim or counterclaim in a lawsuit) alleging that the Work
120 | or a Contribution incorporated within the Work constitutes direct
121 | or contributory patent infringement, then any patent licenses
122 | granted to You under this License for that Work shall terminate
123 | as of the date such litigation is filed.
124 |
125 | 4. Redistribution. You may reproduce and distribute copies of the
126 | Work or Derivative Works thereof in any medium, with or without
127 | modifications, and in Source or Object form, provided that You
128 | meet the following conditions:
129 |
130 | (a) You must give any other recipients of the Work or
131 | Derivative Works a copy of this License; and
132 |
133 | (b) You must cause any modified files to carry prominent notices
134 | stating that You changed the files; and
135 |
136 | (c) You must retain, in the Source form of any Derivative Works
137 | that You distribute, all copyright, patent, trademark, and
138 | attribution notices from the Source form of the Work,
139 | excluding those notices that do not pertain to any part of
140 | the Derivative Works; and
141 |
142 | (d) If the Work includes a "NOTICE" text file as part of its
143 | distribution, then any Derivative Works that You distribute must
144 | include a readable copy of the attribution notices contained
145 | within such NOTICE file, excluding those notices that do not
146 | pertain to any part of the Derivative Works, in at least one
147 | of the following places: within a NOTICE text file distributed
148 | as part of the Derivative Works; within the Source form or
149 | documentation, if provided along with the Derivative Works; or,
150 | within a display generated by the Derivative Works, if and
151 | wherever such third-party notices normally appear. The contents
152 | of the NOTICE file are for informational purposes only and
153 | do not modify the License. You may add Your own attribution
154 | notices within Derivative Works that You distribute, alongside
155 | or as an addendum to the NOTICE text from the Work, provided
156 | that such additional attribution notices cannot be construed
157 | as modifying the License.
158 |
159 | You may add Your own copyright statement to Your modifications and
160 | may provide additional or different license terms and conditions
161 | for use, reproduction, or distribution of Your modifications, or
162 | for any such Derivative Works as a whole, provided Your use,
163 | reproduction, and distribution of the Work otherwise complies with
164 | the conditions stated in this License.
165 |
166 | 5. Submission of Contributions. Unless You explicitly state otherwise,
167 | any Contribution intentionally submitted for inclusion in the Work
168 | by You to the Licensor shall be under the terms and conditions of
169 | this License, without any additional terms or conditions.
170 | Notwithstanding the above, nothing herein shall supersede or modify
171 | the terms of any separate license agreement you may have executed
172 | with Licensor regarding such Contributions.
173 |
174 | 6. Trademarks. This License does not grant permission to use the trade
175 | names, trademarks, service marks, or product names of the Licensor,
176 | except as required for reasonable and customary use in describing the
177 | origin of the Work and reproducing the content of the NOTICE file.
178 |
179 | 7. Disclaimer of Warranty. Unless required by applicable law or
180 | agreed to in writing, Licensor provides the Work (and each
181 | Contributor provides its Contributions) on an "AS IS" BASIS,
182 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
183 | implied, including, without limitation, any warranties or conditions
184 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
185 | PARTICULAR PURPOSE. You are solely responsible for determining the
186 | appropriateness of using or redistributing the Work and assume any
187 | risks associated with Your exercise of permissions under this License.
188 |
189 | 8. Limitation of Liability. In no event and under no legal theory,
190 | whether in tort (including negligence), contract, or otherwise,
191 | unless required by applicable law (such as deliberate and grossly
192 | negligent acts) or agreed to in writing, shall any Contributor be
193 | liable to You for damages, including any direct, indirect, special,
194 | incidental, or consequential damages of any character arising as a
195 | result of this License or out of the use or inability to use the
196 | Work (including but not limited to damages for loss of goodwill,
197 | work stoppage, computer failure or malfunction, or any and all
198 | other commercial damages or losses), even if such Contributor
199 | has been advised of the possibility of such damages.
200 |
201 | 9. Accepting Warranty or Additional Liability. While redistributing
202 | the Work or Derivative Works thereof, You may choose to offer,
203 | and charge a fee for, acceptance of support, warranty, indemnity,
204 | or other liability obligations and/or rights consistent with this
205 | License. However, in accepting such obligations, You may act only
206 | on Your own behalf and on Your sole responsibility, not on behalf
207 | of any other Contributor, and only if You agree to indemnify,
208 | defend, and hold each Contributor harmless for any liability
209 | incurred by, or claims asserted against, such Contributor by reason
210 | of your accepting any such warranty or additional liability.
211 |
212 | END OF TERMS AND CONDITIONS
213 |
214 | APPENDIX: How to apply the Apache License to your work.
215 |
216 | To apply the Apache License to your work, attach the following
217 | boilerplate notice, with the fields enclosed by brackets "[]"
218 | replaced with your own identifying information. (Don't include
219 | the brackets!) The text should be enclosed in the appropriate
220 | comment syntax for the file format. We also recommend that a
221 | file or class name and description of purpose be included on the
222 | same "printed page" as the copyright notice for easier
223 | identification within third-party archives.
224 |
225 | Copyright [yyyy] [name of copyright owner]
226 |
227 | Licensed under the Apache License, Version 2.0 (the "License");
228 | you may not use this file except in compliance with the License.
229 | You may obtain a copy of the License at
230 |
231 | http://www.apache.org/licenses/LICENSE-2.0
232 |
233 | Unless required by applicable law or agreed to in writing, software
234 | distributed under the License is distributed on an "AS IS" BASIS,
235 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
236 | See the License for the specific language governing permissions and
237 | limitations under the License.
238 |
239 | ```
240 |
241 | ### flush-write-stream
242 |
243 | This product includes source derived from [flush-write-stream](https://github.com/mafintosh/flush-write-stream) ([v2.0.0](https://github.com/mafintosh/flush-write-stream/tree/v2.0.0)), distributed under the [MIT License](https://github.com/mafintosh/flush-write-stream/blob/v2.0.0/LICENSE):
244 |
245 | ```
246 | The MIT License (MIT)
247 |
248 | Copyright (c) 2015 Mathias Buus
249 |
250 | Permission is hereby granted, free of charge, to any person obtaining a copy
251 | of this software and associated documentation files (the "Software"), to deal
252 | in the Software without restriction, including without limitation the rights
253 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
254 | copies of the Software, and to permit persons to whom the Software is
255 | furnished to do so, subject to the following conditions:
256 |
257 | The above copyright notice and this permission notice shall be included in
258 | all copies or substantial portions of the Software.
259 |
260 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
261 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
262 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
263 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
264 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
265 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
266 | THE SOFTWARE.
267 |
268 | ```
269 |
270 | ### newrelic
271 |
272 | This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v10.3.2](https://github.com/newrelic/node-newrelic/tree/v10.3.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v10.3.2/LICENSE):
273 |
274 | ```
275 | Apache License
276 | Version 2.0, January 2004
277 | http://www.apache.org/licenses/
278 |
279 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
280 |
281 | 1. Definitions.
282 |
283 | "License" shall mean the terms and conditions for use, reproduction,
284 | and distribution as defined by Sections 1 through 9 of this document.
285 |
286 | "Licensor" shall mean the copyright owner or entity authorized by
287 | the copyright owner that is granting the License.
288 |
289 | "Legal Entity" shall mean the union of the acting entity and all
290 | other entities that control, are controlled by, or are under common
291 | control with that entity. For the purposes of this definition,
292 | "control" means (i) the power, direct or indirect, to cause the
293 | direction or management of such entity, whether by contract or
294 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
295 | outstanding shares, or (iii) beneficial ownership of such entity.
296 |
297 | "You" (or "Your") shall mean an individual or Legal Entity
298 | exercising permissions granted by this License.
299 |
300 | "Source" form shall mean the preferred form for making modifications,
301 | including but not limited to software source code, documentation
302 | source, and configuration files.
303 |
304 | "Object" form shall mean any form resulting from mechanical
305 | transformation or translation of a Source form, including but
306 | not limited to compiled object code, generated documentation,
307 | and conversions to other media types.
308 |
309 | "Work" shall mean the work of authorship, whether in Source or
310 | Object form, made available under the License, as indicated by a
311 | copyright notice that is included in or attached to the work
312 | (an example is provided in the Appendix below).
313 |
314 | "Derivative Works" shall mean any work, whether in Source or Object
315 | form, that is based on (or derived from) the Work and for which the
316 | editorial revisions, annotations, elaborations, or other modifications
317 | represent, as a whole, an original work of authorship. For the purposes
318 | of this License, Derivative Works shall not include works that remain
319 | separable from, or merely link (or bind by name) to the interfaces of,
320 | the Work and Derivative Works thereof.
321 |
322 | "Contribution" shall mean any work of authorship, including
323 | the original version of the Work and any modifications or additions
324 | to that Work or Derivative Works thereof, that is intentionally
325 | submitted to Licensor for inclusion in the Work by the copyright owner
326 | or by an individual or Legal Entity authorized to submit on behalf of
327 | the copyright owner. For the purposes of this definition, "submitted"
328 | means any form of electronic, verbal, or written communication sent
329 | to the Licensor or its representatives, including but not limited to
330 | communication on electronic mailing lists, source code control systems,
331 | and issue tracking systems that are managed by, or on behalf of, the
332 | Licensor for the purpose of discussing and improving the Work, but
333 | excluding communication that is conspicuously marked or otherwise
334 | designated in writing by the copyright owner as "Not a Contribution."
335 |
336 | "Contributor" shall mean Licensor and any individual or Legal Entity
337 | on behalf of whom a Contribution has been received by Licensor and
338 | subsequently incorporated within the Work.
339 |
340 | 2. Grant of Copyright License. Subject to the terms and conditions of
341 | this License, each Contributor hereby grants to You a perpetual,
342 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
343 | copyright license to reproduce, prepare Derivative Works of,
344 | publicly display, publicly perform, sublicense, and distribute the
345 | Work and such Derivative Works in Source or Object form.
346 |
347 | 3. Grant of Patent License. Subject to the terms and conditions of
348 | this License, each Contributor hereby grants to You a perpetual,
349 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
350 | (except as stated in this section) patent license to make, have made,
351 | use, offer to sell, sell, import, and otherwise transfer the Work,
352 | where such license applies only to those patent claims licensable
353 | by such Contributor that are necessarily infringed by their
354 | Contribution(s) alone or by combination of their Contribution(s)
355 | with the Work to which such Contribution(s) was submitted. If You
356 | institute patent litigation against any entity (including a
357 | cross-claim or counterclaim in a lawsuit) alleging that the Work
358 | or a Contribution incorporated within the Work constitutes direct
359 | or contributory patent infringement, then any patent licenses
360 | granted to You under this License for that Work shall terminate
361 | as of the date such litigation is filed.
362 |
363 | 4. Redistribution. You may reproduce and distribute copies of the
364 | Work or Derivative Works thereof in any medium, with or without
365 | modifications, and in Source or Object form, provided that You
366 | meet the following conditions:
367 |
368 | (a) You must give any other recipients of the Work or
369 | Derivative Works a copy of this License; and
370 |
371 | (b) You must cause any modified files to carry prominent notices
372 | stating that You changed the files; and
373 |
374 | (c) You must retain, in the Source form of any Derivative Works
375 | that You distribute, all copyright, patent, trademark, and
376 | attribution notices from the Source form of the Work,
377 | excluding those notices that do not pertain to any part of
378 | the Derivative Works; and
379 |
380 | (d) If the Work includes a "NOTICE" text file as part of its
381 | distribution, then any Derivative Works that You distribute must
382 | include a readable copy of the attribution notices contained
383 | within such NOTICE file, excluding those notices that do not
384 | pertain to any part of the Derivative Works, in at least one
385 | of the following places: within a NOTICE text file distributed
386 | as part of the Derivative Works; within the Source form or
387 | documentation, if provided along with the Derivative Works; or,
388 | within a display generated by the Derivative Works, if and
389 | wherever such third-party notices normally appear. The contents
390 | of the NOTICE file are for informational purposes only and
391 | do not modify the License. You may add Your own attribution
392 | notices within Derivative Works that You distribute, alongside
393 | or as an addendum to the NOTICE text from the Work, provided
394 | that such additional attribution notices cannot be construed
395 | as modifying the License.
396 |
397 | You may add Your own copyright statement to Your modifications and
398 | may provide additional or different license terms and conditions
399 | for use, reproduction, or distribution of Your modifications, or
400 | for any such Derivative Works as a whole, provided Your use,
401 | reproduction, and distribution of the Work otherwise complies with
402 | the conditions stated in this License.
403 |
404 | 5. Submission of Contributions. Unless You explicitly state otherwise,
405 | any Contribution intentionally submitted for inclusion in the Work
406 | by You to the Licensor shall be under the terms and conditions of
407 | this License, without any additional terms or conditions.
408 | Notwithstanding the above, nothing herein shall supersede or modify
409 | the terms of any separate license agreement you may have executed
410 | with Licensor regarding such Contributions.
411 |
412 | 6. Trademarks. This License does not grant permission to use the trade
413 | names, trademarks, service marks, or product names of the Licensor,
414 | except as required for reasonable and customary use in describing the
415 | origin of the Work and reproducing the content of the NOTICE file.
416 |
417 | 7. Disclaimer of Warranty. Unless required by applicable law or
418 | agreed to in writing, Licensor provides the Work (and each
419 | Contributor provides its Contributions) on an "AS IS" BASIS,
420 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
421 | implied, including, without limitation, any warranties or conditions
422 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
423 | PARTICULAR PURPOSE. You are solely responsible for determining the
424 | appropriateness of using or redistributing the Work and assume any
425 | risks associated with Your exercise of permissions under this License.
426 |
427 | 8. Limitation of Liability. In no event and under no legal theory,
428 | whether in tort (including negligence), contract, or otherwise,
429 | unless required by applicable law (such as deliberate and grossly
430 | negligent acts) or agreed to in writing, shall any Contributor be
431 | liable to You for damages, including any direct, indirect, special,
432 | incidental, or consequential damages of any character arising as a
433 | result of this License or out of the use or inability to use the
434 | Work (including but not limited to damages for loss of goodwill,
435 | work stoppage, computer failure or malfunction, or any and all
436 | other commercial damages or losses), even if such Contributor
437 | has been advised of the possibility of such damages.
438 |
439 | 9. Accepting Warranty or Additional Liability. While redistributing
440 | the Work or Derivative Works thereof, You may choose to offer,
441 | and charge a fee for, acceptance of support, warranty, indemnity,
442 | or other liability obligations and/or rights consistent with this
443 | License. However, in accepting such obligations, You may act only
444 | on Your own behalf and on Your sole responsibility, not on behalf
445 | of any other Contributor, and only if You agree to indemnify,
446 | defend, and hold each Contributor harmless for any liability
447 | incurred by, or claims asserted against, such Contributor by reason
448 | of your accepting any such warranty or additional liability.
449 |
450 | END OF TERMS AND CONDITIONS
451 |
452 | APPENDIX: How to apply the Apache License to your work.
453 |
454 | To apply the Apache License to your work, attach the following
455 | boilerplate notice, with the fields enclosed by brackets "[]"
456 | replaced with your own identifying information. (Don't include
457 | the brackets!) The text should be enclosed in the appropriate
458 | comment syntax for the file format. We also recommend that a
459 | file or class name and description of purpose be included on the
460 | same "printed page" as the copyright notice for easier
461 | identification within third-party archives.
462 |
463 | Copyright [yyyy] [name of copyright owner]
464 |
465 | Licensed under the Apache License, Version 2.0 (the "License");
466 | you may not use this file except in compliance with the License.
467 | You may obtain a copy of the License at
468 |
469 | http://www.apache.org/licenses/LICENSE-2.0
470 |
471 | Unless required by applicable law or agreed to in writing, software
472 | distributed under the License is distributed on an "AS IS" BASIS,
473 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
474 | See the License for the specific language governing permissions and
475 | limitations under the License.
476 | ```
477 |
478 | ### split2
479 |
480 | This product includes source derived from [split2](https://github.com/mcollina/split2) ([v4.1.0](https://github.com/mcollina/split2/tree/v4.1.0)), distributed under the [ISC License](https://github.com/mcollina/split2/blob/v4.1.0/LICENSE):
481 |
482 | ```
483 | Copyright (c) 2014-2018, Matteo Collina
484 |
485 | Permission to use, copy, modify, and/or distribute this software for any
486 | purpose with or without fee is hereby granted, provided that the above
487 | copyright notice and this permission notice appear in all copies.
488 |
489 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
490 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
491 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
492 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
493 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
494 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
495 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
496 |
497 | ```
498 |
499 | ### tap
500 |
501 | This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.2](https://github.com/tapjs/node-tap/tree/v16.3.2)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.2/LICENSE):
502 |
503 | ```
504 | The ISC License
505 |
506 | Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
507 |
508 | Permission to use, copy, modify, and/or distribute this software for any
509 | purpose with or without fee is hereby granted, provided that the above
510 | copyright notice and this permission notice appear in all copies.
511 |
512 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
513 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
514 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
515 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
516 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
517 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
518 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
519 |
520 | ```
521 |
522 |
523 | -----
524 |
525 | Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,your systems may call externally maintained libraries in addition to those listed above. See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE) for additional details regarding externally maintained libraries and certain related licenses and notices.
526 |
527 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/THIRD_PARTY_NOTICES_FOOTER.md:
--------------------------------------------------------------------------------
1 | -----
2 |
3 | Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,your systems may call externally maintained libraries in addition to those listed above. See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE) for additional details regarding externally maintained libraries and certain related licenses and notices.
4 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/bin/update-third-party-notices.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Checks all staged files for
4 | # package.json. If it changes
5 | # it will re-run `oss third-party manifest`
6 | # and `oss third-party notices` to keep
7 | # these files up to date as deps get updated
8 |
9 | STAGED_FILES=$(git diff-index --cached --name-only HEAD)
10 |
11 | for FILE in $STAGED_FILES
12 | do
13 | if [ $FILE == "package.json" ]; then
14 | RUN_THIRD_PARTY=1
15 | break
16 | fi
17 | done
18 |
19 | if [ -n "$RUN_THIRD_PARTY" ]; then
20 | echo "package.json changed, running oss manifest and notices"
21 | npm run third-party-updates
22 | fi
23 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | /**
9 | * Allows users to `require('@newrelic/pino-enricher')` directly in their app. If
10 | * they for some reason choose to explicitly use an older version of our
11 | * instrumentation then the supportability metrics for custom instrumentation
12 | * will trigger.
13 | */
14 | const newrelic = require('newrelic')
15 | const createFormatter = require('./lib/createFormatter')
16 | module.exports = createFormatter.bind(null, newrelic)
17 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/lib/createFormatter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 | const truncate = require('./truncate')
8 |
9 | /**
10 | * Returns a series of formatters/mixins to enrich
11 | * logs to work with New Relic logs
12 | *
13 | * @param {Object} newrelic
14 | */
15 | module.exports = function createFormatter(newrelic) {
16 | // Stub API means agent is not enabled.
17 | if (!newrelic.shim) {
18 | // Continue to log original message with JSON formatter
19 | return {}
20 | }
21 |
22 | createModuleUsageMetric(newrelic.shim.agent)
23 |
24 | // Using pino API to modify log lines
25 | // https://github.com/pinojs/pino/blob/master/docs/api.md#level
26 | return {
27 | timestamp: () => `,"timestamp": "${Date.now()}"`,
28 | messageKey: 'message',
29 | mixin() {
30 | return newrelic.getLinkingMetadata(true)
31 | },
32 | formatters: {
33 | log(obj) {
34 | if (obj.err) {
35 | obj['error.message'] = truncate(obj.err.message)
36 | obj['error.stack'] = truncate(obj.err.stack)
37 | obj['error.class'] = obj.err.name === 'Error' ? obj.err.constructor.name : obj.err.name
38 | delete obj.err
39 | }
40 | return obj
41 | }
42 | }
43 | }
44 | }
45 |
46 | /**
47 | * Adds a supportability metric to track customers
48 | * using the Pino log enricher
49 | *
50 | * @param {Agent} agent New Relic agent
51 | */
52 | function createModuleUsageMetric(agent) {
53 | agent.metrics
54 | .getOrCreateMetric('Supportability/ExternalModules/PinoLogEnricher')
55 | .incrementCallCount()
56 | }
57 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/lib/truncate.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const OUTPUT_LENGTH = 1024
9 | const MAX_LENGTH = 1021
10 |
11 | const truncate = (str) => {
12 | if (typeof str === 'string' && str.length > OUTPUT_LENGTH) {
13 | return str.substring(0, MAX_LENGTH) + '...'
14 | }
15 |
16 | return str
17 | }
18 |
19 | module.exports = truncate
20 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@newrelic/pino-enricher",
3 | "version": "1.1.1",
4 | "description": "New Relic log encricher for the `pino` package. Allows `pino` logs to be consumed by New Relic Logs.",
5 | "main": "index.js",
6 | "scripts": {
7 | "unit": "tap tests/unit/**/*.tap.js --no-coverage",
8 | "test": "npm run unit && npm run versioned",
9 | "lint": "eslint *.js lib tests",
10 | "lint:fix": "eslint --fix *.js lib tests",
11 | "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
12 | "third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json",
13 | "versioned": "versioned-tests --minor --all -i 2 tests/versioned/*.tap.js"
14 | },
15 | "author": "New Relic Node.js Agent Team ",
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/newrelic/newrelic-node-log-extensions.git"
19 | },
20 | "license": "Apache-2.0",
21 | "bugs": {
22 | "url": "https://github.com/newrelic/newrelic-node-log-extensions/issues"
23 | },
24 | "homepage": "https://github.com/newrelic/newrelic-node-log-extensions#readme",
25 | "peerDependencies": {
26 | "newrelic": ">=8.13.0"
27 | },
28 | "devDependencies": {
29 | "@newrelic/test-utilities": "^7.3.2",
30 | "flush-write-stream": "^2.0.0",
31 | "newrelic": "^10.3.2",
32 | "split2": "^4.1.0",
33 | "tap": "^16.0.1"
34 | },
35 | "engines": {
36 | "node": ">=14.0"
37 | },
38 | "files": [
39 | "lib/**",
40 | "index.js"
41 | ]
42 | }
43 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/tests/unit/messageTruncate.tap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const tap = require('tap')
9 | const truncate = require('../../lib/truncate')
10 |
11 | tap.test('Should truncate string > 1024 chars', (t) => {
12 | const longString =
13 | '1111111111111111111111111111111111111111111111111111111111111111' +
14 | '1111111111111111111111111111111111111111111111111111111111111111' +
15 | '1111111111111111111111111111111111111111111111111111111111111111' +
16 | '1111111111111111111111111111111111111111111111111111111111111111' +
17 | '1111111111111111111111111111111111111111111111111111111111111111' +
18 | '1111111111111111111111111111111111111111111111111111111111111111' +
19 | '1111111111111111111111111111111111111111111111111111111111111111' +
20 | '1111111111111111111111111111111111111111111111111111111111111111' +
21 | '1111111111111111111111111111111111111111111111111111111111111111' +
22 | '1111111111111111111111111111111111111111111111111111111111111111' +
23 | '1111111111111111111111111111111111111111111111111111111111111111' +
24 | '1111111111111111111111111111111111111111111111111111111111111111' +
25 | '1111111111111111111111111111111111111111111111111111111111111111' +
26 | '1111111111111111111111111111111111111111111111111111111111111111' +
27 | '1111111111111111111111111111111111111111111111111111111111111111' +
28 | '1111111111111111111111111111111111111111111111111111111111111111' +
29 | '1111111111111111111111111111111111111111111111111111111111111111' +
30 | '1111111111111111111111111111111111111111111111111111111111111111'
31 |
32 | const processedStr = truncate(longString)
33 |
34 | t.equal(processedStr.length, 1024)
35 | t.equal(processedStr.substring(processedStr.length - 3), '...')
36 |
37 | t.end()
38 | })
39 |
40 | tap.test('Should return non-truncated string when <= 1024 chars', (t) => {
41 | const str = 'kenny loggins'
42 |
43 | const processedStr = truncate(str)
44 |
45 | t.equal(processedStr, str)
46 | t.end()
47 | })
48 | ;[
49 | { value: '', type: 'empty string' },
50 | { value: undefined, type: 'undefined' },
51 | { value: null, type: 'null' },
52 | { value: {}, type: 'object' },
53 | { value: [], type: 'array' },
54 | { value: function () {}, type: 'function' }
55 | ].forEach(({ value, type }) => {
56 | tap.test(`should not truncate ${type}`, (t) => {
57 | const newValue = truncate(value)
58 | t.same(value, newValue)
59 | t.end()
60 | })
61 | })
62 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/tests/versioned/newrelic.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | exports.config = {
9 | app_name: ['My Application'],
10 | license_key: 'license key here',
11 | logging: {
12 | level: 'trace',
13 | filepath: '../../newrelic_agent.log'
14 | },
15 | utilization: {
16 | detect_aws: false,
17 | detect_pcf: false,
18 | detect_azure: false,
19 | detect_gcp: false,
20 | detect_docker: false
21 | },
22 | distributed_tracing: {
23 | enabled: true
24 | },
25 | transaction_tracer: {
26 | enabled: true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/tests/versioned/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pino-tests",
3 | "version": "0.0.0",
4 | "private": true,
5 | "tests": [
6 | {
7 | "engines": {
8 | "node": ">=14"
9 | },
10 | "dependencies": {
11 | "pino": ">=7.0.0"
12 | },
13 | "files": [
14 | "pino.tap.js"
15 | ]
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/tests/versioned/pino.tap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const tap = require('tap')
9 | const utils = require('@newrelic/test-utilities')
10 | const formatFactory = require('../../lib/createFormatter')
11 | const { sink, once } = require('pino/test/helper')
12 | const API = require('newrelic/api')
13 | const truncate = require('../../lib/truncate')
14 |
15 | tap.Test.prototype.addAssert(
16 | 'validateAnnotations',
17 | 2,
18 | function assertCoreAnnotations(logLine, config) {
19 | this.equal(
20 | logLine['entity.name'],
21 | config.applications()[0],
22 | 'should have entity name that matches app'
23 | )
24 | this.equal(logLine['entity.type'], 'SERVICE', 'should have entity type of SERVICE')
25 | this.equal(logLine.hostname, config.getHostnameSafe(), 'should have proper hostname')
26 | this.match(logLine.timestamp, /[0-9]{10}/, 'should have proper unix timestamp')
27 | }
28 | )
29 |
30 | tap.test('Pino instrumentation', (t) => {
31 | t.autoend()
32 | let logger
33 | let config
34 | let helper
35 | let stream
36 | let api
37 | let pino
38 |
39 | t.beforeEach(() => {
40 | helper = utils.TestAgent.makeInstrumented()
41 | pino = require('pino')
42 | api = new API(helper.agent)
43 | stream = sink()
44 | logger = pino(formatFactory(api), stream)
45 | config = helper.agent.config
46 | })
47 |
48 | t.afterEach(() => {
49 | helper.unload()
50 | })
51 |
52 | t.test('should have proper metadata outside of a transaction', async (t) => {
53 | const message = 'pino unit test'
54 | logger.info(message)
55 | const line = await once(stream, 'data')
56 | t.validateAnnotations(line, config)
57 | t.equal(line.message, message, 'should have proper message key/value')
58 | t.end()
59 | })
60 |
61 | t.test('should have proper error keys when error is present', async (t) => {
62 | const err = new Error('This is a test')
63 | logger.error(err)
64 | const line = await once(stream, 'data')
65 | t.validateAnnotations(line, config)
66 | t.equal(line['error.class'], 'Error', 'should have Error as error.class')
67 | t.equal(line['error.message'], err.message, 'should have proper error.message')
68 | t.equal(line['error.stack'], truncate(err.stack), 'should have proper error.stack')
69 | t.notOk(line.err, 'should not have err key')
70 | t.equal(line.message, err.message, 'should have proper messsage')
71 | t.end()
72 | })
73 |
74 | t.test('should add proper trace info in transaction', (t) => {
75 | helper.runInTransaction('pino-test', async () => {
76 | logger.info('My debug test')
77 | const meta = api.getLinkingMetadata()
78 | const line = await once(stream, 'data')
79 | t.validateAnnotations(line, config)
80 | t.equal(line['trace.id'], meta['trace.id'])
81 | t.equal(line['span.id'], meta['span.id'])
82 | t.end()
83 | })
84 | })
85 |
86 | t.test('should still log user data when agent is disabled', async (t) => {
87 | const disabledLogger = pino(formatFactory({}), stream)
88 | const message = 'logs are not enriched'
89 | disabledLogger.info(message)
90 | const line = await once(stream, 'data')
91 | t.equal(line.msg, message)
92 | t.match(line.time, /[0-9]{10}/)
93 | t.notOk(line['entity.type'])
94 | t.end()
95 | })
96 | })
97 |
--------------------------------------------------------------------------------
/packages/pino-log-enricher/third_party_manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "lastUpdated": "Tue Jul 11 2023 15:54:24 GMT-0400 (Eastern Daylight Time)",
3 | "projectName": "New Relic Pino Log Enricher",
4 | "projectUrl": "https://github.com/newrelic/newrelic-node-pino-logenricher",
5 | "includeOptDeps": false,
6 | "includeDev": true,
7 | "dependencies": {},
8 | "devDependencies": {
9 | "@newrelic/test-utilities@7.3.2": {
10 | "name": "@newrelic/test-utilities",
11 | "version": "7.3.2",
12 | "range": "^7.3.2",
13 | "licenses": "Apache-2.0",
14 | "repoUrl": "https://github.com/newrelic/node-test-utilities",
15 | "versionedRepoUrl": "https://github.com/newrelic/node-test-utilities/tree/v7.3.2",
16 | "licenseFile": "node_modules/@newrelic/test-utilities/LICENSE",
17 | "licenseUrl": "https://github.com/newrelic/node-test-utilities/blob/v7.3.2/LICENSE",
18 | "licenseTextSource": "file",
19 | "publisher": "New Relic Node.js agent team",
20 | "email": "nodejs@newrelic.com"
21 | },
22 | "flush-write-stream@2.0.0": {
23 | "name": "flush-write-stream",
24 | "version": "2.0.0",
25 | "range": "^2.0.0",
26 | "licenses": "MIT",
27 | "repoUrl": "https://github.com/mafintosh/flush-write-stream",
28 | "versionedRepoUrl": "https://github.com/mafintosh/flush-write-stream/tree/v2.0.0",
29 | "licenseFile": "node_modules/flush-write-stream/LICENSE",
30 | "licenseUrl": "https://github.com/mafintosh/flush-write-stream/blob/v2.0.0/LICENSE",
31 | "licenseTextSource": "file",
32 | "publisher": "Mathias Buus",
33 | "url": "@mafintosh"
34 | },
35 | "newrelic@10.3.2": {
36 | "name": "newrelic",
37 | "version": "10.3.2",
38 | "range": "^10.3.2",
39 | "licenses": "Apache-2.0",
40 | "repoUrl": "https://github.com/newrelic/node-newrelic",
41 | "versionedRepoUrl": "https://github.com/newrelic/node-newrelic/tree/v10.3.2",
42 | "licenseFile": "node_modules/newrelic/LICENSE",
43 | "licenseUrl": "https://github.com/newrelic/node-newrelic/blob/v10.3.2/LICENSE",
44 | "licenseTextSource": "file",
45 | "publisher": "New Relic Node.js agent team",
46 | "email": "nodejs@newrelic.com"
47 | },
48 | "split2@4.1.0": {
49 | "name": "split2",
50 | "version": "4.1.0",
51 | "range": "^4.1.0",
52 | "licenses": "ISC",
53 | "repoUrl": "https://github.com/mcollina/split2",
54 | "versionedRepoUrl": "https://github.com/mcollina/split2/tree/v4.1.0",
55 | "licenseFile": "node_modules/split2/LICENSE",
56 | "licenseUrl": "https://github.com/mcollina/split2/blob/v4.1.0/LICENSE",
57 | "licenseTextSource": "file",
58 | "publisher": "Matteo Collina",
59 | "email": "hello@matteocollina.com"
60 | },
61 | "tap@16.3.2": {
62 | "name": "tap",
63 | "version": "16.3.2",
64 | "range": "^16.0.1",
65 | "licenses": "ISC",
66 | "repoUrl": "https://github.com/tapjs/node-tap",
67 | "versionedRepoUrl": "https://github.com/tapjs/node-tap/tree/v16.3.2",
68 | "licenseFile": "node_modules/tap/LICENSE",
69 | "licenseUrl": "https://github.com/tapjs/node-tap/blob/v16.3.2/LICENSE",
70 | "licenseTextSource": "file",
71 | "publisher": "Isaac Z. Schlueter",
72 | "email": "i@izs.me",
73 | "url": "http://blog.izs.me"
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Bug report \U0001F41B"
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug, needs-triage
6 | assignees: ''
7 |
8 | ---
9 |
10 | [NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )
11 |
12 | ## Description
13 |
14 | [NOTE]: # ( Describe the problem you're encountering. )
15 | [TIP]: # ( Do NOT share sensitive information, whether personal, proprietary, or otherwise! )
16 |
17 | ## Expected Behavior
18 |
19 | [NOTE]: # ( Tell us what you expected to happen. )
20 |
21 | ## [Troubleshooting](https://discuss.newrelic.com/t/troubleshooting-frameworks/108787) or [NR Diag](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/troubleshooting/new-relic-diagnostics) results
22 |
23 | [NOTE]: # ( Provide any other relevant log data. )
24 | [TIP]: # ( Scrub logs and diagnostic information for sensitive information )
25 |
26 | ## Steps to Reproduce
27 |
28 | [NOTE]: # ( Please be as specific as possible. )
29 | [TIP]: # ( Link a sample application that demonstrates the issue. )
30 |
31 | ## Your Environment
32 |
33 | [TIP]: # ( Include as many relevant details about your environment as possible. )
34 |
35 | * ex: Browser name and version:
36 | * ex: Node version:
37 | * ex: Operating System and version:
38 |
39 | ## Additional context
40 |
41 | [TIP]: # ( Add any other context about the problem here. For example, relevant community posts or support tickets. )
42 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: feature-request, needs-triage
6 | assignees: ''
7 | priority: ''
8 | ---
9 |
10 | ## Is your feature request related to a problem? Please describe.
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | ## Feature Description
14 | A clear and concise description of the feature you want or need.
15 |
16 | ## Describe Alternatives
17 | A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to?
18 |
19 | ## Additional context
20 | Add any other context here.
21 |
22 | ## Priority
23 | Please help us better understand this feature request by choosing a priority from the following options:
24 | [Nice to Have, Really Want, Must Have, Blocker]
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
14 |
15 | ## Proposed Release Notes
16 |
17 | ## Links
18 |
19 | ## Details
20 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.github/workflows/ci-workflow.yaml:
--------------------------------------------------------------------------------
1 | name: Winston Log Enricher CI
2 |
3 | on:
4 | push:
5 | pull_request:
6 | workflow_dispatch:
7 | schedule:
8 | # Run every Monday at 9AM PST (16 UTC)
9 | - cron: '0 16 * * 1'
10 |
11 | jobs:
12 | lint:
13 | runs-on: ubuntu-latest
14 |
15 | strategy:
16 | matrix:
17 | node-version: [lts/*]
18 |
19 | steps:
20 | - uses: actions/checkout@v2
21 | - name: Use Node.js ${{ matrix.node-version }}
22 | uses: actions/setup-node@v2
23 | with:
24 | node-version: ${{ matrix.node-version }}
25 | - name: Install Dependencies
26 | run: npm ci
27 | - name: Run Linting
28 | run: npm run lint
29 |
30 | types:
31 | runs-on: ubuntu-latest
32 |
33 | strategy:
34 | matrix:
35 | node-version: [lts/*]
36 |
37 | steps:
38 | - uses: actions/checkout@v2
39 | - name: Use Node.js ${{ matrix.node-version }}
40 | uses: actions/setup-node@v2
41 | with:
42 | node-version: ${{ matrix.node-version }}
43 | - name: Install Dependencies
44 | run: npm ci
45 | - name: Run Type Checking (TSD)
46 | run: npm run types
47 |
48 | unit:
49 | runs-on: ubuntu-latest
50 |
51 | strategy:
52 | matrix:
53 | node-version: [12.x, 14.x, 16.x]
54 |
55 | steps:
56 | - uses: actions/checkout@v2
57 | - name: Use Node.js ${{ matrix.node-version }}
58 | uses: actions/setup-node@v2
59 | with:
60 | node-version: ${{ matrix.node-version }}
61 | - name: Install Dependencies
62 | run: npm ci
63 | - name: Run Unit Tests
64 | run: npm run unit
65 |
66 | versioned:
67 | runs-on: ubuntu-latest
68 |
69 | strategy:
70 | matrix:
71 | node-version: [12.x, 14.x, 16.x]
72 |
73 | steps:
74 | - uses: actions/checkout@v2
75 | - name: Use Node.js ${{ matrix.node-version }}
76 | uses: actions/setup-node@v2
77 | with:
78 | node-version: ${{ matrix.node-version }}
79 | - name: Install Dependencies
80 | run: npm ci
81 | - name: Run Versioned Tests (npm v6 / Node 12-14)
82 | if: ${{ matrix.node-version != '16.x' }}
83 | run: npm run versioned:npm6
84 | - name: Run Versioned Tests (npm v7 / Node 16)
85 | if: ${{ matrix.node-version == '16.x' }}
86 | run: npm run versioned:npm7
87 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.github/workflows/repolinter.yml:
--------------------------------------------------------------------------------
1 | # NOTE: This file should always be named `repolinter.yml` to allow
2 | # workflow_dispatch to work properly
3 | name: Repolinter Action
4 |
5 | # NOTE: This workflow will ONLY check the default branch!
6 | # Currently there is no elegant way to specify the default
7 | # branch in the event filtering, so branches are instead
8 | # filtered in the "Test Default Branch" step.
9 | on: [push, workflow_dispatch]
10 |
11 | jobs:
12 | repolint:
13 | name: Run Repolinter
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Test Default Branch
17 | id: default-branch
18 | uses: actions/github-script@v2
19 | with:
20 | script: |
21 | const data = await github.repos.get(context.repo)
22 | return data.data && data.data.default_branch === context.ref.split('/').slice(-1)[0]
23 | - name: Checkout Self
24 | if: ${{ steps.default-branch.outputs.result == 'true' }}
25 | uses: actions/checkout@v2
26 | - name: Run Repolinter
27 | if: ${{ steps.default-branch.outputs.result == 'true' }}
28 | uses: newrelic/repolinter-action@v1
29 | with:
30 | config_url: https://raw.githubusercontent.com/newrelic/.github/main/repolinter-rulesets/community-plus.yml
31 | output_type: issue
32 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (http://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # Typescript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # VS Code specific configuration
61 | .vscode
62 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | ## 4.0.1 (12/15/2022)
4 | * Fixed an issue where logging non-standard error objects under the err key causes APM to throw.
5 |
6 | ## 4.0.0 (07/27/2022)
7 |
8 | * **BREAKING** Removed support for Node 12.
9 |
10 | The minimum supported version is now Node v14. For further information on our support policy, see: https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.
11 |
12 | * Added support for Node 18.
13 | * Resolved several dev-dependency audit warnings.
14 |
15 | ## 3.2.0 (06/07/2022)
16 |
17 | * Restored package to only handle log enrichment and not application logging. If you want to get logs in context automatically forwarded you can use Node.js agent version v8.13.0 or later.
18 |
19 | ## 3.1.1 (05/11/2022)
20 |
21 | **BREAKING**: Updated the signature to require passing in the winston package instead of relying on it being a peer dependency.
22 |
23 | Before:
24 |
25 | ```js
26 | const newrelicFormatter = require('@newrelic/winston-enricher')
27 |
28 | format: winston.format.combine(
29 | winston.format.label({label: 'test'}),
30 | newrelicFormatter()
31 | )
32 | ```
33 |
34 | Now:
35 |
36 | ```js
37 | const nrWinstonEnricher = require('@newrelic/winston-enricher')
38 | const newrelicFormatter = nrWinstonEnricher(winston)
39 |
40 |
41 | format: winston.format.combine(
42 | winston.format.label({label: 'test'}),
43 | newrelicFormatter()
44 | )
45 | ```
46 |
47 | * Added support for new application logging for the Node.js agent
48 | * facilitate agent log forwarding
49 | * local log decorating
50 | * agent supportability metrics around usage
51 | * log enrichment
52 | * Added logic to prevent double logging with agent application log forwarding and log enrichment.
53 | * Handled case where customer upgrades agent and log enricher will continue to function without any changes.
54 | * Updated formatter to favor application log forwarding when both application log forwarding and application local log decorating are both enabled.
55 | * Dev-only npm audit fixes.
56 | * Bumped tap to ^16.0.1.
57 | * Bumped @newrelic/test-utilities ^6.5.3.
58 | * Fixed third-party notice generation.
59 |
60 | ## 3.1.0 (05/05/2022)
61 |
62 | * This release has been deprecated. Please use version 3.1.1 or higher.
63 |
64 | ## 3.0.0 (04/28/2022)
65 |
66 | * This release has been deprecated. Please use version 3.1.1 or higher.
67 |
68 | ## 2.1.1 (04/05/2022)
69 |
70 | * Made Winston a peer dependency.
71 |
72 | ## 2.1.0 (10/20/2021)
73 |
74 | * Added TypeScript types.
75 | * Upgraded setup-node CI job to v2 and changed the linting node version to lts/* for future proofing.
76 | * Added @newrelic/eslint-config to rely on a centralized eslint ruleset.
77 | * Updated issue templates for consistency with our other repositories.
78 | * Added a pre-commit hook to check if package.json changes and run `oss third-party manifest` and `oss third-party notices`. This will ensure the `third_party_manifest.json` and `THIRD_PARTY_NOTICES.md` are up to date.
79 | * Added a pre-commit hook to run linting via huskey.
80 |
81 | ## 2.0.0 (07/20/2021)
82 |
83 | **BREAKING** Removed support for Node 10.
84 |
85 | The minimum supported version is now Node v12. For further information on our support policy, see: https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.
86 |
87 | * Added support for Node 16.
88 | * Added files list instead of `.npmignore` to specify module contents.
89 | * Added `workflow_dispatch` to CI workflow to allow manual triggers.
90 | * Bumped `@newrelic/test-utilities` to ^5.1.0.
91 | * Bumped `tap` to ^15.0.9.
92 | * Update `newrelic` dev dependency to >= 7.x.
93 |
94 | ## 1.0.0 (11/02/2020)
95 |
96 | * Fixed several bugs where the formatter would have unexpected results when the agent is disabled. Fixes include:
97 | * Now always logs via JSON format.
98 | * Does not modify original content when the agent is disabled.
99 | * Does not crash with the existence of a timestamp field when the agent is disabled.
100 | * Added module load support metric.
101 | * Breaking: Moved agent dependency to be a peer dependency. It is now required the leveraging application install 'newrelic' directly.
102 | * This prevents attempts to load multiple copies of the agent. Previously, when an application referenced 'newrelic' the formatter would attempt to load a second copy of the agent. The agent protects against this behavior but it is preferred we avoid this. Also, the prior dependency was too restrictive and would have pinned the formatters version to 6.x versions of the agent.
103 | * Removed Node v8 from CI.
104 | * Added Node 14 to CI.
105 | * Update README for consistency with New Relic OSS repositories.
106 | * Remove Code of Conduct doc and link to New Relic org.
107 | * Added Open Source Policy Workflow.
108 | * Bumped node-test-utilities version to ^4.0.0.
109 | * Updated third party notices including new footer language.
110 | * Modifies default branch name wording in contributing guide.
111 | * Migrated CI to GitHub Actions from CircleCI.
112 |
113 | ## 0.1.1 (02/14/2020)
114 |
115 | * Handle getLinkingMetadata not returning an object.
116 |
117 | ## 0.1.0 (11/26/2019)
118 |
119 | * Initial release of log formatter.
120 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are always welcome. Before contributing please read the
4 | [code of conduct](./CODE_OF_CONDUCT.md) and [search the issue tracker](../../issues); your issue may have already been discussed or fixed in the default branch. To contribute,
5 | [fork](https://help.github.com/articles/fork-a-repo/) this repository, commit your changes, and [send a Pull Request](https://help.github.com/articles/using-pull-requests/).
6 |
7 | Note that our [code of conduct](./CODE_OF_CONDUCT.md) applies to all platforms and venues related to this project; please follow it in all your interactions with the project and its participants.
8 |
9 | ## Feature Requests
10 |
11 | Feature requests should be submitted in the [Issue tracker](../../issues), with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest, [e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), has been [shown by the community](../../issues?q=label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
12 | Before submitting an Issue, please search for similar ones in the
13 | [closed issues](../../issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement).
14 |
15 | ## Pull Requests
16 |
17 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
18 | 2. Apply the appropriate `semver: [major|minor|patch]` label to the PR to indicate the version increase this Pull Request would represent. For more info, see: [SemVer](http://semver.org/).
19 | 3. Apply the appropriate `risk: [high|medium|low|none]` label to the PR to indicate the estimated risk level of the changes in this Pull Request.
20 | 4. You may merge the Pull Request in once you have the sign-off of one of the maintainers, or if you do not have permission to do that, you may request the reviewer merge it for you. In most cases, a project maintainer will merge the PR for you upon approval.
21 |
22 | ## Contributor License Agreement
23 |
24 | Keep in mind that when you submit your Pull Request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at opensource@newrelic.com.
25 |
26 | For more information about CLAs, please check out Alex Russell’s excellent post,
27 | [“Why Do I Need to Sign This?”](https://infrequently.org/2008/06/why-do-i-need-to-sign-this/).
28 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2019 New Relic, Inc.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # @newrelic/winston-enricher
4 |
5 | New Relic's official `winston` log enricher for use with the
6 | [Node Agent](https://github.com/newrelic/node-newrelic).
7 |
8 | The `winston-enricher` log format adds additional app, distributed trace and span information output as JSON-formatted log messages. This is most commonly used with the New Relic Logs product.
9 |
10 | For the latest information, please see [the New Relic docs](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-apm-agents).
11 |
12 | ## Installation
13 |
14 | ```bash
15 | npm install @newrelic/winston-enricher
16 | ```
17 |
18 | ## Usage
19 |
20 | ```js
21 | // index.js
22 | const newrelicFormatter = require('@newrelic/winston-enricher')
23 | const winston = require('winston')
24 | const newrelicWinstonFormatter = newrelicFormatter(winston)
25 | ```
26 |
27 | The New Relic formatter can be used individually or combined with other
28 | formatters as the final format.
29 |
30 | ```js
31 | format: winston.format.combine(
32 | winston.format.label({label: 'test'}),
33 | newrelicWinstonFormatter()
34 | )
35 | ```
36 |
37 | **Note for unhandledException log messages:**
38 |
39 | The stack trace will be written to the `error.stack` property.
40 |
41 | To accommodate the New Relic Logs 4000 character log line limit, the `stack` and `trace` properties will be removed and the `message`, `error.message` and `error.stack` values will be truncated to 1024 characters.
42 |
43 | ### Version Requirements
44 |
45 | `winston` versions 3.0.0 and greater are supported.
46 |
47 | For more information, including currently supported Node versions, please see the agent [compatibility and requirements](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent).
48 |
49 | For general agent setup, please see the agent [installation guide](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/install-nodejs-agent).
50 |
51 | ## Support
52 |
53 | New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:
54 |
55 | **Support Channels**
56 |
57 | * [New Relic Documentation](https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/logs-context-nodejs/nodejs-configure-winston): Comprehensive guidance for using our platform
58 | * [New Relic Community](https://forum.newrelic.com/): The best place to engage in troubleshooting questions
59 | * [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
60 | * [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
61 | * **[For Community Plus repositories]** [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
62 |
63 | ## Contribute
64 |
65 | We encourage your contributions to improve New Relic's Node.js logging extensions! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
66 |
67 | If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
68 |
69 | **A note about vulnerabilities**
70 |
71 | As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
72 |
73 | If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
74 |
75 | If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
76 |
77 | To all contributors, we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node.js logging extensions](https://opensource.newrelic.com/projects/newrelic-node-log-extensions).
78 |
79 | ## License
80 | The New Relic Node.js loggin extensions are licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
81 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/THIRD_PARTY_NOTICES.md:
--------------------------------------------------------------------------------
1 | # Third Party Notices
2 |
3 | The @newrelic/winston-enricher uses source code from third party libraries which carry
4 | their own copyright notices and license terms. These notices are provided
5 | below.
6 |
7 | In the event that a required notice is missing or incorrect, please notify us
8 | by e-mailing [open-source@newrelic.com](mailto:open-source@newrelic.com).
9 |
10 | For any licenses that require the disclosure of source
11 | code, the source code can be found at [https://github.com/newrelic/newrelic-winston-logenricher-node](https://github.com/newrelic/newrelic-winston-logenricher-node).
12 |
13 | ## Content
14 |
15 | **[dependencies](#dependencies)**
16 |
17 |
18 | **[devDependencies](#devDependencies)**
19 |
20 | * [@newrelic/test-utilities](#newrelictest-utilities)
21 | * [concat-stream](#concat-stream)
22 | * [newrelic](#newrelic)
23 | * [tap](#tap)
24 | * [tsd](#tsd)
25 | * [winston](#winston)
26 |
27 |
28 | ## dependencies
29 |
30 |
31 | ## devDependencies
32 |
33 | ### @newrelic/test-utilities
34 |
35 | This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.3.2](https://github.com/newrelic/node-test-utilities/tree/v7.3.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v7.3.2/LICENSE):
36 |
37 | ```
38 | Apache License
39 | Version 2.0, January 2004
40 | http://www.apache.org/licenses/
41 |
42 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
43 |
44 | 1. Definitions.
45 |
46 | "License" shall mean the terms and conditions for use, reproduction,
47 | and distribution as defined by Sections 1 through 9 of this document.
48 |
49 | "Licensor" shall mean the copyright owner or entity authorized by
50 | the copyright owner that is granting the License.
51 |
52 | "Legal Entity" shall mean the union of the acting entity and all
53 | other entities that control, are controlled by, or are under common
54 | control with that entity. For the purposes of this definition,
55 | "control" means (i) the power, direct or indirect, to cause the
56 | direction or management of such entity, whether by contract or
57 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
58 | outstanding shares, or (iii) beneficial ownership of such entity.
59 |
60 | "You" (or "Your") shall mean an individual or Legal Entity
61 | exercising permissions granted by this License.
62 |
63 | "Source" form shall mean the preferred form for making modifications,
64 | including but not limited to software source code, documentation
65 | source, and configuration files.
66 |
67 | "Object" form shall mean any form resulting from mechanical
68 | transformation or translation of a Source form, including but
69 | not limited to compiled object code, generated documentation,
70 | and conversions to other media types.
71 |
72 | "Work" shall mean the work of authorship, whether in Source or
73 | Object form, made available under the License, as indicated by a
74 | copyright notice that is included in or attached to the work
75 | (an example is provided in the Appendix below).
76 |
77 | "Derivative Works" shall mean any work, whether in Source or Object
78 | form, that is based on (or derived from) the Work and for which the
79 | editorial revisions, annotations, elaborations, or other modifications
80 | represent, as a whole, an original work of authorship. For the purposes
81 | of this License, Derivative Works shall not include works that remain
82 | separable from, or merely link (or bind by name) to the interfaces of,
83 | the Work and Derivative Works thereof.
84 |
85 | "Contribution" shall mean any work of authorship, including
86 | the original version of the Work and any modifications or additions
87 | to that Work or Derivative Works thereof, that is intentionally
88 | submitted to Licensor for inclusion in the Work by the copyright owner
89 | or by an individual or Legal Entity authorized to submit on behalf of
90 | the copyright owner. For the purposes of this definition, "submitted"
91 | means any form of electronic, verbal, or written communication sent
92 | to the Licensor or its representatives, including but not limited to
93 | communication on electronic mailing lists, source code control systems,
94 | and issue tracking systems that are managed by, or on behalf of, the
95 | Licensor for the purpose of discussing and improving the Work, but
96 | excluding communication that is conspicuously marked or otherwise
97 | designated in writing by the copyright owner as "Not a Contribution."
98 |
99 | "Contributor" shall mean Licensor and any individual or Legal Entity
100 | on behalf of whom a Contribution has been received by Licensor and
101 | subsequently incorporated within the Work.
102 |
103 | 2. Grant of Copyright License. Subject to the terms and conditions of
104 | this License, each Contributor hereby grants to You a perpetual,
105 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
106 | copyright license to reproduce, prepare Derivative Works of,
107 | publicly display, publicly perform, sublicense, and distribute the
108 | Work and such Derivative Works in Source or Object form.
109 |
110 | 3. Grant of Patent License. Subject to the terms and conditions of
111 | this License, each Contributor hereby grants to You a perpetual,
112 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
113 | (except as stated in this section) patent license to make, have made,
114 | use, offer to sell, sell, import, and otherwise transfer the Work,
115 | where such license applies only to those patent claims licensable
116 | by such Contributor that are necessarily infringed by their
117 | Contribution(s) alone or by combination of their Contribution(s)
118 | with the Work to which such Contribution(s) was submitted. If You
119 | institute patent litigation against any entity (including a
120 | cross-claim or counterclaim in a lawsuit) alleging that the Work
121 | or a Contribution incorporated within the Work constitutes direct
122 | or contributory patent infringement, then any patent licenses
123 | granted to You under this License for that Work shall terminate
124 | as of the date such litigation is filed.
125 |
126 | 4. Redistribution. You may reproduce and distribute copies of the
127 | Work or Derivative Works thereof in any medium, with or without
128 | modifications, and in Source or Object form, provided that You
129 | meet the following conditions:
130 |
131 | (a) You must give any other recipients of the Work or
132 | Derivative Works a copy of this License; and
133 |
134 | (b) You must cause any modified files to carry prominent notices
135 | stating that You changed the files; and
136 |
137 | (c) You must retain, in the Source form of any Derivative Works
138 | that You distribute, all copyright, patent, trademark, and
139 | attribution notices from the Source form of the Work,
140 | excluding those notices that do not pertain to any part of
141 | the Derivative Works; and
142 |
143 | (d) If the Work includes a "NOTICE" text file as part of its
144 | distribution, then any Derivative Works that You distribute must
145 | include a readable copy of the attribution notices contained
146 | within such NOTICE file, excluding those notices that do not
147 | pertain to any part of the Derivative Works, in at least one
148 | of the following places: within a NOTICE text file distributed
149 | as part of the Derivative Works; within the Source form or
150 | documentation, if provided along with the Derivative Works; or,
151 | within a display generated by the Derivative Works, if and
152 | wherever such third-party notices normally appear. The contents
153 | of the NOTICE file are for informational purposes only and
154 | do not modify the License. You may add Your own attribution
155 | notices within Derivative Works that You distribute, alongside
156 | or as an addendum to the NOTICE text from the Work, provided
157 | that such additional attribution notices cannot be construed
158 | as modifying the License.
159 |
160 | You may add Your own copyright statement to Your modifications and
161 | may provide additional or different license terms and conditions
162 | for use, reproduction, or distribution of Your modifications, or
163 | for any such Derivative Works as a whole, provided Your use,
164 | reproduction, and distribution of the Work otherwise complies with
165 | the conditions stated in this License.
166 |
167 | 5. Submission of Contributions. Unless You explicitly state otherwise,
168 | any Contribution intentionally submitted for inclusion in the Work
169 | by You to the Licensor shall be under the terms and conditions of
170 | this License, without any additional terms or conditions.
171 | Notwithstanding the above, nothing herein shall supersede or modify
172 | the terms of any separate license agreement you may have executed
173 | with Licensor regarding such Contributions.
174 |
175 | 6. Trademarks. This License does not grant permission to use the trade
176 | names, trademarks, service marks, or product names of the Licensor,
177 | except as required for reasonable and customary use in describing the
178 | origin of the Work and reproducing the content of the NOTICE file.
179 |
180 | 7. Disclaimer of Warranty. Unless required by applicable law or
181 | agreed to in writing, Licensor provides the Work (and each
182 | Contributor provides its Contributions) on an "AS IS" BASIS,
183 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
184 | implied, including, without limitation, any warranties or conditions
185 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
186 | PARTICULAR PURPOSE. You are solely responsible for determining the
187 | appropriateness of using or redistributing the Work and assume any
188 | risks associated with Your exercise of permissions under this License.
189 |
190 | 8. Limitation of Liability. In no event and under no legal theory,
191 | whether in tort (including negligence), contract, or otherwise,
192 | unless required by applicable law (such as deliberate and grossly
193 | negligent acts) or agreed to in writing, shall any Contributor be
194 | liable to You for damages, including any direct, indirect, special,
195 | incidental, or consequential damages of any character arising as a
196 | result of this License or out of the use or inability to use the
197 | Work (including but not limited to damages for loss of goodwill,
198 | work stoppage, computer failure or malfunction, or any and all
199 | other commercial damages or losses), even if such Contributor
200 | has been advised of the possibility of such damages.
201 |
202 | 9. Accepting Warranty or Additional Liability. While redistributing
203 | the Work or Derivative Works thereof, You may choose to offer,
204 | and charge a fee for, acceptance of support, warranty, indemnity,
205 | or other liability obligations and/or rights consistent with this
206 | License. However, in accepting such obligations, You may act only
207 | on Your own behalf and on Your sole responsibility, not on behalf
208 | of any other Contributor, and only if You agree to indemnify,
209 | defend, and hold each Contributor harmless for any liability
210 | incurred by, or claims asserted against, such Contributor by reason
211 | of your accepting any such warranty or additional liability.
212 |
213 | END OF TERMS AND CONDITIONS
214 |
215 | APPENDIX: How to apply the Apache License to your work.
216 |
217 | To apply the Apache License to your work, attach the following
218 | boilerplate notice, with the fields enclosed by brackets "[]"
219 | replaced with your own identifying information. (Don't include
220 | the brackets!) The text should be enclosed in the appropriate
221 | comment syntax for the file format. We also recommend that a
222 | file or class name and description of purpose be included on the
223 | same "printed page" as the copyright notice for easier
224 | identification within third-party archives.
225 |
226 | Copyright [yyyy] [name of copyright owner]
227 |
228 | Licensed under the Apache License, Version 2.0 (the "License");
229 | you may not use this file except in compliance with the License.
230 | You may obtain a copy of the License at
231 |
232 | http://www.apache.org/licenses/LICENSE-2.0
233 |
234 | Unless required by applicable law or agreed to in writing, software
235 | distributed under the License is distributed on an "AS IS" BASIS,
236 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
237 | See the License for the specific language governing permissions and
238 | limitations under the License.
239 |
240 | ```
241 |
242 | ### concat-stream
243 |
244 | This product includes source derived from [concat-stream](https://github.com/maxogden/concat-stream) ([v2.0.0](https://github.com/maxogden/concat-stream/tree/v2.0.0)), distributed under the [MIT License](https://github.com/maxogden/concat-stream/blob/v2.0.0/LICENSE):
245 |
246 | ```
247 | The MIT License
248 |
249 | Copyright (c) 2013 Max Ogden
250 |
251 | Permission is hereby granted, free of charge,
252 | to any person obtaining a copy of this software and
253 | associated documentation files (the "Software"), to
254 | deal in the Software without restriction, including
255 | without limitation the rights to use, copy, modify,
256 | merge, publish, distribute, sublicense, and/or sell
257 | copies of the Software, and to permit persons to whom
258 | the Software is furnished to do so,
259 | subject to the following conditions:
260 |
261 | The above copyright notice and this permission notice
262 | shall be included in all copies or substantial portions of the Software.
263 |
264 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
265 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
266 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
267 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
268 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
269 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
270 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
271 | ```
272 |
273 | ### newrelic
274 |
275 | This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v10.3.2](https://github.com/newrelic/node-newrelic/tree/v10.3.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v10.3.2/LICENSE):
276 |
277 | ```
278 | Apache License
279 | Version 2.0, January 2004
280 | http://www.apache.org/licenses/
281 |
282 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
283 |
284 | 1. Definitions.
285 |
286 | "License" shall mean the terms and conditions for use, reproduction,
287 | and distribution as defined by Sections 1 through 9 of this document.
288 |
289 | "Licensor" shall mean the copyright owner or entity authorized by
290 | the copyright owner that is granting the License.
291 |
292 | "Legal Entity" shall mean the union of the acting entity and all
293 | other entities that control, are controlled by, or are under common
294 | control with that entity. For the purposes of this definition,
295 | "control" means (i) the power, direct or indirect, to cause the
296 | direction or management of such entity, whether by contract or
297 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
298 | outstanding shares, or (iii) beneficial ownership of such entity.
299 |
300 | "You" (or "Your") shall mean an individual or Legal Entity
301 | exercising permissions granted by this License.
302 |
303 | "Source" form shall mean the preferred form for making modifications,
304 | including but not limited to software source code, documentation
305 | source, and configuration files.
306 |
307 | "Object" form shall mean any form resulting from mechanical
308 | transformation or translation of a Source form, including but
309 | not limited to compiled object code, generated documentation,
310 | and conversions to other media types.
311 |
312 | "Work" shall mean the work of authorship, whether in Source or
313 | Object form, made available under the License, as indicated by a
314 | copyright notice that is included in or attached to the work
315 | (an example is provided in the Appendix below).
316 |
317 | "Derivative Works" shall mean any work, whether in Source or Object
318 | form, that is based on (or derived from) the Work and for which the
319 | editorial revisions, annotations, elaborations, or other modifications
320 | represent, as a whole, an original work of authorship. For the purposes
321 | of this License, Derivative Works shall not include works that remain
322 | separable from, or merely link (or bind by name) to the interfaces of,
323 | the Work and Derivative Works thereof.
324 |
325 | "Contribution" shall mean any work of authorship, including
326 | the original version of the Work and any modifications or additions
327 | to that Work or Derivative Works thereof, that is intentionally
328 | submitted to Licensor for inclusion in the Work by the copyright owner
329 | or by an individual or Legal Entity authorized to submit on behalf of
330 | the copyright owner. For the purposes of this definition, "submitted"
331 | means any form of electronic, verbal, or written communication sent
332 | to the Licensor or its representatives, including but not limited to
333 | communication on electronic mailing lists, source code control systems,
334 | and issue tracking systems that are managed by, or on behalf of, the
335 | Licensor for the purpose of discussing and improving the Work, but
336 | excluding communication that is conspicuously marked or otherwise
337 | designated in writing by the copyright owner as "Not a Contribution."
338 |
339 | "Contributor" shall mean Licensor and any individual or Legal Entity
340 | on behalf of whom a Contribution has been received by Licensor and
341 | subsequently incorporated within the Work.
342 |
343 | 2. Grant of Copyright License. Subject to the terms and conditions of
344 | this License, each Contributor hereby grants to You a perpetual,
345 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
346 | copyright license to reproduce, prepare Derivative Works of,
347 | publicly display, publicly perform, sublicense, and distribute the
348 | Work and such Derivative Works in Source or Object form.
349 |
350 | 3. Grant of Patent License. Subject to the terms and conditions of
351 | this License, each Contributor hereby grants to You a perpetual,
352 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
353 | (except as stated in this section) patent license to make, have made,
354 | use, offer to sell, sell, import, and otherwise transfer the Work,
355 | where such license applies only to those patent claims licensable
356 | by such Contributor that are necessarily infringed by their
357 | Contribution(s) alone or by combination of their Contribution(s)
358 | with the Work to which such Contribution(s) was submitted. If You
359 | institute patent litigation against any entity (including a
360 | cross-claim or counterclaim in a lawsuit) alleging that the Work
361 | or a Contribution incorporated within the Work constitutes direct
362 | or contributory patent infringement, then any patent licenses
363 | granted to You under this License for that Work shall terminate
364 | as of the date such litigation is filed.
365 |
366 | 4. Redistribution. You may reproduce and distribute copies of the
367 | Work or Derivative Works thereof in any medium, with or without
368 | modifications, and in Source or Object form, provided that You
369 | meet the following conditions:
370 |
371 | (a) You must give any other recipients of the Work or
372 | Derivative Works a copy of this License; and
373 |
374 | (b) You must cause any modified files to carry prominent notices
375 | stating that You changed the files; and
376 |
377 | (c) You must retain, in the Source form of any Derivative Works
378 | that You distribute, all copyright, patent, trademark, and
379 | attribution notices from the Source form of the Work,
380 | excluding those notices that do not pertain to any part of
381 | the Derivative Works; and
382 |
383 | (d) If the Work includes a "NOTICE" text file as part of its
384 | distribution, then any Derivative Works that You distribute must
385 | include a readable copy of the attribution notices contained
386 | within such NOTICE file, excluding those notices that do not
387 | pertain to any part of the Derivative Works, in at least one
388 | of the following places: within a NOTICE text file distributed
389 | as part of the Derivative Works; within the Source form or
390 | documentation, if provided along with the Derivative Works; or,
391 | within a display generated by the Derivative Works, if and
392 | wherever such third-party notices normally appear. The contents
393 | of the NOTICE file are for informational purposes only and
394 | do not modify the License. You may add Your own attribution
395 | notices within Derivative Works that You distribute, alongside
396 | or as an addendum to the NOTICE text from the Work, provided
397 | that such additional attribution notices cannot be construed
398 | as modifying the License.
399 |
400 | You may add Your own copyright statement to Your modifications and
401 | may provide additional or different license terms and conditions
402 | for use, reproduction, or distribution of Your modifications, or
403 | for any such Derivative Works as a whole, provided Your use,
404 | reproduction, and distribution of the Work otherwise complies with
405 | the conditions stated in this License.
406 |
407 | 5. Submission of Contributions. Unless You explicitly state otherwise,
408 | any Contribution intentionally submitted for inclusion in the Work
409 | by You to the Licensor shall be under the terms and conditions of
410 | this License, without any additional terms or conditions.
411 | Notwithstanding the above, nothing herein shall supersede or modify
412 | the terms of any separate license agreement you may have executed
413 | with Licensor regarding such Contributions.
414 |
415 | 6. Trademarks. This License does not grant permission to use the trade
416 | names, trademarks, service marks, or product names of the Licensor,
417 | except as required for reasonable and customary use in describing the
418 | origin of the Work and reproducing the content of the NOTICE file.
419 |
420 | 7. Disclaimer of Warranty. Unless required by applicable law or
421 | agreed to in writing, Licensor provides the Work (and each
422 | Contributor provides its Contributions) on an "AS IS" BASIS,
423 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
424 | implied, including, without limitation, any warranties or conditions
425 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
426 | PARTICULAR PURPOSE. You are solely responsible for determining the
427 | appropriateness of using or redistributing the Work and assume any
428 | risks associated with Your exercise of permissions under this License.
429 |
430 | 8. Limitation of Liability. In no event and under no legal theory,
431 | whether in tort (including negligence), contract, or otherwise,
432 | unless required by applicable law (such as deliberate and grossly
433 | negligent acts) or agreed to in writing, shall any Contributor be
434 | liable to You for damages, including any direct, indirect, special,
435 | incidental, or consequential damages of any character arising as a
436 | result of this License or out of the use or inability to use the
437 | Work (including but not limited to damages for loss of goodwill,
438 | work stoppage, computer failure or malfunction, or any and all
439 | other commercial damages or losses), even if such Contributor
440 | has been advised of the possibility of such damages.
441 |
442 | 9. Accepting Warranty or Additional Liability. While redistributing
443 | the Work or Derivative Works thereof, You may choose to offer,
444 | and charge a fee for, acceptance of support, warranty, indemnity,
445 | or other liability obligations and/or rights consistent with this
446 | License. However, in accepting such obligations, You may act only
447 | on Your own behalf and on Your sole responsibility, not on behalf
448 | of any other Contributor, and only if You agree to indemnify,
449 | defend, and hold each Contributor harmless for any liability
450 | incurred by, or claims asserted against, such Contributor by reason
451 | of your accepting any such warranty or additional liability.
452 |
453 | END OF TERMS AND CONDITIONS
454 |
455 | APPENDIX: How to apply the Apache License to your work.
456 |
457 | To apply the Apache License to your work, attach the following
458 | boilerplate notice, with the fields enclosed by brackets "[]"
459 | replaced with your own identifying information. (Don't include
460 | the brackets!) The text should be enclosed in the appropriate
461 | comment syntax for the file format. We also recommend that a
462 | file or class name and description of purpose be included on the
463 | same "printed page" as the copyright notice for easier
464 | identification within third-party archives.
465 |
466 | Copyright [yyyy] [name of copyright owner]
467 |
468 | Licensed under the Apache License, Version 2.0 (the "License");
469 | you may not use this file except in compliance with the License.
470 | You may obtain a copy of the License at
471 |
472 | http://www.apache.org/licenses/LICENSE-2.0
473 |
474 | Unless required by applicable law or agreed to in writing, software
475 | distributed under the License is distributed on an "AS IS" BASIS,
476 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
477 | See the License for the specific language governing permissions and
478 | limitations under the License.
479 | ```
480 |
481 | ### tap
482 |
483 | This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.2.0](https://github.com/tapjs/node-tap/tree/v16.2.0)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.2.0/LICENSE):
484 |
485 | ```
486 | The ISC License
487 |
488 | Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
489 |
490 | Permission to use, copy, modify, and/or distribute this software for any
491 | purpose with or without fee is hereby granted, provided that the above
492 | copyright notice and this permission notice appear in all copies.
493 |
494 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
495 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
496 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
497 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
498 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
499 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
500 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
501 |
502 | ```
503 |
504 | ### tsd
505 |
506 | This product includes source derived from [tsd](https://github.com/SamVerschueren/tsd) ([v0.18.0](https://github.com/SamVerschueren/tsd/tree/v0.18.0)), distributed under the [MIT License](https://github.com/SamVerschueren/tsd/blob/v0.18.0/license):
507 |
508 | ```
509 | MIT License
510 |
511 | Copyright (c) Sam Verschueren (github.com/SamVerschueren)
512 |
513 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
514 |
515 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
516 |
517 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
518 |
519 | ```
520 |
521 | ### winston
522 |
523 | This product includes source derived from [winston](https://github.com/winstonjs/winston) ([v3.6.0](https://github.com/winstonjs/winston/tree/v3.6.0)), distributed under the [MIT License](https://github.com/winstonjs/winston/blob/v3.6.0/LICENSE):
524 |
525 | ```
526 | Copyright (c) 2010 Charlie Robbins
527 |
528 | Permission is hereby granted, free of charge, to any person obtaining a copy
529 | of this software and associated documentation files (the "Software"), to deal
530 | in the Software without restriction, including without limitation the rights
531 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
532 | copies of the Software, and to permit persons to whom the Software is
533 | furnished to do so, subject to the following conditions:
534 |
535 | The above copyright notice and this permission notice shall be included in
536 | all copies or substantial portions of the Software.
537 |
538 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
539 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
540 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
541 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
542 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
543 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
544 | THE SOFTWARE.
545 | ```
546 |
547 |
548 | -----
549 |
550 | Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,your systems may call externally maintained libraries in addition to those listed above. See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE) for additional details regarding externally maintained libraries and certain related licenses and notices.
551 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/THIRD_PARTY_NOTICES_FOOTER.md:
--------------------------------------------------------------------------------
1 | -----
2 |
3 | Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,your systems may call externally maintained libraries in addition to those listed above. See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE) for additional details regarding externally maintained libraries and certain related licenses and notices.
--------------------------------------------------------------------------------
/packages/winston-log-enricher/bin/update-third-party-notices.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Checks all staged files for
4 | # package.json. If it changes
5 | # it will re-run `oss third-party manifest`
6 | # and `oss third-party notices` to keep
7 | # these files up to date as deps get updated
8 |
9 | STAGED_FILES=$(git diff-index --cached --name-only HEAD)
10 |
11 | for FILE in $STAGED_FILES
12 | do
13 | if [ $FILE == "package.json" ]; then
14 | RUN_THIRD_PARTY=1
15 | break
16 | fi
17 | done
18 |
19 | if [ -n "$RUN_THIRD_PARTY" ]; then
20 | echo "package.json changed, running oss manifest and notices"
21 | npm run third-party-updates
22 | fi
23 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | /**
9 | * Allows users to `require('@newrelic/winston-enricher')` directly in their app. If
10 | * they for some reason choose to explicitly use an older version of our
11 | * instrumentation then the supportability metrics for custom instrumentation
12 | * will trigger.
13 | */
14 | const newrelic = require('newrelic')
15 | const formatterFactory = require('./lib/createFormatter.js')
16 | module.exports = formatterFactory.bind(null, newrelic)
17 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/lib/createFormatter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 | const truncate = require('./truncate')
8 |
9 | module.exports = function createFormatter(newrelic, winston) {
10 | // Stub API means agent is not enabled.
11 | if (!newrelic.shim) {
12 | // Continue to log original message with JSON formatter
13 | return winston.format.json
14 | }
15 |
16 | createModuleUsageMetric(newrelic.shim.agent)
17 |
18 | const jsonFormatter = winston.format.json()
19 |
20 | return winston.format((info, opts) => {
21 | if (info.exception === true) {
22 | // Due to Winston internals sometimes the error on the info object is a string or an
23 | // empty object, and so the message property is all we have
24 | const errorMessage = info.error.message || info.message || ''
25 |
26 | info['error.message'] = truncate(errorMessage)
27 | info['error.class'] =
28 | info.error.name === 'Error' ? info.error.constructor.name : info.error.name
29 | info['error.stack'] = truncate(info.error.stack)
30 | info.message = truncate(info.message)
31 |
32 | // Removes additional capture of stack to reduce overall payload/log-line size.
33 | // The server has a maximum of ~4k characters per line allowed.
34 | delete info.trace
35 | delete info.stack
36 | }
37 |
38 | if (info.timestamp) {
39 | newrelic.shim.logger.traceOnce(
40 | 'Overwriting `timestamp` key; assigning original value to `original_timestamp`.'
41 | )
42 | info.original_timestamp = info.timestamp
43 | }
44 | info.timestamp = Date.now()
45 |
46 | const metadata = newrelic.getLinkingMetadata(true)
47 |
48 | // Add the metadata to the info object being logged
49 | Object.keys(metadata).forEach((m) => {
50 | info[m] = metadata[m]
51 | })
52 |
53 | return jsonFormatter.transform(info, opts)
54 | })
55 | }
56 |
57 | function createModuleUsageMetric(agent) {
58 | agent.metrics
59 | .getOrCreateMetric('Supportability/ExternalModules/WinstonLogEnricher')
60 | .incrementCallCount()
61 | }
62 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/lib/truncate.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const OUTPUT_LENGTH = 1024
9 | const MAX_LENGTH = 1021
10 |
11 | const truncate = (str) => {
12 | if (typeof str === 'string' && str.length > OUTPUT_LENGTH) {
13 | return str.substring(0, MAX_LENGTH) + '...'
14 | }
15 |
16 | return str
17 | }
18 |
19 | module.exports = truncate
20 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@newrelic/winston-enricher",
3 | "version": "4.0.1",
4 | "description": "New Relic log enricher for the `winston` package. Allows `winston` logs to be consumed by New Relic Logs.",
5 | "main": "index.js",
6 | "types": "types/index.d.ts",
7 | "scripts": {
8 | "unit": "tap tests/unit/**/*.tap.js --no-coverage",
9 | "lint": "eslint *.js lib tests",
10 | "lint:fix": "eslint --fix *.js lib tests",
11 | "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
12 | "types": "tsd",
13 | "test": "npm run unit && npm run lint && npm run types && npm run versioned",
14 | "third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json",
15 | "versioned": "versioned-tests --minor --all -i 2 'tests/versioned/*.tap.js'"
16 | },
17 | "author": "New Relic Node.js Agent Team ",
18 | "license": "Apache-2.0",
19 | "homepage": "https://github.com/newrelic/newrelic-node-log-extensions#readme",
20 | "repository": {
21 | "type": "git",
22 | "url": "git+https://github.com/newrelic/newrelic-node-log-extensions.git"
23 | },
24 | "peerDependencies": {
25 | "newrelic": ">=8.13.0"
26 | },
27 | "devDependencies": {
28 | "@newrelic/test-utilities": "^7.3.2",
29 | "concat-stream": "2.0.0",
30 | "newrelic": "^10.3.2",
31 | "tap": "16.2.0",
32 | "tsd": "0.18.0",
33 | "winston": "3.6.0"
34 | },
35 | "engines": {
36 | "node": ">=14.0"
37 | },
38 | "files": [
39 | "types/**",
40 | "lib/**",
41 | "index.js",
42 | "*.md"
43 | ],
44 | "tsd": {
45 | "directory": "./tests/types"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/types/index.test-d.ts:
--------------------------------------------------------------------------------
1 | import { expectType, expectAssignable } from "tsd"
2 | import winston = require('winston')
3 |
4 | import logEnricherFactory from '../../'
5 |
6 | const logEnricher = logEnricherFactory(winston)
7 |
8 | expectType(logEnricher)
9 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/unit/messageTruncate.tap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const tap = require('tap')
9 | const truncate = require('../../lib/truncate')
10 |
11 | tap.test('Should truncate string > 1024 chars', (t) => {
12 | const longString =
13 | '1111111111111111111111111111111111111111111111111111111111111111' +
14 | '1111111111111111111111111111111111111111111111111111111111111111' +
15 | '1111111111111111111111111111111111111111111111111111111111111111' +
16 | '1111111111111111111111111111111111111111111111111111111111111111' +
17 | '1111111111111111111111111111111111111111111111111111111111111111' +
18 | '1111111111111111111111111111111111111111111111111111111111111111' +
19 | '1111111111111111111111111111111111111111111111111111111111111111' +
20 | '1111111111111111111111111111111111111111111111111111111111111111' +
21 | '1111111111111111111111111111111111111111111111111111111111111111' +
22 | '1111111111111111111111111111111111111111111111111111111111111111' +
23 | '1111111111111111111111111111111111111111111111111111111111111111' +
24 | '1111111111111111111111111111111111111111111111111111111111111111' +
25 | '1111111111111111111111111111111111111111111111111111111111111111' +
26 | '1111111111111111111111111111111111111111111111111111111111111111' +
27 | '1111111111111111111111111111111111111111111111111111111111111111' +
28 | '1111111111111111111111111111111111111111111111111111111111111111' +
29 | '1111111111111111111111111111111111111111111111111111111111111111' +
30 | '1111111111111111111111111111111111111111111111111111111111111111'
31 |
32 | const processedStr = truncate(longString)
33 |
34 | t.equal(processedStr.length, 1024)
35 | t.equal(processedStr.substring(processedStr.length - 3), '...')
36 |
37 | t.end()
38 | })
39 |
40 | tap.test('Should return non-truncated string when <= 1024 chars', (t) => {
41 | const str = 'kenny loggins'
42 |
43 | const processedStr = truncate(str)
44 |
45 | t.equal(processedStr, str)
46 | t.end()
47 | })
48 | ;[
49 | { value: '', type: 'empty string' },
50 | { value: undefined, type: 'undefined' },
51 | { value: null, type: 'null' },
52 | { value: {}, type: 'object' },
53 | { value: [], type: 'array' },
54 | { value: function () {}, type: 'function' }
55 | ].forEach(({ value, type }) => {
56 | tap.test(`should not truncate ${type}`, (t) => {
57 | const newValue = truncate(value)
58 | t.same(value, newValue)
59 | t.end()
60 | })
61 | })
62 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/versioned/newrelic.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | exports.config = {
9 | app_name: ['My Application'],
10 | license_key: 'license key here',
11 | logging: {
12 | level: 'trace',
13 | filepath: '../../newrelic_agent.log'
14 | },
15 | utilization: {
16 | detect_aws: false,
17 | detect_pcf: false,
18 | detect_azure: false,
19 | detect_gcp: false,
20 | detect_docker: false
21 | },
22 | distributed_tracing: {
23 | enabled: true
24 | },
25 | transaction_tracer: {
26 | enabled: true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/versioned/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "winston-tests",
3 | "version": "0.0.0",
4 | "private": true,
5 | "engines": {
6 | "node": ">=14"
7 | },
8 | "tests": [
9 | {
10 | "engines": {
11 | "node": ">=14"
12 | },
13 | "dependencies": {
14 | "winston": ">=3"
15 | },
16 | "files": [
17 | "winston.tap.js"
18 | ]
19 | }
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/versioned/utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 | const utils = module.exports
8 |
9 | const concat = require('concat-stream')
10 |
11 | /**
12 | * Keep track of the number of streams that we're waiting to close and test. Also clean
13 | * up the info object used by winston/logform to make it easier to test.
14 | *
15 | * @param {Tap.Test} t
16 | */
17 | utils.makeStreamTest = function makeStreamTest(t) {
18 | let toBeClosed = 0
19 |
20 | // Assert function will receive log strings to be tested
21 | return function streamTest(assertFn) {
22 | // When creating a stream test, increment the number of streams to wait to close.
23 | ++toBeClosed
24 |
25 | // This function will be given to `concat` and will receive an array of messages
26 | // from Winston when the stream closes.
27 | return function (msgs) {
28 | // We only want the log string from the message object. This is stored on the
29 | // object on a key that is a symbol. Grab that and give it to the assert function.
30 | const logStrings = msgs.map((msg) => {
31 | const symbols = Object.getOwnPropertySymbols(msg)
32 | const msgSym = symbols.filter((s) => s.toString() === 'Symbol(message)')[0]
33 | return msg[msgSym]
34 | })
35 |
36 | assertFn(logStrings)
37 |
38 | // If this function is called it is because the stream closed. Decrement the
39 | // number of streams we're waiting for and end the test if it's the last one.
40 | if (--toBeClosed === 0) {
41 | t.end()
42 | }
43 | }
44 | }
45 | }
46 |
47 | /**
48 | * Concatenates the test stream with an assertion callback
49 | *
50 | * @param {Stream} testStream
51 | * @param {Function} cb assertion callback with all messages emitted during test run
52 | */
53 | utils.concatStreams = function concatStreams(testStream, cb) {
54 | return concat(
55 | testStream((msgs) => {
56 | cb(msgs)
57 | })
58 | )
59 | }
60 |
61 | /**
62 | * Helper function to compare a json-parsed log msg against the values we expected
63 | *
64 | * @param {Tap.Test} t
65 | * @param {string} msg actual message
66 | * @param {string} expected expected message
67 | */
68 | utils.validateAnnotations = function validateAnnotations(t, msg, expected) {
69 | Object.keys(expected).forEach((a) => {
70 | const ex = expected[a]
71 | t.type(msg[a], ex.type, `should have the proper keys (${a})`)
72 | if (ex.val != null) {
73 | t.equal(msg[a], ex.val, `should have the expected value (${a})`)
74 | }
75 | })
76 | }
77 |
78 | /**
79 | * Get the basic context annotations for every log line that is decorated
80 | *
81 | * @param {Object} config agent config
82 | * @return {Object}
83 | */
84 | utils.getBasicAnnotations = function getBasicAnnotations(config) {
85 | return {
86 | 'entity.name': {
87 | type: 'string',
88 | val: config.applications()[0]
89 | },
90 | 'entity.type': {
91 | type: 'string',
92 | val: 'SERVICE'
93 | },
94 | 'hostname': {
95 | type: 'string',
96 | val: config.getHostnameSafe()
97 | },
98 | 'entity.guid': {
99 | type: 'string',
100 | val: config.entity_guid
101 | }
102 | }
103 | }
104 |
105 | /**
106 | * Get the transaction ontext annotations for every log line that is decorated
107 | *
108 | * @param {Object} newrelic agent instance
109 | * @return {Object}
110 | */
111 | utils.getTransactionAnnotations = function getTransactionAnnotations(newrelic) {
112 | const metadata = newrelic.getLinkingMetadata()
113 | return {
114 | 'trace.id': {
115 | type: 'string',
116 | val: metadata['trace.id']
117 | },
118 | 'span.id': {
119 | type: 'string',
120 | val: metadata['span.id']
121 | }
122 | }
123 | }
124 |
125 | /**
126 | * Validates every message within a test stream:
127 | * verifies it can parse message as JSON
128 | * validates the basic NR metadata in message `entity.*` and `hostname`
129 | * validates packages key additions(like timestamp)
130 | * if message is `in trans` it validates the trace.id and span.id
131 | */
132 | utils.validateMsgs = function validateMsgs({
133 | t,
134 | msgs,
135 | basicAnnotations,
136 | loggingAnnotations,
137 | transactionAnnotations
138 | }) {
139 | msgs.forEach((msg) => {
140 | // Make sure the JSON stream actually gets JSON
141 | let msgJson
142 | t.doesNotThrow(() => (msgJson = JSON.parse(msg)), 'should be JSON')
143 | // Verify the proper keys are there
144 | utils.validateAnnotations(t, msgJson, basicAnnotations)
145 | utils.validateAnnotations(t, msgJson, loggingAnnotations)
146 | // Test that transaction keys are there if in a transaction
147 | if (msgJson.message === 'in trans') {
148 | utils.validateAnnotations(t, msgJson, transactionAnnotations)
149 | }
150 | })
151 | }
152 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/tests/versioned/winston.tap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 New Relic Corporation. All rights reserved.
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | 'use strict'
7 |
8 | const tap = require('tap')
9 | const utils = require('@newrelic/test-utilities')
10 | const formatFactory = require('../../lib/createFormatter.js')
11 | const concat = require('concat-stream')
12 | const API = require('newrelic/api')
13 | const StubApi = require('newrelic/stub_api')
14 |
15 | utils(tap)
16 |
17 | tap.test('Winston instrumentation', (t) => {
18 | t.autoend()
19 |
20 | const helper = utils.TestAgent.makeInstrumented()
21 | const winston = require('winston')
22 | const api = new API(helper.agent)
23 | // Keep track of the number of streams that we're waiting to close and test. Also clean
24 | // up the info object used by winston/logform to make it easier to test.
25 | function makeStreamTest(t) {
26 | let toBeClosed = 0
27 |
28 | // Assert function will receive log strings to be tested
29 | return function streamTest(assertFn) {
30 | // When creating a stream test, increment the number of streams to wait to close.
31 | ++toBeClosed
32 |
33 | // This function will be given to `concat` and will receive an array of messages
34 | // from Winston when the stream closes.
35 | return function (msgs) {
36 | // We only want the log string from the message object. This is stored on the
37 | // object on a key that is a symbol. Grab that and give it to the assert function.
38 | const logStrings = msgs.map((msg) => {
39 | const symbols = Object.getOwnPropertySymbols(msg)
40 | const msgSym = symbols.filter((s) => s.toString() === 'Symbol(message)')[0]
41 | return msg[msgSym]
42 | })
43 |
44 | assertFn(logStrings)
45 |
46 | // If this function is called it is because the stream closed. Decrement the
47 | // number of streams we're waiting for and end the test if it's the last one.
48 | if (--toBeClosed === 0) {
49 | t.end()
50 | }
51 | }
52 | }
53 | }
54 |
55 | // Helper function to compare a json-parsed log msg against the values we expect.
56 | function validateAnnotations(t, msg, expected) {
57 | Object.keys(expected).forEach((a) => {
58 | const ex = expected[a]
59 | t.type(msg[a], ex.type, `should have the proper keys (${a})`)
60 | if (ex.val != null) {
61 | t.equal(msg[a], ex.val, `should have the expected value (${a})`)
62 | }
63 | })
64 | }
65 |
66 | t.test('should add linking metadata to default logs', (t) => {
67 | const config = helper.agent.config
68 |
69 | // These values should be added by the instrumentation even when not in a transaction.
70 | const basicAnnotations = {
71 | 'entity.name': {
72 | type: 'string',
73 | val: config.applications()[0]
74 | },
75 | 'entity.type': {
76 | type: 'string',
77 | val: 'SERVICE'
78 | },
79 | 'hostname': {
80 | type: 'string',
81 | val: config.getHostnameSafe()
82 | }
83 | }
84 |
85 | // These should show up in the JSON via the combined formatters in the winston config.
86 | const loggingAnnotations = {
87 | timestamp: {
88 | type: 'number'
89 | }
90 | }
91 |
92 | // These will be assigned when inside a transaction below and should be in the JSON.
93 | let transactionAnnotations
94 |
95 | const streamTest = makeStreamTest(t)
96 |
97 | // These streams are passed to the Winston config below to capture the
98 | // output of the logging. `concat` captures all of a stream and passes it to
99 | // the given function.
100 | const jsonStream = concat(
101 | streamTest((msgs) => {
102 | msgs.forEach((msg) => {
103 | // Make sure the JSON stream actually gets JSON
104 | let msgJson
105 | t.doesNotThrow(() => (msgJson = JSON.parse(msg)), 'should be JSON')
106 |
107 | // Verify the proper keys are there
108 | validateAnnotations(t, msgJson, basicAnnotations)
109 | validateAnnotations(t, msgJson, loggingAnnotations)
110 |
111 | // Test that transaction keys are there if in a transaction
112 | if (msgJson.message === 'in trans') {
113 | validateAnnotations(t, msgJson, transactionAnnotations)
114 | }
115 | })
116 | })
117 | )
118 |
119 | const simpleStream = concat(
120 | streamTest((msgs) => {
121 | msgs.forEach((msg) => {
122 | t.throws(() => JSON.parse(msg), 'should not be json parsable')
123 | t.notOk(/timestamp/.exec(msg), 'should clean up timestamp generation')
124 | t.ok(/^info:.*trans$/.exec(msg), 'should not have metadata keys')
125 | })
126 | })
127 | )
128 |
129 | // Example Winston setup to test
130 | const logger = winston.createLogger({
131 | transports: [
132 | // Log to a stream so we can test the output
133 | new winston.transports.Stream({
134 | level: 'info',
135 | format: formatFactory(api, winston)(),
136 | stream: jsonStream
137 | }),
138 | new winston.transports.Stream({
139 | level: 'info',
140 | format: winston.format.simple(),
141 | stream: simpleStream
142 | })
143 | ]
144 | })
145 |
146 | // Log some stuff, both in and out of a transaction
147 | logger.info('out of trans')
148 |
149 | helper.runInTransaction('test', () => {
150 | logger.info('in trans')
151 |
152 | const metadata = api.getLinkingMetadata()
153 | // Capture info about the transaction that should show up in the logs
154 | transactionAnnotations = {
155 | 'trace.id': {
156 | type: 'string',
157 | val: metadata['trace.id']
158 | },
159 | 'span.id': {
160 | type: 'string',
161 | val: metadata['span.id']
162 | }
163 | }
164 |
165 | // Force the streams to close so that we can test the output
166 | jsonStream.end()
167 | simpleStream.end()
168 | })
169 | })
170 |
171 | t.test('should add linking metadata to JSON logs', (t) => {
172 | const config = helper.agent.config
173 |
174 | // These should show up in the JSON via the combined formatters in the winston config.
175 | const loggingAnnotations = {
176 | timestamp: {
177 | type: 'number'
178 | },
179 | original_timestamp: {
180 | type: 'string',
181 | val: new Date().getFullYear().toString()
182 | },
183 | label: {
184 | type: 'string',
185 | val: 'test'
186 | }
187 | }
188 |
189 | // These values should be added by the instrumentation even when not in a transaction.
190 | const basicAnnotations = {
191 | 'entity.name': {
192 | type: 'string',
193 | val: config.applications()[0]
194 | },
195 | 'entity.type': {
196 | type: 'string',
197 | val: 'SERVICE'
198 | },
199 | 'hostname': {
200 | type: 'string',
201 | val: config.getHostnameSafe()
202 | }
203 | }
204 |
205 | // These will be assigned when inside a transaction below and should be in the JSON.
206 | let transactionAnnotations
207 |
208 | const streamTest = makeStreamTest(t)
209 |
210 | // These streams are passed to the Winston config below to capture the
211 | // output of the logging. `concat` captures all of a stream and passes it to
212 | // the given function.
213 | const jsonStream = concat(
214 | streamTest((msgs) => {
215 | msgs.forEach((msg) => {
216 | // Make sure the JSON stream actually gets JSON
217 | let msgJson
218 | t.doesNotThrow(() => (msgJson = JSON.parse(msg)), 'should be JSON')
219 |
220 | // Verify the proper keys are there
221 | validateAnnotations(t, msgJson, basicAnnotations)
222 | validateAnnotations(t, msgJson, loggingAnnotations)
223 |
224 | // Test that transaction keys are there if in a transaction
225 | if (msgJson.message === 'in trans') {
226 | validateAnnotations(t, msgJson, transactionAnnotations)
227 | }
228 | })
229 | })
230 | )
231 |
232 | const simpleStream = concat(
233 | streamTest((msgs) => {
234 | msgs.forEach((msg) => {
235 | t.throws(() => JSON.parse(msg), 'should not be json parsable')
236 | t.notOk(/original_timestamp/.exec(msg), 'should clean up timestamp reassignment')
237 | t.ok(/^info:.*trans$/.exec(msg), 'should not have metadata keys')
238 | })
239 | })
240 | )
241 |
242 | // Example Winston setup to test
243 | const logger = winston.createLogger({
244 | transports: [
245 | // Log to a stream so we can test the output
246 | new winston.transports.Stream({
247 | level: 'info',
248 | // Format combos are used here to test that the shim doesn't affect
249 | // format piping
250 | format: winston.format.combine(
251 | winston.format.timestamp({ format: 'YYYY' }),
252 | winston.format.label({ label: 'test' }),
253 | formatFactory(api, winston)()
254 | ),
255 | stream: jsonStream
256 | }),
257 | new winston.transports.Stream({
258 | level: 'info',
259 | format: winston.format.simple(),
260 | stream: simpleStream
261 | })
262 | ]
263 | })
264 |
265 | // Log some stuff, both in and out of a transaction
266 | logger.info('out of trans')
267 |
268 | helper.runInTransaction('test', () => {
269 | logger.info('in trans')
270 |
271 | const metadata = api.getLinkingMetadata()
272 | // Capture info about the transaction that should show up in the logs
273 | transactionAnnotations = {
274 | 'trace.id': {
275 | type: 'string',
276 | val: metadata['trace.id']
277 | },
278 | 'span.id': {
279 | type: 'string',
280 | val: metadata['span.id']
281 | }
282 | }
283 |
284 | // Force the streams to close so that we can test the output
285 | jsonStream.end()
286 | simpleStream.end()
287 | })
288 | })
289 |
290 | t.test('should add error metadata to JSON logs', (t) => {
291 | // These should show up in the JSON via the combined formatters in the winston config.
292 | const annotations = {
293 | 'error.message': {
294 | type: 'string',
295 | val: 'test error message'
296 | },
297 | 'error.class': {
298 | type: 'string',
299 | val: 'TestError'
300 | },
301 | 'error.stack': {
302 | type: 'string'
303 | }
304 | }
305 |
306 | // These streams are passed to the Winston config below to capture the output of the
307 | // logging. `concat` captures all of a stream and passes it to the given function.
308 | const errorStream = concat(
309 | makeStreamTest(t)((msgs) => {
310 | msgs.forEach((msg) => {
311 | let msgJson
312 | t.doesNotThrow(() => (msgJson = JSON.parse(msg)), 'should be JSON')
313 | validateAnnotations(t, msgJson, annotations)
314 | t.ok(msgJson['error.message'], 'Error messages are captured')
315 | t.ok(msgJson['error.class'], 'Error classes are captured')
316 | t.ok(msgJson['error.stack'], 'Error stack traces are captured')
317 | t.notOk(msgJson.stack, 'Stack removed from JSON')
318 | t.notOk(msgJson.trace, 'trace removed from JSON')
319 | })
320 | })
321 | )
322 |
323 | // Example Winston setup to test
324 | winston.createLogger({
325 | // There is a bug in winston around piping exception handler data
326 | // into the underlying transport that skips the formatters. To
327 | // get around this, move the `exceptionHandlers` into `transports` and
328 | // set the `handleExceptions` option to `true`.
329 | transports: [
330 | new winston.transports.Stream({
331 | level: 'info',
332 | format: formatFactory(api, winston)(),
333 | handleExceptions: true,
334 | stream: errorStream
335 | })
336 | ],
337 | exitOnError: false
338 | })
339 |
340 | helper.runInTransaction('test', () => {
341 | // Simulate an error being thrown to trigger Winston's error handling
342 | class TestError extends Error {
343 | constructor(msg) {
344 | super(msg)
345 | this.name = 'TestError'
346 | }
347 | }
348 | process.emit('uncaughtException', new TestError('test error message'))
349 | const metadata = api.getLinkingMetadata()
350 |
351 | // Capture info about the transaction that should show up in the logs
352 | annotations['trace.id'] = { type: 'string', val: metadata['trace.id'] }
353 | annotations['span.id'] = { type: 'string', val: metadata['span.id'] }
354 |
355 | // Force the stream to close so that we can test the output
356 | errorStream.end()
357 | })
358 | })
359 |
360 | t.test('should still log user data when agent disabled', (t) => {
361 | // These should show up in the JSON via the combined formatters in the winston config.
362 | const loggingAnnotations = {
363 | timestamp: {
364 | type: 'string' // original format
365 | },
366 | label: {
367 | type: 'string',
368 | val: 'test'
369 | }
370 | }
371 |
372 | const streamTest = makeStreamTest(t)
373 |
374 | // These streams are passed to the Winston config below to capture the
375 | // output of the logging. `concat` captures all of a stream and passes it to
376 | // the given function.
377 | const jsonStream = concat(
378 | streamTest((msgs) => {
379 | tap.equal(msgs.length, 2)
380 | msgs.forEach((msg) => {
381 | // Make sure the JSON stream actually gets JSON
382 | let msgJson
383 | t.doesNotThrow(() => (msgJson = JSON.parse(msg)), 'should be JSON')
384 |
385 | // Verify the proper keys are there
386 | validateAnnotations(t, msgJson, loggingAnnotations)
387 | })
388 | })
389 | )
390 |
391 | const simpleStream = concat(
392 | streamTest((msgs) => {
393 | msgs.forEach((msg) => {
394 | t.throws(() => JSON.parse(msg), 'should not be json parsable')
395 | t.notOk(/original_timestamp/.exec(msg), 'should clean up timestamp reassignment')
396 | t.ok(/^info:.*trans$/.exec(msg), 'should not have metadata keys')
397 | })
398 | })
399 | )
400 |
401 | // Example Winston setup to test
402 | const logger = winston.createLogger({
403 | transports: [
404 | // Log to a stream so we can test the output
405 | new winston.transports.Stream({
406 | level: 'info',
407 | // Format combos are used here to test that the shim doesn't affect
408 | // format piping
409 | format: winston.format.combine(
410 | winston.format.timestamp({ format: 'YYYY' }),
411 | winston.format.label({ label: 'test' }),
412 | formatFactory(new StubApi(), winston)() // Stub API mimics disabled agent
413 | ),
414 | stream: jsonStream
415 | }),
416 | new winston.transports.Stream({
417 | level: 'info',
418 | format: winston.format.simple(),
419 | stream: simpleStream
420 | })
421 | ]
422 | })
423 |
424 | // Log some stuff, both in and out of a transaction
425 | logger.info('out of trans')
426 |
427 | helper.runInTransaction('test', () => {
428 | logger.info('in trans')
429 |
430 | // Force the streams to close so that we can test the output
431 | jsonStream.end()
432 | simpleStream.end()
433 | })
434 | })
435 | })
436 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/third_party_manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "lastUpdated": "Tue Jul 11 2023 15:54:24 GMT-0400 (Eastern Daylight Time)",
3 | "projectName": "@newrelic/winston-enricher",
4 | "projectUrl": "https://github.com/newrelic/newrelic-winston-logenricher-node",
5 | "includeOptDeps": false,
6 | "includeDev": true,
7 | "dependencies": {},
8 | "devDependencies": {
9 | "@newrelic/test-utilities@7.3.2": {
10 | "name": "@newrelic/test-utilities",
11 | "version": "7.3.2",
12 | "range": "^7.3.2",
13 | "licenses": "Apache-2.0",
14 | "repoUrl": "https://github.com/newrelic/node-test-utilities",
15 | "versionedRepoUrl": "https://github.com/newrelic/node-test-utilities/tree/v7.3.2",
16 | "licenseFile": "node_modules/@newrelic/test-utilities/LICENSE",
17 | "licenseUrl": "https://github.com/newrelic/node-test-utilities/blob/v7.3.2/LICENSE",
18 | "licenseTextSource": "file",
19 | "publisher": "New Relic Node.js agent team",
20 | "email": "nodejs@newrelic.com"
21 | },
22 | "concat-stream@2.0.0": {
23 | "name": "concat-stream",
24 | "version": "2.0.0",
25 | "range": "^2.0.0",
26 | "licenses": "MIT",
27 | "repoUrl": "https://github.com/maxogden/concat-stream",
28 | "versionedRepoUrl": "https://github.com/maxogden/concat-stream/tree/v2.0.0",
29 | "licenseFile": "node_modules/concat-stream/LICENSE",
30 | "licenseUrl": "https://github.com/maxogden/concat-stream/blob/v2.0.0/LICENSE",
31 | "licenseTextSource": "file",
32 | "publisher": "Max Ogden",
33 | "email": "max@maxogden.com"
34 | },
35 | "newrelic@10.3.2": {
36 | "name": "newrelic",
37 | "version": "10.3.2",
38 | "range": "^10.3.2",
39 | "licenses": "Apache-2.0",
40 | "repoUrl": "https://github.com/newrelic/node-newrelic",
41 | "versionedRepoUrl": "https://github.com/newrelic/node-newrelic/tree/v10.3.2",
42 | "licenseFile": "node_modules/newrelic/LICENSE",
43 | "licenseUrl": "https://github.com/newrelic/node-newrelic/blob/v10.3.2/LICENSE",
44 | "licenseTextSource": "file",
45 | "publisher": "New Relic Node.js agent team",
46 | "email": "nodejs@newrelic.com"
47 | },
48 | "tap@16.2.0": {
49 | "name": "tap",
50 | "version": "16.2.0",
51 | "range": "^16.2.0",
52 | "licenses": "ISC",
53 | "repoUrl": "https://github.com/tapjs/node-tap",
54 | "versionedRepoUrl": "https://github.com/tapjs/node-tap/tree/v16.2.0",
55 | "licenseFile": "node_modules/tap/LICENSE",
56 | "licenseUrl": "https://github.com/tapjs/node-tap/blob/v16.2.0/LICENSE",
57 | "licenseTextSource": "file",
58 | "publisher": "Isaac Z. Schlueter",
59 | "email": "i@izs.me",
60 | "url": "http://blog.izs.me"
61 | },
62 | "tsd@0.18.0": {
63 | "name": "tsd",
64 | "version": "0.18.0",
65 | "range": "^0.18.0",
66 | "licenses": "MIT",
67 | "repoUrl": "https://github.com/SamVerschueren/tsd",
68 | "versionedRepoUrl": "https://github.com/SamVerschueren/tsd/tree/v0.18.0",
69 | "licenseFile": "node_modules/tsd/license",
70 | "licenseUrl": "https://github.com/SamVerschueren/tsd/blob/v0.18.0/license",
71 | "licenseTextSource": "file",
72 | "publisher": "Sam Verschueren",
73 | "email": "sam.verschueren@gmail.com",
74 | "url": "https://github.com/SamVerschueren"
75 | },
76 | "winston@3.6.0": {
77 | "name": "winston",
78 | "version": "3.6.0",
79 | "range": "3.6.0",
80 | "licenses": "MIT",
81 | "repoUrl": "https://github.com/winstonjs/winston",
82 | "versionedRepoUrl": "https://github.com/winstonjs/winston/tree/v3.6.0",
83 | "licenseFile": "node_modules/winston/LICENSE",
84 | "licenseUrl": "https://github.com/winstonjs/winston/blob/v3.6.0/LICENSE",
85 | "licenseTextSource": "file",
86 | "publisher": "Charlie Robbins",
87 | "email": "charlie.robbins@gmail.com"
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/packages/winston-log-enricher/types/index.d.ts:
--------------------------------------------------------------------------------
1 | import winston = require('winston');
2 | declare function _default(winston: object): winston.Logform.FormatWrap;
3 | export default _default;
4 |
--------------------------------------------------------------------------------
/third_party_manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "lastUpdated": "Tue Jul 11 2023 15:54:22 GMT-0400 (Eastern Daylight Time)",
3 | "projectName": "New Relic Node.js Log Extensions",
4 | "projectUrl": "https://github.com/newrelic/newrelic-node-log-extensions",
5 | "includeOptDeps": false,
6 | "includeDev": true,
7 | "dependencies": {},
8 | "devDependencies": {
9 | "@newrelic/eslint-config@0.0.4": {
10 | "name": "@newrelic/eslint-config",
11 | "version": "0.0.4",
12 | "range": "^0.0.4",
13 | "licenses": "Apache-2.0",
14 | "repoUrl": "https://github.com/newrelic/eslint-config-newrelic",
15 | "versionedRepoUrl": "https://github.com/newrelic/eslint-config-newrelic/tree/v0.0.4",
16 | "licenseFile": "node_modules/@newrelic/eslint-config/LICENSE",
17 | "licenseUrl": "https://github.com/newrelic/eslint-config-newrelic/blob/v0.0.4/LICENSE",
18 | "licenseTextSource": "file",
19 | "publisher": "New Relic Node.js agent team",
20 | "email": "nodejs@newrelic.com"
21 | },
22 | "@newrelic/newrelic-oss-cli@0.1.2": {
23 | "name": "@newrelic/newrelic-oss-cli",
24 | "version": "0.1.2",
25 | "range": "^0.1.2",
26 | "licenses": "Apache-2.0",
27 | "repoUrl": "https://github.com/newrelic/newrelic-oss-cli",
28 | "versionedRepoUrl": "https://github.com/newrelic/newrelic-oss-cli/tree/v0.1.2",
29 | "licenseFile": "node_modules/@newrelic/newrelic-oss-cli/LICENSE",
30 | "licenseUrl": "https://github.com/newrelic/newrelic-oss-cli/blob/v0.1.2/LICENSE",
31 | "licenseTextSource": "file",
32 | "publisher": "New Relic"
33 | },
34 | "c8@7.12.0": {
35 | "name": "c8",
36 | "version": "7.12.0",
37 | "range": "^7.12.0",
38 | "licenses": "ISC",
39 | "repoUrl": "https://github.com/bcoe/c8",
40 | "versionedRepoUrl": "https://github.com/bcoe/c8/tree/v7.12.0",
41 | "licenseFile": "node_modules/c8/LICENSE.txt",
42 | "licenseUrl": "https://github.com/bcoe/c8/blob/v7.12.0/LICENSE.txt",
43 | "licenseTextSource": "file",
44 | "publisher": "Ben Coe",
45 | "email": "ben@npmjs.com"
46 | },
47 | "eslint-plugin-header@3.1.1": {
48 | "name": "eslint-plugin-header",
49 | "version": "3.1.1",
50 | "range": "^3.1.1",
51 | "licenses": "MIT",
52 | "repoUrl": "https://github.com/Stuk/eslint-plugin-header",
53 | "versionedRepoUrl": "https://github.com/Stuk/eslint-plugin-header/tree/v3.1.1",
54 | "licenseFile": "node_modules/eslint-plugin-header/README.md",
55 | "licenseUrl": "https://github.com/Stuk/eslint-plugin-header/blob/v3.1.1/README.md",
56 | "licenseTextSource": "spdx",
57 | "publisher": "Stuart Knightley"
58 | },
59 | "eslint-plugin-node@11.1.0": {
60 | "name": "eslint-plugin-node",
61 | "version": "11.1.0",
62 | "range": "^11.1.0",
63 | "licenses": "MIT",
64 | "repoUrl": "https://github.com/mysticatea/eslint-plugin-node",
65 | "versionedRepoUrl": "https://github.com/mysticatea/eslint-plugin-node/tree/v11.1.0",
66 | "licenseFile": "node_modules/eslint-plugin-node/LICENSE",
67 | "licenseUrl": "https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/LICENSE",
68 | "licenseTextSource": "file",
69 | "publisher": "Toru Nagashima"
70 | },
71 | "eslint-plugin-prettier@3.4.1": {
72 | "name": "eslint-plugin-prettier",
73 | "version": "3.4.1",
74 | "range": "^3.4.0",
75 | "licenses": "MIT",
76 | "repoUrl": "https://github.com/prettier/eslint-plugin-prettier",
77 | "versionedRepoUrl": "https://github.com/prettier/eslint-plugin-prettier/tree/v3.4.1",
78 | "licenseFile": "node_modules/eslint-plugin-prettier/LICENSE.md",
79 | "licenseUrl": "https://github.com/prettier/eslint-plugin-prettier/blob/v3.4.1/LICENSE.md",
80 | "licenseTextSource": "file",
81 | "publisher": "Teddy Katz"
82 | },
83 | "eslint@7.32.0": {
84 | "name": "eslint",
85 | "version": "7.32.0",
86 | "range": "^7.32.0",
87 | "licenses": "MIT",
88 | "repoUrl": "https://github.com/eslint/eslint",
89 | "versionedRepoUrl": "https://github.com/eslint/eslint/tree/v7.32.0",
90 | "licenseFile": "node_modules/eslint/LICENSE",
91 | "licenseUrl": "https://github.com/eslint/eslint/blob/v7.32.0/LICENSE",
92 | "licenseTextSource": "file",
93 | "publisher": "Nicholas C. Zakas",
94 | "email": "nicholas+npm@nczconsulting.com"
95 | },
96 | "husky@7.0.4": {
97 | "name": "husky",
98 | "version": "7.0.4",
99 | "range": "^7.0.4",
100 | "licenses": "MIT",
101 | "repoUrl": "https://github.com/typicode/husky",
102 | "versionedRepoUrl": "https://github.com/typicode/husky/tree/v7.0.4",
103 | "licenseFile": "node_modules/husky/LICENSE",
104 | "licenseUrl": "https://github.com/typicode/husky/blob/v7.0.4/LICENSE",
105 | "licenseTextSource": "file",
106 | "publisher": "Typicode",
107 | "email": "typicode@gmail.com"
108 | },
109 | "lerna@6.0.0": {
110 | "name": "lerna",
111 | "version": "6.0.0",
112 | "range": "^6.0.0",
113 | "licenses": "MIT",
114 | "repoUrl": "https://github.com/lerna/lerna",
115 | "versionedRepoUrl": "https://github.com/lerna/lerna/tree/v6.0.0",
116 | "licenseFile": "node_modules/lerna/LICENSE",
117 | "licenseUrl": "https://github.com/lerna/lerna/blob/v6.0.0/LICENSE",
118 | "licenseTextSource": "file",
119 | "publisher": "Sebastian McKenzie",
120 | "email": "sebmck@gmail.com"
121 | },
122 | "lint-staged@12.4.0": {
123 | "name": "lint-staged",
124 | "version": "12.4.0",
125 | "range": "^12.1.2",
126 | "licenses": "MIT",
127 | "repoUrl": "https://github.com/okonet/lint-staged",
128 | "versionedRepoUrl": "https://github.com/okonet/lint-staged/tree/v12.4.0",
129 | "licenseFile": "node_modules/lint-staged/LICENSE",
130 | "licenseUrl": "https://github.com/okonet/lint-staged/blob/v12.4.0/LICENSE",
131 | "licenseTextSource": "file",
132 | "publisher": "Andrey Okonetchnikov",
133 | "email": "andrey@okonet.ru"
134 | },
135 | "lockfile-lint@4.9.6": {
136 | "name": "lockfile-lint",
137 | "version": "4.9.6",
138 | "range": "^4.9.6",
139 | "licenses": "Apache-2.0",
140 | "repoUrl": "https://github.com/lirantal/lockfile-lint",
141 | "versionedRepoUrl": "https://github.com/lirantal/lockfile-lint/tree/v4.9.6",
142 | "licenseFile": "node_modules/lockfile-lint/LICENSE",
143 | "licenseUrl": "https://github.com/lirantal/lockfile-lint/blob/v4.9.6/LICENSE",
144 | "licenseTextSource": "file",
145 | "publisher": "Liran Tal",
146 | "email": "liran.tal@gmail.com",
147 | "url": "https://github.com/lirantal"
148 | },
149 | "prettier@2.6.2": {
150 | "name": "prettier",
151 | "version": "2.6.2",
152 | "range": "^2.4.1",
153 | "licenses": "MIT",
154 | "repoUrl": "https://github.com/prettier/prettier",
155 | "versionedRepoUrl": "https://github.com/prettier/prettier/tree/v2.6.2",
156 | "licenseFile": "node_modules/prettier/LICENSE",
157 | "licenseUrl": "https://github.com/prettier/prettier/blob/v2.6.2/LICENSE",
158 | "licenseTextSource": "file",
159 | "publisher": "James Long"
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------