[Playground] OTLP-Mapper - instana to otlp span mapper#2534
[Playground] OTLP-Mapper - instana to otlp span mapper#2534abhilash-sivan wants to merge 12 commits into
Conversation
4490ab0 to
f1c0d6f
Compare
53e1fcc to
d261bc5
Compare
| // console.log(JSON.stringify(otlpFormat)); | ||
|
|
||
| const payloadAsString = JSON.stringify(otlpFormat, circularReferenceRemover()); | ||
| const payloadAsString = JSON.stringify(data, circularReferenceRemover()); |
There was a problem hiding this comment.
Doing the conversion from spanBuffer
| * @param {import('../../core').InstanaBaseSpan} span | ||
| * @returns {import('../../core').InstanaBaseSpan} The transformed span. | ||
| */ | ||
| module.exports.transform = span => { |
There was a problem hiding this comment.
the same transform logic, like we already do for instana internal format to backend compatible conversion
| 'use strict'; | ||
|
|
||
| // Gespeicherte Resource-Informationen für Metrics (wenn kein "from" Feld vorhanden) | ||
| const { getOtlpAttributeMappings } = require('./backend_mappers/otlpMapper'); |
There was a problem hiding this comment.
moved the file to core
|
|
||
| const otlpKey = sectionMappings[field] || `${dataKey}.${field}`; | ||
|
|
||
| // Determine value type and format |
There was a problem hiding this comment.
This attribute addition is optional
| if (normalized.length > 32) { | ||
| return normalized.slice(-32); | ||
| } | ||
| return normalized.padStart(32, '0'); |
There was a problem hiding this comment.
prepending with 0s due to the length mismatch for traceId.
We currently use 16, but otel uses 32
| spans = []; | ||
| batchingBuckets.clear(); | ||
|
|
||
| const processedSpans = |
There was a problem hiding this comment.
This is where the conversion is happening.
This seems to be the optimal place because if we convert early, then in some places we talk Instana format and it could raise unexpected issues. So before transmission seems simple and maintanable
There was a problem hiding this comment.
Should we do this here or just after the current BE transformation,
https://github.com/instana/nodejs/pull/2534/changes?utm_source=chatgpt.com#diff-462ace70d7ac6eb4cd6f82756059c88629bfad1463fde0498d89106d7ccc8104L193
Right now we’re applying the transformation after collecting all spans. IMO it would be cleaner to do it before calling transmitSpans, so the transmit layer only deals with already-transformed spans.
TBD
There was a problem hiding this comment.
Yeah, I agree. This would be a more cleaner way
// Transform internal span data format into external (backend) readable format.
span = applySpanTransformation(span);
Just after this transformation, we can call the Otel transformation.
There was a problem hiding this comment.
One thing we have to consider is that currently all the spans intended for transmission — i.e., the array of spans — are converted together. If we do it in the above-mentioned area, we will have to process the spans individually.
There was a problem hiding this comment.
Note: TBD — Transform each span to OTLP format immediately in addSpan and store them in OTLP format in the buffer if batching is enabled. This would require changes to the batching logic.
There was a problem hiding this comment.
How do you want to organize the agent ports etc?
OTLP mode is on -> port will change.
There is something missing.
There was a problem hiding this comment.
Also:
How can we skip the agent announcement cycle when connecting to an otel collector later?
Did you draw that path as well to confirm the architecture?
There was a problem hiding this comment.
No, I haven’t worked much on the architecture yet. I can work on the dynamic port connections part, and I’ll also think through the agent announcement cycle and how we can skip it when connecting to an OTel collector
| const agentOpts = require('./agent/opts'); | ||
| const cmdline = require('./cmdline'); | ||
| const otlpTransformer = require('./otlpTransformer'); | ||
| const otlpTransformer = require('@instana/core/src/tracing/otlpTransformer'); |
There was a problem hiding this comment.
Could you please reset the file? I think no changes needed as part of this playground, right?
There was a problem hiding this comment.
Yeah, no major changes here. Only the relevant change is removing the Otel span transforming logic from this file
| }; | ||
| return createSafeTransform(mapper.transform); | ||
| }, | ||
| get otlpTransform() { |
There was a problem hiding this comment.
This is not a backend mapper.
Could you please move this unit to an otlp mapper folder?
The folder will have multiple files later.
| }, | ||
|
|
||
| // resource but added for ui view, without this .. ? | ||
| service: { |
There was a problem hiding this comment.
I don't think this is right? Service is part of resource attrs?
This needs to be communicated in the next WG. Traces & Metrics mapping is required. |

UI: https://instana.io/s/B2R0pfHbSpaV5jXmQNDd7w
This is just a playground where we convert Instana spans to Otel spans and send them to the Otel backend.
INSTANA_OTLP_FORMAT=true SERVICE_NAME=test-nodejs-service INSTANA_DEBUG=true node index.jshttps://instana.io/s/Ehe2Zhb7QyKyxrmQg0fK8Q The BE uses path_tpl or url values ot show in the UI, so we mapped the otel span name to the same data from Instana span.