Skip to content

Commit

Permalink
Rename rasp metrics (#4635)
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua authored Aug 28, 2024
1 parent ba0442f commit b19b382
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/dd-trace/src/appsec/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ function updateRaspRequestsMetricTags (metrics, req, raspRuleType) {
if (!enabled) return

const tags = { rule_type: raspRuleType, waf_version: metrics.wafVersion }
appsecMetrics.count('appsec.rasp.rule.eval', tags).inc(1)
appsecMetrics.count('rasp.rule.eval', tags).inc(1)

if (metrics.wafTimeout) {
appsecMetrics.count('appsec.rasp.timeout', tags).inc(1)
appsecMetrics.count('rasp.timeout', tags).inc(1)
}

if (metrics.ruleTriggered) {
appsecMetrics.count('appsec.rasp.rule.match', tags).inc(1)
appsecMetrics.count('rasp.rule.match', tags).inc(1)
}
}

Expand Down
24 changes: 12 additions & 12 deletions packages/dd-trace/test/appsec/telemetry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,41 +162,41 @@ describe('Appsec Telemetry metrics', () => {
})

describe('updateRaspRequestsMetricTags', () => {
it('should increment appsec.rasp.rule.eval metric', () => {
it('should increment rasp.rule.eval metric', () => {
appsecTelemetry.updateRaspRequestsMetricTags({
duration: 42,
durationExt: 52
}, req, 'rule-type')

expect(count).to.have.been.calledWith('appsec.rasp.rule.eval')
expect(count).to.not.have.been.calledWith('appsec.rasp.timeout')
expect(count).to.not.have.been.calledWith('appsec.rasp.rule.match')
expect(count).to.have.been.calledWith('rasp.rule.eval')
expect(count).to.not.have.been.calledWith('rasp.timeout')
expect(count).to.not.have.been.calledWith('rasp.rule.match')
expect(inc).to.have.been.calledOnceWith(1)
})

it('should increment appsec.rasp.timeout metric if timeout', () => {
it('should increment rasp.timeout metric if timeout', () => {
appsecTelemetry.updateRaspRequestsMetricTags({
duration: 42,
durationExt: 52,
wafTimeout: true
}, req, 'rule-type')

expect(count).to.have.been.calledWith('appsec.rasp.rule.eval')
expect(count).to.have.been.calledWith('appsec.rasp.timeout')
expect(count).to.not.have.been.calledWith('appsec.rasp.rule.match')
expect(count).to.have.been.calledWith('rasp.rule.eval')
expect(count).to.have.been.calledWith('rasp.timeout')
expect(count).to.not.have.been.calledWith('rasp.rule.match')
expect(inc).to.have.been.calledTwice
})

it('should increment appsec.rasp.rule.match metric if ruleTriggered', () => {
it('should increment rasp.rule.match metric if ruleTriggered', () => {
appsecTelemetry.updateRaspRequestsMetricTags({
duration: 42,
durationExt: 52,
ruleTriggered: true
}, req, 'rule-type')

expect(count).to.have.been.calledWith('appsec.rasp.rule.match')
expect(count).to.have.been.calledWith('appsec.rasp.rule.eval')
expect(count).to.not.have.been.calledWith('appsec.rasp.timeout')
expect(count).to.have.been.calledWith('rasp.rule.match')
expect(count).to.have.been.calledWith('rasp.rule.eval')
expect(count).to.not.have.been.calledWith('rasp.timeout')
expect(inc).to.have.been.calledTwice
})

Expand Down

0 comments on commit b19b382

Please sign in to comment.