opentelemetry-specification
opentelemetry-specification copied to clipboard
Semantic conventions for language bindings API calls
I have a Node.JS app which uses module written in C++. I need to pass spans from one language to another, in both directions. I cannot pass parent span directly, so I use Inject on one side and Extract on the another one. This is conceptually similar to RPC, so I can follow Semantic conventions for RPC spans and create following spans on both sides:
SpanName: "MyModule/MyFunc"
SpanKind: CLIENT or SERVER
rpc.system: "node_api"
rpc.service: "MyModule"
rpc.method: "MyFunc"
net.peer.name: ""
net.transport: "inproc"
However there is one case which is not addressed there: NodeJS code passes callback function to C++ code, where it is stored and called later when needed. In this case method name is not known when call is made - for C++ code this is some anonymous method. The closest thing which can be used instead is name assigned on C++ side, like NodeStatusCallback
or NodeErrorCallback
.
Please review this use case and update specification accordingly.
Do you really need this information? You can also create spans without attributes if you just need these spans for linking.
Also note that rpc.* should be set to logical names. The code.* attributes might be better suited.
@sirzooro I believe the general solution would be to create a new FFI-based SDK for NodeJS, which forwards all API calls to the C++ SDK. We have never tried this, but in theory it should work. Since the new SDK would just be a bridge layer to C++, the implementation should not require a huge amount of code.
Way back in the day, we built one of these for Python, based on the OpenTracing API. You can look at that for reference if it's helpful: https://github.com/lightstep/python-bridge-tracer