-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dynamodb): added endpoint filtering (#1484)
refs INSTA-16323
- Loading branch information
1 parent
ce5c9d8
commit 93e4023
Showing
11 changed files
with
370 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* @typedef {Object<string, string>} FieldMapping | ||
* @typedef {Object<string, FieldMapping>} FieldMappings | ||
*/ | ||
|
||
/** | ||
* Field mappings for different span types. | ||
* | ||
* This FieldMappings defines how internal span fields are mapped to backend fields | ||
* for various span types (e.g., dynamodb, redis). | ||
* | ||
* As new span types needs to add, simply add their respective mappings | ||
* following the same format (e.g., 'internal-field': 'backend-field'). | ||
* | ||
* @type {FieldMappings} | ||
*/ | ||
const fieldMappings = { | ||
dynamodb: { | ||
/// Maps internal field 'operation' to backend field 'op' | ||
operation: 'op' | ||
}, | ||
redis: { | ||
operation: 'command' | ||
} | ||
}; | ||
|
||
/** | ||
* Transforms span data fields to match the backend format. | ||
* | ||
* @param {import('../../core').InstanaBaseSpan} span | ||
* @returns {import('../../core').InstanaBaseSpan} The transformed span. | ||
*/ | ||
module.exports.transform = span => { | ||
const spanName = span.n; | ||
const mappings = fieldMappings[spanName]; | ||
// If no mappings exist for the span name or the span data, return the original span | ||
if (!mappings || !span.data[spanName]) return span; | ||
|
||
Object.keys(span.data[spanName]).forEach(internalField => { | ||
// Only proceed if there's a mapping for the internal field in the current span type | ||
if (internalField in mappings) { | ||
const backendField = mappings[internalField]; | ||
|
||
if (backendField) { | ||
span.data[spanName][backendField] = span.data[spanName][internalField]; | ||
delete span.data[spanName][internalField]; | ||
} else { | ||
// If backendField is falsy, remove the internalField from span data | ||
delete span.data[spanName][internalField]; | ||
} | ||
} | ||
}); | ||
|
||
return span; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.