Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Span attributes value length limit ignored for attributes passed to the Span constructor #4416

Closed
Bataran opened this issue Jan 15, 2024 · 2 comments · Fixed by #4417
Closed
Assignees
Labels
bug Something isn't working has:reproducer This bug/feature has a minimal reproducer provided pkg:sdk-trace-base priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@Bataran
Copy link
Contributor

Bataran commented Jan 15, 2024

What happened?

Steps to Reproduce

Install the packages defined in the package.json:
npm i

Run the sample app with script:
npm run startWithEnv

Expected Result

Span has 2 attributes attr1 and attr2 with truncated values "myval"

Actual Result

Span has attr1 attribute with non truncated value "myvalue" and attr2 attribute with truncated value "myval.

Additional Details

Attributes passed to the Span constructor are not truncated with the limit defined by OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT while the attributes passed to span.setAttributes() are. The issue seems to be introduced with the 1.19.0 version of @opentelemetry/sdk-trace-base

OpenTelemetry Setup Code

// bug.js
const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base');

new BasicTracerProvider().register();

const span = opentelemetry.trace
	.getTracer('default')
	.startSpan('foo', {
		attributes: {
			attr1: "myvalue"
		}
	});

span.setAttribute('attr2', 'myvalue');

// the span has attr1 with non-truncated value "myvalue"
// and attr2 with truncated value "myval"
// when the script is run with OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT=5
console.log(`span.attributes.attr1 => ${span.attributes.attr1}`)
console.log(`span.attributes.attr2 => ${span.attributes.attr2}`)

span.end();

package.json

{
  "name": "bug-sample",
  "version": "0.0.1",
  "description": "bug sample",
  "main": "bug.js",
  "scripts": {
    "startWithEnv": "env OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT=5 node bug.js"
  },
  "dependencies": {
    "@opentelemetry/api": "1.7.0",
    "@opentelemetry/sdk-trace-base": "1.19.0"
  }
}

Relevant log output

> but-sample@0.0.1 startWithEnv
> env OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT=5 node bug.js

span.attributes.attr1 => myvalue
span.attributes.attr2 => myval
@Bataran Bataran added bug Something isn't working triage labels Jan 15, 2024
@pichlermarc pichlermarc added priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect pkg:sdk-trace-base has:reproducer This bug/feature has a minimal reproducer provided and removed triage labels Jan 15, 2024
@pichlermarc pichlermarc self-assigned this Jan 15, 2024
@pichlermarc
Copy link
Member

pichlermarc commented Jan 15, 2024

Yep, looks like that's introduced with 1.19.0. The attributes are set before the limit is set in the span implementation. I'll assign this to myself.

@pichlermarc
Copy link
Member

pichlermarc commented Jan 15, 2024

Opened #4417 to take care of this, thanks for the report @Bataran 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has:reproducer This bug/feature has a minimal reproducer provided pkg:sdk-trace-base priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
2 participants