Skip to content

Commit 5a3f144

Browse files
authored
Add recording of basic rpc span type (#112)
1 parent 9fa3051 commit 5a3f144

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

instana/json_span.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Data(object):
3131
http = None
3232
rabbitmq = None
3333
redis = None
34+
rpc = None
3435
sdk = None
3536
service = None
3637
sqlalchemy = None
@@ -86,6 +87,20 @@ def __init__(self, **kwds):
8687
self.__dict__.update(kwds)
8788

8889

90+
class RPCData(object):
91+
flavor = None
92+
host = None
93+
port = None
94+
call = None
95+
call_type = None
96+
params = None
97+
baggage = None
98+
error = None
99+
100+
def __init__(self, **kwds):
101+
self.__dict__.update(kwds)
102+
103+
89104
class SQLAlchemyData(object):
90105
sql = None
91106
url = None

instana/recorder.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import instana.singletons
1313

1414
from .json_span import (CustomData, Data, HttpData, JsonSpan, MySQLData,
15-
RabbitmqData, RedisData, SDKData, SoapData,
15+
RabbitmqData, RedisData, RPCData, SDKData, SoapData,
1616
SQLAlchemyData)
1717
from .log import logger
1818

@@ -124,6 +124,16 @@ def build_registered_span(self, span):
124124
error=span.tags.pop('redis.error', None),
125125
subCommands=span.tags.pop('subCommands', None))
126126

127+
if span.operation_name == "rpc-client" or span.operation_name == "rpc-server":
128+
data.rpc = RPCData(flavor=span.tags.pop('rpc.flavor', None),
129+
host=span.tags.pop('rpc.host', None),
130+
port=span.tags.pop('rpc.port', None),
131+
call=span.tags.pop('rpc.call', None),
132+
call_type=span.tags.pop('rpc.call_type', None),
133+
params=span.tags.pop('rpc.params', None),
134+
baggage=span.tags.pop('rpc.baggage', None),
135+
error=span.tags.pop('rpc.error', None))
136+
127137
if span.operation_name == "sqlalchemy":
128138
data.sqlalchemy = SQLAlchemyData(sql=span.tags.pop('sqlalchemy.sql', None),
129139
eng=span.tags.pop('sqlalchemy.eng', None),
@@ -142,7 +152,7 @@ def build_registered_span(self, span):
142152
tskey = list(data.custom.logs.keys())[0]
143153
data.mysql.error = data.custom.logs[tskey]['message']
144154

145-
entityFrom = {'e': instana.singletons.agent.from_.pid,
155+
entity_from = {'e': instana.singletons.agent.from_.pid,
146156
'h': instana.singletons.agent.from_.agentUuid}
147157

148158
json_span = JsonSpan(n=span.operation_name,
@@ -151,7 +161,7 @@ def build_registered_span(self, span):
151161
s=span.context.span_id,
152162
ts=int(round(span.start_time * 1000)),
153163
d=int(round(span.duration * 1000)),
154-
f=entityFrom,
164+
f=entity_from,
155165
data=data)
156166

157167
if span.stack:
@@ -182,7 +192,7 @@ def build_sdk_span(self, span):
182192

183193
sdk_data.Type = self.get_span_kind(span)
184194
data = Data(service=self.get_service_name(span), sdk=sdk_data)
185-
entityFrom = {'e': instana.singletons.agent.from_.pid,
195+
entity_from = {'e': instana.singletons.agent.from_.pid,
186196
'h': instana.singletons.agent.from_.agentUuid}
187197

188198
json_span = JsonSpan(
@@ -192,7 +202,7 @@ def build_sdk_span(self, span):
192202
ts=int(round(span.start_time * 1000)),
193203
d=int(round(span.duration * 1000)),
194204
n="sdk",
195-
f=entityFrom,
205+
f=entity_from,
196206
data=data)
197207

198208
error = span.tags.pop("error", False)

0 commit comments

Comments
 (0)