Add support for the Attribute limits and Span limits environment variables
Feature Request
Is your feature request related to a problem?
The dotnet SDK does not support limiting attributes and spans based on the OpenTelemetry specification. As a result, customers cannot use the SDK to automatically limit attributes and spans. When attributes or spans are not limited, they may end up being dropped by vendors due to their size.
Describe the solution you'd like:
The SDK relies on the specification-defined environment variables to truncate attributes and spans.
Additional Context
There are a lot of different environment variables. If this needs to be broken into separate issues for each environment variable let me know.
I am going to start working on this.
I've got the SpanLimits class created and tested, but I'm struggling to decide where to do the actual truncation. Other languages do it when setting attributes but I haven't been able to find the equivalent spot in the dotnet SDK. Any opinions?
@cijothomas Could you describe how you implement this? Activity class is part of the .NET runtime repo, so it must be added there, not in this repo.
Do you mean this capability to truncate would actually live in .Net itself and not it the SDK?
I thought the SDK specification implied that the ability to limit should be configurable in the SDK so thats where I created the SpanLimits class, following other languages examples. I have not actually used the SpanLimits class anywhere though. I'm working in this fork if you're interested in seeing what I've done so far.
Do you mean this capability to truncate would actually live in .Net itself and not it the SDK?
Yes. SDK can contain the configuration, but it must be passed to the Activity class itself to enforce it.
In an effort to provide a solution for customers while we wait for this to be added in the .Net runtime I am going to experiment with a processor in the SDK that can do the truncation.
We just reviewed this with the .NET team. They aren't going to prioritize this work for now because it doesn't seem like many folks are asking for it.
Seeing logs dropped by my vendor due to the size of some exception messages. It’s unfortunate we cannot limit the attribute length.
Seeing logs dropped by my vendor due to the size of some exception messages. It’s unfortunate we cannot limit the attribute length.
You can leverage this https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol#attribute-limits
This issue is somewhat misleading now, as this capability is offered not by the SDK, but as part of OTLP Exporting.
Interesting. I’ve tried adding OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT set to 4095 to an Azure Function’s environment variables but am not seeing it limit log message bodies. Should I be using that one or OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT
There should be nothing specific about Azure Functions that prevent it from working there! If you can share a minimal repro, we can help find if there is any issue in the way it is configured (or we have a bug!)
Ignore my above comment. There are no limits to LogRecord's body today, and that is a gap in the spec as well : https://github.com/open-telemetry/opentelemetry-specification/issues/4006
This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.