[Playground] OTLP-Mapper - instana to otlp span mapper#2534
[Playground] OTLP-Mapper - instana to otlp span mapper#2534abhilash-sivan wants to merge 90 commits into
Conversation
4490ab0 to
f1c0d6f
Compare
53e1fcc to
d261bc5
Compare
This needs to be communicated in the next WG. Traces & Metrics mapping is required. |
08a2757 to
e827e9c
Compare
e827e9c to
d6c01a6
Compare
| @@ -0,0 +1,145 @@ | |||
| /* | |||
There was a problem hiding this comment.
This is the future design in my mind now
└── otlp/
├── index.js ← Entry point (exports transform())
├── converter.js ← Core conversion logic
├── constants.js ← Metric types, aggregation types
├── util.js ← Helper functions
├── transformers/
│ ├── index.js
│ ├── resourceAttributes.js ← Service name, SDK info, host, PID
│ └── metricData.js ← Metric value transformation
└── mappers/
└── metricAttributes.js
Share your thoughts 💭
|
|
||
| downstreamConnection.sendMetrics(payload, onMetricsHaveBeenSent.bind(null, isFullTransmission, newValueToTransmit)); | ||
| // Convert to OTLP format if needed (before sending to agentConnection) | ||
| const isOtlpFormat = process.env.INSTANA_OTLP_FORMAT === 'true'; |
| * @param {number} instanaSpanKind | ||
| */ | ||
| function convertSpanKind(instanaSpanKind) { | ||
| if (instanaSpanKind === 1) return SPAN_KINDS.SERVER; |
There was a problem hiding this comment.
In future maybe we need to check if the span is any messaging lib, and map to producer/consumer span kind
There was a problem hiding this comment.
Todo: we can extend later, no urgency
| const isOtlpFormat = options.isOtlpFormat; | ||
|
|
||
| if (isOtlpFormat) { | ||
| sendData('/v1/metrics', data, err => { |
There was a problem hiding this comment.
It's not still clean approach. I will come up with a better approach later
| spans = []; | ||
| batchingBuckets.clear(); | ||
|
|
||
| const payload = prepareSpansForExport(spansToSend); |
There was a problem hiding this comment.
issue: we still transform twice for OTLP. I can't find the TODO in the list.
There was a problem hiding this comment.
Oops 😃, I thought we had agreed to leave the internal mapping refactoring for later.
There was a problem hiding this comment.
Its not a refacotring?
Its only:
internal format -> spanBuffer -> isOTLP ? transform internal to otlp : transform internal to be/instana
| * @returns {any} | ||
| */ | ||
| function prepareSpansForExport(spansToSend) { | ||
| if (process.env.INSTANA_OTLP_FORMAT === 'true') { |
There was a problem hiding this comment.
Lets add a TODO to read the configs in the config area.
I only found a verify task
The configuration option to enable the OTLP format, INSTANA_OTLP_ENABLED or?
There was a problem hiding this comment.
It was the config support task after all. I'll tidy up the task list and remove any confusion there.
| @@ -0,0 +1,170 @@ | |||
| # OTLP (OpenTelemetry Protocol) Converter | |||
There was a problem hiding this comment.
qs: Why is the OTLP module not part of the tracing folder?
There was a problem hiding this comment.
This module handles all telemetry signals- Traces, Metrics, and Logs. Placing it under the tracing folder would unnecessarily couple it to tracing-specific concepts such as spans. Keeping it at the root allows the logic to remain shared and signal-agnostic. It also provides flexibility for future enhancements, such as extending the OTLP implementation to emit additional telemetry signals like logs.
There was a problem hiding this comment.
IMO it belongs to core/tracing/exporters
There was a problem hiding this comment.
We can discuss this before merging. No big topic
| }; | ||
|
|
||
| const originFrom = rawSpan.data?.resource || null; | ||
| const rKey = resourceFactory.getResourceKey(originFrom); |
There was a problem hiding this comment.
const originFrom = rawSpan.data?.resource || null; const rKey = resourceFactory.getResourceKey(originFrom);
This looks wrong to me? 🤔
This must be rawSpan.f?
There was a problem hiding this comment.
Any instana span has .f - doesn't matter if its coming from ours instrumentations or from otel integration.
|
|
||
| let group = resourceGroupMap.get(rKey); | ||
|
|
||
| if (!group) { |
There was a problem hiding this comment.
I can't follow this whole logic 🤔
Why do we need to group the spans by resource?
What is the actual case? The spans are generated on the same process.
| const resourceGroupMap = new Map(); | ||
|
|
||
| spans.forEach(rawSpan => { | ||
| if (isLogSpan(rawSpan)) { |
There was a problem hiding this comment.
| if (isLogSpan(rawSpan)) { | |
| // TODO: Add log span converter | |
| if (isLogSpan(rawSpan)) { |
|
|
||
| // 1.23 matches baseline parameters identically. No overrides required. | ||
|
|
||
| const LOOKUP_OVERRIDES = {}; |
There was a problem hiding this comment.
// base loopup based on v1.23 with some common mappings as well
Okay I understood the current sem conv structure. So yeah the base mappings are secretly from v1.23.
I'd like to suggest this:
index.js
const VERSIONS = {
'1.23': require('./v1.23'), // explicit version
'1.42': require('./v1.42') // explicit version
};Three folders
- base/
- mappings.js
- v1.23/
- index.js
- mappings.js
- v1.43/
- index.js
- mappings.js
- merge.js
base/mappings.js
module.exports = require('../v1.23/mappings');v1.23/mappings.js
const MAPPINGS = {
metadata: {
TRACE_ID: 'traceId',
...v1.23/index.js
const { merge } = require('../merge');
const base = require('../base/mappings').MAPPINGS;
const { MAPPINGS } = require('./mappings');
module.exports = merge(base, MAPPINGS);
v1.41/index.js
const { merge } = require('../merge');
const base = require('../base/mappings').MAPPINGS;
const { MAPPINGS } = require('./mappings');
module.exports = merge(base, MAPPINGS);
v1.41/mappings.js
const MAPPINGS = {
http: {
REQUEST_METHOD: 'http.request.method',
RESPONSE_STATUS: 'http.response.status_code',
...The concept of overrides === merge.
Summary
Introduces the Instana-to-OTLP Converter Playground.
4318/v1/traces).Out of Scope
TODO
Core Implementation
span.data.peer,span.data.mongo)INSTANA_OTLP_ENABLED?) - NOT PART OF THISSpan Data Mapping
Testing
Unit Tests
End-to-End Testing (@abhilash-sivan)
Performance Testing
Special Cases
Issue Tracking
Validation Checklist
Before merging, verify the following:
4318/v1/traces).Future Enhancements/TODO
/v1/logsendpoint.References