Skip to content

Commit

Permalink
pinpoint-apm#92 update v1 protocol compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Sep 12, 2023
1 parent ee9395b commit 6cc1e52
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 96 deletions.
8 changes: 2 additions & 6 deletions grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ $ export PATH="$PATH:$(npm bin -g)"
$ grpc_tools_node_protoc --version
libprotoc 3.14.0
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` Span.proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` Service.proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` Cmd.proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` Annotation.proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` Stat.proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../ --grpc_out=grpc_js:../ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` ThreadDump.proto
$ cd grpc-idl/proto
$ grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../../../lib/data --grpc_out=grpc_js:../../../lib/data --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` v1/*.proto
```
2 changes: 1 addition & 1 deletion lib/client/grpc-data-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const grpc = require('@grpc/grpc-js')
const log = require('../utils/logger')
const services = require('../data/grpc/Service_grpc_pb')
const services = require('../data/v1/Service_grpc_pb')
const dataConvertor = require('../data/grpc-data-convertor')
const pingIdGenerator = require('../context/sequence-generator').pingIdGenerator
const GrpcBidirectionalStream = require('./grpc-bidirectional-stream')
Expand Down
24 changes: 12 additions & 12 deletions lib/context/span-chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

'use strict'

const spanMessages = require('../data/grpc/Span_pb')
const {convertTransactionId, convertLocalAsyncId} = require('../data/grpc-data-convertor')
const spanMessages = require('../data/v1/Span_pb')
const { convertTransactionId, convertLocalAsyncId } = require('../data/grpc-data-convertor')
const SpanEvents = require('./span-events')

class SpanChunk {
constructor (traceId, agentInfo, asyncId, spanEventList) {
constructor(traceId, agentInfo, asyncId, spanEventList) {
if (!traceId || !agentInfo) {
throw new Error('Can not initialize SpanChunk', traceId, agentInfo)
}
Expand All @@ -29,44 +29,44 @@ class SpanChunk {
this.localAsyncId = asyncId
}

static getFactoryMethod (agentInfo, traceId) {
static getFactoryMethod(agentInfo, traceId) {
return (spanEventList) => new SpanChunk(agentInfo, traceId, null, spanEventList)
}

static getAsyncFactoryMethod (agentInfo, traceId, asyncId) {
static getAsyncFactoryMethod(agentInfo, traceId, asyncId) {
return (spanEventList) => new SpanChunk(agentInfo, traceId, asyncId, spanEventList)
}

get spanMessage() {
const pSpanMessage = new spanMessages.PSpanMessage()
const pSpanChunk = new spanMessages.PSpanChunk()
pSpanChunk.setVersion(1);
pSpanChunk.setVersion(1)

const pTransactionId = convertTransactionId(this.transactionIdObject)
pSpanChunk.setTransactionid(pTransactionId);
pSpanChunk.setTransactionid(pTransactionId)

pSpanChunk.setSpanid(this.spanId)
pSpanChunk.setEndpoint(this.endPoint)
pSpanChunk.setApplicationservicetype(this.applicationServiceType)
pSpanChunk.setLocalasyncid(convertLocalAsyncId(this.localAsyncId))

const keyTime = this.keyTime
pSpanChunk.setKeytime(keyTime)

const spanEvents = new SpanEvents(this.spanEventList)
const pSpanEvents = spanEvents.getpSpanEvents(keyTime)
if (pSpanEvents.length > 0) {
pSpanEvents.forEach(pSpanEvent => pSpanChunk.addSpanevent(pSpanEvent))
}

pSpanMessage.setSpanchunk(pSpanChunk)
return pSpanMessage
}

get keyTime() {
const minStartTimeSpanEvent = this.spanEventList.reduce((minStartTimeSpanEvent, currentSpanEvent) => minStartTimeSpanEvent.startTime < currentSpanEvent.startTime ? minStartTimeSpanEvent : currentSpanEvent)
if (!minStartTimeSpanEvent) {
return 0;
return 0
}
return minStartTimeSpanEvent.startTime
}
Expand Down
4 changes: 2 additions & 2 deletions lib/context/span-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

'use strict'

const {convertIntStringValue, convertNextEvent, addAnnotations} = require('../data/grpc-data-convertor')
const spanMessages = require('../data/grpc/Span_pb')
const { convertIntStringValue, convertNextEvent, addAnnotations } = require('../data/grpc-data-convertor')
const spanMessages = require('../data/v1/Span_pb')

class SpanEvents {
constructor(spanEvents) {
Expand Down
18 changes: 9 additions & 9 deletions lib/context/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

'use strict'

const {convertTransactionId, convertAcceptEvent, convertIntStringValue, addAnnotations} = require('../data/grpc-data-convertor')
const spanMessages = require('../data/grpc/Span_pb')
const { convertTransactionId, convertAcceptEvent, convertIntStringValue, addAnnotations } = require('../data/grpc-data-convertor')
const spanMessages = require('../data/v1/Span_pb')
const SpanEvents = require('./span-events')

class Span {
constructor (traceId, agentInfo, requestData = {}) {
constructor(traceId, agentInfo, requestData = {}) {
if (!traceId || !agentInfo) {
throw new Error('Can not initialize Span', traceId, agentInfo)
}
Expand Down Expand Up @@ -42,13 +42,13 @@ class Span {
this.parentApplicationType = requestData.parentApplicationType
}

markElapsedTime () {
markElapsedTime() {
if (this.startTime) {
this.elapsedTime = Date.now() - this.startTime
}
}

get elapsed () {
get elapsed() {
return this.elapsedTime
}

Expand All @@ -57,12 +57,12 @@ class Span {
const pSpanMessage = new spanMessages.PSpanMessage()
const pSpan = new spanMessages.PSpan()
pSpan.setVersion(1)

if (this.traceId) {
const pTransactionId = convertTransactionId(this.traceId.transactionId)
pSpan.setTransactionid(pTransactionId)
}

pSpan.setSpanid(this.spanId)
pSpan.setParentspanid(this.parentSpanId)
pSpan.setStarttime(this.startTime)
Expand All @@ -75,14 +75,14 @@ class Span {
pSpan.setExceptioninfo(convertIntStringValue(this.exceptionInfo))
pSpan.setApplicationservicetype(this.applicationServiceType)
pSpan.setLoggingtransactioninfo(this.loggingTransactionInfo)

const spanEvents = new SpanEvents(this.spanEventList)
const pSpanEvents = spanEvents.getpSpanEvents(this.startTime)
if (pSpanEvents.length > 0) {
pSpanEvents.forEach(pSpanEvent => pSpan.addSpanevent(pSpanEvent))
}
addAnnotations(pSpan, this.annotations)

pSpanMessage.setSpan(pSpan)
return pSpanMessage
}
Expand Down
20 changes: 10 additions & 10 deletions lib/data/grpc-data-convertor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

'use strict'

const statMessages = require('./grpc/Stat_pb')
const spanMessages = require('./grpc/Span_pb')
const annotationMessages = require('./grpc/Annotation_pb')
const cmdMessages = require('./grpc/Cmd_pb')
const statMessages = require('./v1/Stat_pb')
const spanMessages = require('./v1/Span_pb')
const annotationMessages = require('./v1/Annotation_pb')
const cmdMessages = require('./v1/Cmd_pb')
const wrappers = require('google-protobuf/google/protobuf/wrappers_pb')

const convertAgentInfo = (agentInfo) => {
Expand Down Expand Up @@ -93,7 +93,7 @@ const convertTransactionId = (transactionId) => {
pTransactionId.setAgentid(transactionId.agentId)
pTransactionId.setAgentstarttime(transactionId.agentStartTime)
pTransactionId.setSequence(transactionId.sequence)
return pTransactionId
return pTransactionId
}

const convertParentInfo = (span) => {
Expand Down Expand Up @@ -192,11 +192,11 @@ const convertStringStringValue = (value) => {
return null
}
const pStringStringValue = new annotationMessages.PStringStringValue()

const stringValue1 = new wrappers.StringValue()
stringValue1.setValue(value.stringValue1)
pStringStringValue.setStringvalue1(stringValue1)

const stringValue2 = new wrappers.StringValue()
stringValue2.setValue(value.stringValue2)
pStringStringValue.setStringvalue2(stringValue2)
Expand Down Expand Up @@ -245,11 +245,11 @@ const convertStat = (stat) => {
return null
}
const pStatMessage = new statMessages.PStatMessage()

const pAgentStat = new statMessages.PAgentStat()
pAgentStat.setTimestamp(stat.timestamp)
pAgentStat.setCollectinterval(stat.collectInterval)

const pCpuLoad = new statMessages.PCpuLoad()
pCpuLoad.setJvmcpuload(stat.cpu.user)
pCpuLoad.setSystemcpuload(stat.cpu.system)
Expand All @@ -270,7 +270,7 @@ const convertStat = (stat) => {

const count = stat.activeTrace.fastCount + stat.activeTrace.normalCount + stat.activeTrace.slowCount + stat.activeTrace.verySlowCount
pActiveTraceHistogram.addActivetracecount(count)

pActiveTrace.setHistogram(pActiveTraceHistogram)
}

Expand Down
16 changes: 8 additions & 8 deletions lib/data/typed-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@
'use strict'

const ValuedType = require('../constant/valued-type').ValuedType
const annotationMessages = require('./grpc/Annotation_pb')
const {convertStringStringValue} = require('./grpc-data-convertor')
const annotationMessages = require('./v1/Annotation_pb')
const { convertStringStringValue } = require('./grpc-data-convertor')

class TypedValue {
constructor(value, valuedType) {
switch (typeof value) {
case 'number':
this.intValue = value
break;
break
case 'boolean':
this.boolValue = value
break;
break
case 'string':
this.stringValue = value
break;
break
case 'object':
if (valuedType === ValuedType.stringStringValue) {
this.stringStringValue = value
}
break;
break
case 'undefined':
this.stringValue = value
break;
break
}
}

static of (value) {
static of(value) {
return new TypedValue(value)
}

Expand Down
Loading

0 comments on commit 6cc1e52

Please sign in to comment.