Skip to content

Commit

Permalink
pinpoint-apm#92 mock datasender
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Sep 12, 2023
1 parent 01ced0c commit 9ccf0d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion grpc/grpc-idl
Submodule grpc-idl updated 1 files
+5 −5 proto/v1/Span.proto
1 change: 0 additions & 1 deletion test/instrumentation/module/express.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const DefaultAnnotationKey = require('../../../lib/constant/annotation-key').Def
const apiMetaService = require('../../../lib/context/api-meta-service')
const MethodDescriptorBuilder = require('../../../lib/context/method-descriptor-builder')
const dataSenderMock = require('../../support/data-sender-mock')
apiMetaService.init(dataSenderMock())

const TEST_ENV = {
host: 'localhost',
Expand Down
6 changes: 4 additions & 2 deletions test/support/agent-singleton-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const httpShared = require('../../lib/instrumentation/http-shared')
const traceContext = require('../../lib/context/trace-context')
const contextManager = require('../../lib/context/context-manager')
const activeTrace = require('../../lib/metric/active-trace')
const apiMetaService = require('../../lib/context/api-meta-service')

class MockAgent extends Agent {
startSchedule(agentId, agentStartTime) {
Expand All @@ -31,6 +32,7 @@ class MockAgent extends Agent {

bindHttp(json) {
this.cleanHttp()
apiMetaService.init(dataSenderMock())

if (!json) {
json = require('../pinpoint-config-test')
Expand All @@ -43,7 +45,7 @@ class MockAgent extends Agent {
const http = require('http')
log.debug('shimming http.Server.prototype.emit function')
shimmer.wrap(http && http.Server && http.Server.prototype, 'emit', httpShared.instrumentRequest(agent, 'http'))

log.debug('shimming http.request function')
shimmer.wrap(http, 'request', httpShared.traceOutgoingRequest(agent, 'http'))

Expand All @@ -69,7 +71,7 @@ class MockAgent extends Agent {
this.traceContext = traceContext.init(this.agentInfo, this.dataSender, this.config)
}

cleanHttp() {
cleanHttp() {
const http = require('http')
shimmer.unwrap(http && http.Server && http.Server.prototype, 'emit')
shimmer.unwrap(http, 'request')
Expand Down

0 comments on commit 9ccf0d6

Please sign in to comment.