Skip to content

Commit

Permalink
Merge branch 'main' into update-spec-construction
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 authored Apr 2, 2024
2 parents a4656eb + df2a0fd commit 6fc4584
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 91 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/versioned-security-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,49 @@ on:
required: false
schedule:
- cron: '0 9 * * 1-5'
pull_request:
branches:
- main

jobs:
should_run:
# Used to determine if the `@newrelic/security-agent` dependency has
# been updated in any new pull requests. This job _must_ always run because
# the `security-agent-tests` job depends on the outputs of this job. Thus,
# we cannot put a conditional on this job to only run if the event name
# is "pull_request".
name: Should Run
runs-on: ubuntu-latest
outputs:
previous_version: ${{steps.versions.outputs.PREVIOUS_VAL}}
current_version: ${{steps.versions.outputs.CURRENT_VAL}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: tj-actions/changed-files@v44
id: changed_files
with:
files: package.json
- name: Get dependency versions
id: versions
if: steps.changed_files.outputs.any_changed == 'true'
run: |
current_val=$(cat package.json | jq -r --arg pkg "@newrelic/security-agent" '.dependencies[$pkg]')
echo "current_val=${current_val}" >> $GITHUB_OUTPUT
git checkout origin/${{github.base_ref}}
previous_val=$(cat package.json | jq -r --arg pkg "@newrelic/security-agent" '.dependencies[$pkg]')
echo "previous_val=${previous_val}" >> $GITHUB_OUTPUT
git checkout ${{github.sha}}
security-agent-tests:
needs: [should_run]
if: github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
needs.should_run.outputs.previous_version != needs.should_run.outputs.current_version

runs-on: ubuntu-latest

strategy:
Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ SOFTWARE.

### @newrelic/security-agent

This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v1.0.1](https://github.com/newrelic/csec-node-agent/tree/v1.0.1)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v1.0.1/LICENSE):
This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v1.1.1](https://github.com/newrelic/csec-node-agent/tree/v1.1.1)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v1.1.1/LICENSE):

```
## New Relic Software License v1.0
Expand Down
4 changes: 2 additions & 2 deletions bin/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const git = require('./git-commands')
const npm = require('./npm-commands')

const PROPOSED_NOTES_HEADER = 'Proposed Release Notes'
const FORCE_RUN_DEAFULT_REMOTE = 'origin'
const FORCE_RUN_DEFAULT_REMOTE = 'origin'

// Add command line options
program.addOption(
Expand Down Expand Up @@ -80,7 +80,7 @@ async function prepareReleaseNotes() {
stopOnError()
}

const remote = options.remote || FORCE_RUN_DEAFULT_REMOTE
const remote = options.remote || FORCE_RUN_DEFAULT_REMOTE
console.log('Using remote: ', remote)

try {
Expand Down
3 changes: 2 additions & 1 deletion jsdoc-conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"readme": "./README.md",
"template": "./node_modules/clean-jsdoc-theme",
"theme_opts": {
"search": false
"search": false,
"shouldRemoveScrollbarStyle": true
}
},
"source": {
Expand Down
2 changes: 0 additions & 2 deletions lib/llm-events/langchain/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LangChainEvent extends BaseEvent {
appName
span_id
request_id
transaction_id
trace_id
ingest_source = 'Node'
vendor = 'langchain'
Expand All @@ -60,7 +59,6 @@ class LangChainEvent extends BaseEvent {
this.appName = agent.config.applications()[0]
this.span_id = segment?.id
this.request_id = params.runId
this.transaction_id = segment?.transaction?.id
this.trace_id = segment?.transaction?.traceId
this.langchainMeta = params.metadata
this.metadata = agent
Expand Down
1 change: 0 additions & 1 deletion lib/llm-events/openai/chat-completion-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = class LlmChatCompletionSummary extends LlmEvent {
this['request.max_tokens'] = request.max_tokens
this['request.temperature'] = request.temperature
this['response.number_of_messages'] = request?.messages?.length + response?.choices?.length
this['response.usage.completion_tokens'] = response?.usage?.completion_tokens
this['response.choices.finish_reason'] = response?.choices?.[0]?.finish_reason
}
}
3 changes: 0 additions & 3 deletions lib/llm-events/openai/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = class LlmEvent extends BaseEvent {
this.request_id = response?.headers?.['x-request-id']
this.trace_id = segment?.transaction?.traceId
this.span_id = segment?.id
this.transaction_id = segment?.transaction?.id
this['response.model'] = response.model
this.vendor = 'openai'
this.ingest_source = 'Node'
Expand All @@ -38,8 +37,6 @@ module.exports = class LlmEvent extends BaseEvent {

responseAttrs(response) {
this['response.organization'] = response?.headers?.['openai-organization']
this['response.usage.total_tokens'] = response?.usage?.total_tokens
this['response.usage.prompt_tokens'] = response?.usage?.prompt_tokens
this['response.headers.llmVersion'] = response?.headers?.['openai-version']
this['response.headers.ratelimitLimitRequests'] =
response?.headers?.['x-ratelimit-limit-requests']
Expand Down
59 changes: 22 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"@newrelic/aws-sdk": "^7.3.0",
"@newrelic/koa": "^9.1.0",
"@newrelic/ritm": "^7.2.0",
"@newrelic/security-agent": "1.0.1",
"@newrelic/security-agent": "^1.1.1",
"@newrelic/superagent": "^7.0.1",
"@tyriar/fibonacci-heap": "^2.0.7",
"concat-stream": "^2.0.0",
Expand All @@ -223,7 +223,7 @@
"ajv": "^6.12.6",
"async": "^3.2.4",
"c8": "^8.0.1",
"clean-jsdoc-theme": "^4.2.4",
"clean-jsdoc-theme": "^4.2.18",
"commander": "^7.0.0",
"conventional-changelog-conventionalcommits": "^5.0.0",
"conventional-changelog-writer": "^5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ tap.beforeEach((t) => {
t.context.segment = {
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
}
}
Expand All @@ -63,7 +62,6 @@ tap.test('creates entity', async (t) => {
['llm.conversation_id']: 'test-conversation',
span_id: 'segment-1',
request_id: 'run-1',
transaction_id: 'tx-1',
trace_id: 'trace-1',
['metadata.foo']: 'foo',
ingest_source: 'Node',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ tap.beforeEach((t) => {
t.context.segment = {
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
},
getDurationInMillis() {
Expand All @@ -57,7 +56,6 @@ tap.test('creates entity', async (t) => {
['llm.conversation_id']: 'test-conversation',
span_id: 'segment-1',
request_id: 'run-1',
transaction_id: 'tx-1',
trace_id: 'trace-1',
['metadata.foo']: 'foo',
ingest_source: 'Node',
Expand Down
2 changes: 0 additions & 2 deletions test/unit/llm-events/langchain/event.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ tap.beforeEach((t) => {
t.context.segment = {
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
}
}
Expand All @@ -57,7 +56,6 @@ tap.test('constructs default instance', async (t) => {
['llm.conversation_id']: 'test-conversation',
span_id: 'segment-1',
request_id: 'run-1',
transaction_id: 'tx-1',
trace_id: 'trace-1',
['metadata.foo']: 'foo',
ingest_source: 'Node',
Expand Down
2 changes: 0 additions & 2 deletions test/unit/llm-events/langchain/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ tap.beforeEach((t) => {
},
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
}
}
Expand All @@ -69,7 +68,6 @@ tap.test('constructs default instance', async (t) => {
id: /[a-z0-9-]{36}/,
appName: 'test-app',
span_id: 'segment-1',
transaction_id: 'tx-1',
trace_id: 'trace-1',
duration: 1.01,
['metadata.foo']: 'foo',
Expand Down
2 changes: 0 additions & 2 deletions test/unit/llm-events/langchain/vector-search-result.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ tap.beforeEach((t) => {
t.context.segment = {
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
},
getDurationInMillis() {
Expand Down Expand Up @@ -74,7 +73,6 @@ tap.test('create entity', async (t) => {
['llm.conversation_id']: 'test-conversation',
request_id: 'run-1',
span_id: 'segment-1',
transaction_id: 'tx-1',
trace_id: 'trace-1',
['metadata.foo']: 'foo',
ingest_source: 'Node',
Expand Down
2 changes: 0 additions & 2 deletions test/unit/llm-events/langchain/vector-search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ tap.beforeEach((t) => {
t.context.segment = {
id: 'segment-1',
transaction: {
id: 'tx-1',
traceId: 'trace-1'
},
getDurationInMillis() {
Expand All @@ -64,7 +63,6 @@ tap.test('create entity', async (t) => {
['llm.conversation_id']: 'test-conversation',
'request_id': 'run-1',
'span_id': 'segment-1',
'transaction_id': 'tx-1',
'trace_id': 'trace-1',
'ingest_source': 'Node',
'vendor': 'langchain',
Expand Down
4 changes: 0 additions & 4 deletions test/unit/llm-events/openai/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function getExpectedResult(tx, event, type, completionId) {
'request_id': 'req-id',
'trace_id': tx.traceId,
'span_id': trace.children[0].id,
'transaction_id': tx.id,
'response.model': 'gpt-3.5-turbo-0613',
'vendor': 'openai',
'ingest_source': 'Node'
Expand All @@ -60,8 +59,6 @@ function getExpectedResult(tx, event, type, completionId) {
'duration': trace.children[0].getDurationInMillis(),
'request.model': 'gpt-3.5-turbo-0613',
'response.organization': 'new-relic',
'response.usage.total_tokens': '30',
'response.usage.prompt_tokens': '10',
'response.headers.llmVersion': '1.0.0',
'response.headers.ratelimitLimitRequests': '100',
'response.headers.ratelimitLimitTokens': '100',
Expand All @@ -84,7 +81,6 @@ function getExpectedResult(tx, event, type, completionId) {
['request.max_tokens']: '1000000',
['request.temperature']: 'medium-rare',
['response.number_of_messages']: 3,
['response.usage.completion_tokens']: 20,
['response.choices.finish_reason']: 'stop',
error: false
}
Expand Down
Loading

0 comments on commit 6fc4584

Please sign in to comment.