Skip to content

Commit

Permalink
[pinpoint-apm#243] Fix API Metadata gRPC stream error
Browse files Browse the repository at this point in the history
* Support Send Messages by local gRPC Fixtures a Server
  • Loading branch information
feelform committed Dec 17, 2024
1 parent 7c15f3a commit e8b6d72
Show file tree
Hide file tree
Showing 19 changed files with 740 additions and 622 deletions.
66 changes: 25 additions & 41 deletions demo/express/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"morgan": "~1.9.1",
"mysql": "^2.18.1",
"mysql2": "^3.9.1",
"pinpoint-node-agent": "^0.8.4"
"pinpoint-node-agent": "^0.8.6"
}
}
4 changes: 3 additions & 1 deletion demo/express/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ router.get('/', async function(req, res, next) {
const json = await response.json()
console.log(json)

res.render('index', { title: 'Express' });
setTimeout(() => {
res.render('index', { title: 'Express' })
}, 1000)
})

router.get('/api', function(req, res, next) {
Expand Down
8 changes: 5 additions & 3 deletions lib/client/call-arguments-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class CallArguments {

const DEFAULT_CLIENT_REQUEST_TIMEOUT = 6000
class CallArgumentsBuilder {
static emptyCallArguments = new CallArgumentsBuilder().build()

static emptyCallArguments() {
return new CallArgumentsBuilder().build()
}

constructor(callback) {
this.callback = callback
this.metadata = new grpc.Metadata()
Expand All @@ -56,7 +58,7 @@ class CallArgumentsBuilder {
const callArguments = new CallArguments(this.callback)
callArguments.metadata = this.metadata
callArguments.options = this.options
callArguments.deadlineMilliseconds = this.deadlineMilliseconds || DEFAULT_CLIENT_REQUEST_TIMEOUT
callArguments.deadlineMilliseconds = this.deadlineMilliseconds ?? DEFAULT_CLIENT_REQUEST_TIMEOUT
return callArguments
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/client/grpc-data-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ module.exports = GrpcDataSender

function guardCallArguments(callArguments) {
if (!callArguments) {
return CallArgumentsBuilder.emptyCallArguments
return CallArgumentsBuilder.emptyCallArguments()
}

if (typeof callArguments === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion lib/data/grpc-data-convertor.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const convertMessageEvent = (spanEvent) => {

const addAnnotations = (target, annotations) => {
if (annotations && annotations.length > 0) {
annotations.forEach(annotation => {
annotations.forEach(annotation => {
const pAnnotation = convertAnnotation(annotation)
if (pAnnotation) {
target.addAnnotation(pAnnotation)
Expand Down
2 changes: 1 addition & 1 deletion lib/instrumentation/http-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.instrumentRequest2 = function (agent) {
const trace = requestTrace.makeTrace()
return localStorage.run(trace, () => {
endOfStream(res, function (err) {
const spanRecorder = trace.spanRecorder
const spanRecorder = trace.getSpanRecorder()
if (err) {
const end = res.end
res.end = function () {
Expand Down
Loading

0 comments on commit e8b6d72

Please sign in to comment.