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.
- type: boolean
- Can be set by using an environment variable 'POSTMAN_SDK_ENABLE' , which will over-ride any other config
- debug: Enable debug logger
- truncateData: 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.
- redactSensitiveData: Regex rules to redact data from requests.
- type: { enable: true/false, 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')
}
})