-
Notifications
You must be signed in to change notification settings - Fork 979
Description
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
"dependencies": {
"@opentelemetry/api": "^1.0.4",
"@opentelemetry/auto-instrumentations-node": "^0.30.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.29.2",
"@opentelemetry/resources": "^1.0.1",
"@opentelemetry/sdk-node": "^0.29.2",
"@opentelemetry/semantic-conventions": "^1.0.1",
}
What version of Node are you using?
v18
Please provide the code you used to setup the OpenTelemetry SDK
"use strict";
const { v4: uuidv4 } = require("uuid");
const process = require("process");
const opentelemetry = require("@opentelemetry/sdk-node");
const { getNodeAutoInstrumentations } = require("@opentelemetry/auto-instrumentations-node");
const { Resource } = require("@opentelemetry/resources");
const { SemanticResourceAttributes } = require("@opentelemetry/semantic-conventions");
const { OTLPTraceExporter } = require("@opentelemetry/exporter-trace-otlp-proto");
const api = require("@opentelemetry/api");
const resource = new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "OpenTelemetry-Node.JS-Example",
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
});
const instrumentations = [getNodeAutoInstrumentations()];
const traceExporter = new OTLPTraceExporter();
const sdk = new opentelemetry.NodeSDK({
resource,
traceExporter,
instrumentations,
});
sdk
.start()
.then(() => console.log("Tracing initialized"))
.catch((error) => console.log("Error initializing tracing", error));
process.on("SIGTERM", () => {
sdk
.shutdown()
.then(() => console.log("Tracing terminated"))
.catch((error) => console.log("Error terminating tracing", error))
.finally(() => process.exit(0));
});What did you do?
I exported:
export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=10
What did you expect to see?
Span {
attributes: {
'http.url': 'http://localhost:8080/ping',
'http.host': 'localhost:8080',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.target': '/ping',
'http.user_agent': 'curl/7.79.1',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
truncate: 'AAAAAAAAAA',
'net.host.ip': '::ffff:127.0.0.1',
'net.host.port': 8080,
'net.peer.ip': '::ffff:127.0.0.1',
'net.peer.port': 49760,
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/ping'
},
links: [],
events: [],
status: { code: 1 },
endTime: [ 1655492924, 26444923 ],
_ended: true,
_duration: [ 0, 14500293 ],
name: 'GET /ping',
_spanContext: {
traceId: 'f720a0ec04fdd436065273eb3b008a73',
spanId: '69959269e8c1c594',
traceFlags: 1,
traceState: undefined
},
parentSpanId: undefined,
kind: 1,
startTime: [ 1655492924, 11944630 ],
resource: Resource { attributes: [Object] },
instrumentationLibrary: { name: '@opentelemetry/instrumentation-http', version: '0.27.0' },
_spanLimits: {
attributeValueLengthLimit: 10,
attributeCountLimit: 128,
linkCountLimit: 128,
eventCountLimit: 128
},
_spanProcessor: MultiSpanProcessor { _spanProcessors: [Array] },
_attributeValueLengthLimit: 10
}What did you see instead?
Span {
attributes: {
'http.url': 'http://localhost:8080/ping',
'http.host': 'localhost:8080',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.target': '/ping',
'http.user_agent': 'curl/7.79.1',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
truncate: 'AAAAAAAAAABBBBBBBBBBBBB',
'net.host.ip': '::ffff:127.0.0.1',
'net.host.port': 8080,
'net.peer.ip': '::ffff:127.0.0.1',
'net.peer.port': 49671,
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/ping'
},
links: [],
events: [],
status: { code: 1 },
endTime: [ 1655492500, 698490926 ],
_ended: true,
_duration: [ 0, 15013167 ],
name: 'GET /ping',
_spanContext: {
traceId: 'fc51aae0c8ed3fe2d09337c8e0435ff0',
spanId: '49e5a1f7c580441b',
traceFlags: 1,
traceState: undefined
},
parentSpanId: undefined,
kind: 1,
startTime: [ 1655492500, 683477759 ],
resource: Resource { attributes: [Object] },
instrumentationLibrary: {
name: '@opentelemetry/instrumentation-http',
version: '0.27.0',
schemaUrl: undefined
},
_spanLimits: {
attributeValueLengthLimit: Infinity,
attributeCountLimit: 128,
linkCountLimit: 128,
eventCountLimit: 128
},
_spanProcessor: MultiSpanProcessor { _spanProcessors: [Array] },
_attributeValueLengthLimit: Infinity
}As you can see, the _attributeValueLengthLimitproperty in the span is still set to Infinity and truncate has a value longer than 10.
Additional context
This issue is happening with v1.1.0 in this package: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base
When I was using @opentelemetry/sdk-node": "0.28.0" and higher, the issue started happening and v28 started using @opentelemetry-sdk-trace-base v1.2.0.
@opentelemetry/sdk-node v0.27.0 was using @opentelemetry-sdk-trace-base v1.1.0 and there was no issue with attribute limit.
There was a change with attribute limits in this pr: #2678 but I haven't looked at it thoroughly to confirm it if this is where the bug is coming from.
To avoid this issue when using @opentelemetry-sdk-trace-base v1.2.0, a user has to set the limit programmatically like so:
const sdk = new opentelemetry.NodeSDK({
resource,
traceExporter,
instrumentations,
spanLimits: {
attributeValueLengthLimit: 10
}
});