Skip to content

Optionally trim attribute keys & values? #339

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

Closed
fbogsany opened this issue Aug 26, 2020 · 3 comments
Closed

Optionally trim attribute keys & values? #339

fbogsany opened this issue Aug 26, 2020 · 3 comments
Labels

Comments

@fbogsany
Copy link
Contributor

Related to open-telemetry/opentelemetry-specification#504

Java provides optional attribute value truncation: https://github.com/open-telemetry/opentelemetry-java/blob/a021a59b9433691c06ab2265b4c574eab825b0ed/sdk/tracing/src/main/java/io/opentelemetry/sdk/trace/SpanBuilderSdk.java#L195-L197

    if (traceConfig.shouldTruncateStringAttributeValues()) {
      value = StringUtils.truncateToSize(value, traceConfig.getMaxLengthOfAttributeValues());
    }

We have some ad-hoc truncation and UTF8 validation in the Redis instrumentation, for example:

def truncate(string, size)
string.size > size ? "#{string[0...size - 3]}..." : string
end
def utf8_encode(str, options = {})
str = str.to_s
if options[:binary]
# This option is useful for "gracefully" displaying binary data that
# often contains text such as marshalled objects
str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
elsif str.encoding == ::Encoding::UTF_8
str
else
str.encode(::Encoding::UTF_8)
end
rescue StandardError => e
OpenTelemetry.logger.debug("Error encoding string in UTF-8: #{e}")
options.fetch(:placeholder, STRING_PLACEHOLDER)
end

It is likely worth extracting this into a common utility module, and implementing attribute truncation in a single place with a configurable limit (most likely in the SDK Span class).

@plantfansam
Copy link
Contributor

I believe this issue has been addressed. Should we close or is there more to do here?

@fbogsany
Copy link
Contributor Author

fbogsany commented Mar 8, 2022

I think #1136 is relevant here.

Copy link
Contributor

👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot.

@github-actions github-actions bot added the stale label Apr 27, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants