About
This SDK instrument express/sails app using OpenTelemetry. It captures the http request/response and uses them for auto-generating accurate postman collections
Installation
npm install @postman/postman-sdk
At the top of your app.js file, before app is initialized add this.
initialize({
collectionId: 'postman-collection-id'
apiKey: '<your-postman-api-key>'
});
Configuration
SDK's initialization can be configured with these values
- collectionId: Postman collectionId where requests will be added.
- apiKey: Postman api key needed for collector
- receiverBaseUrl: Where the data should be shipped to collector's http endpoint.
- bufferIntervalInMilliseconds: Time interval for data queueing. Export is triggered after every interval.
- type: number
- default: 5000
- enable: enable or disable tracing.
- debug: Enable debug logger
- dataTruncation: Changes data in request/response body from {key: value} to {key: { type: typeof(value) } }
- type: boolean
- default: false
- environment: Instrumentation environment development/prod etc. ( implementation TO-DO)
- configFilePath: Path to config YAML file.
- dataRedactions: Regex rules to redact data from requests.
- type: { rules: { ruleName: ''}}
Example
initialize(
collectionId: '<postmanCollectionId>'
apiKey: '<apiKey>',
dataRedaction: { rules: {
apiToken: 'PMAK-[a-f0-9]' // Sample rule, you can add your own regex
}}
)
- ignoreIncomingRequests: Apply logic on requests to ignore them from Live Collection
Example
initialize({
...otherParams,
ignoreIncomingRequests: (request) => {
return request.url.includes('knockknock')
}
})
- ignoreOutgoingingRequests: Apply logic on requests to ignore them from Live Collection
Example
initialize({
...otherParams,
ignoreOutgoingRequests: (request) => {
return request.headers['User-Agent'].includes('ignoreme')
}
})