pinpoint-node-agent
Version:
Pinpoint node agent provided by NAVER
23 lines (19 loc) • 642 B
JavaScript
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
const grpc = require('@grpc/grpc-js')
const InterceptingCall = grpc.InterceptingCall
const SequenceGenerator = require('../../context/sequence-generator')
const pingIdGenerator = new SequenceGenerator()
const socketIdInterceptor = function (options, nextCall) {
return new InterceptingCall(nextCall(options), {
start: function (metadata, listener, next) {
metadata.add('socketid', `${pingIdGenerator.next}`)
next(metadata, listener, next)
}
})
}
module.exports = socketIdInterceptor