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

Support "unlimited" limit values #2636

Closed
MrAlias opened this issue Feb 23, 2022 · 3 comments · Fixed by #2637
Closed

Support "unlimited" limit values #2636

MrAlias opened this issue Feb 23, 2022 · 3 comments · Fixed by #2637
Assignees

Comments

@MrAlias
Copy link
Contributor

MrAlias commented Feb 23, 2022

Span limit value can be "unlimited". This concept is not currently supported in the SpanLimits

func (sl *SpanLimits) ensureDefault() {
if sl.EventCountLimit <= 0 {
sl.EventCountLimit = DefaultEventCountLimit
}
if sl.AttributeCountLimit <= 0 {
sl.AttributeCountLimit = DefaultAttributeCountLimit
}
if sl.LinkCountLimit <= 0 {
sl.LinkCountLimit = DefaultLinkCountLimit
}
if sl.AttributePerEventCountLimit <= 0 {
sl.AttributePerEventCountLimit = DefaultAttributePerEventCountLimit
}
if sl.AttributePerLinkCountLimit <= 0 {
sl.AttributePerLinkCountLimit = DefaultAttributePerLinkCountLimit
}
}

Proposal

Accept negative values as being infinite.

This seems to be a common approach in other Go code, and is a stated reason many types use int instead of uint.

Recognized issues with approach

  • The environment variable values are invalid if negative and would need to be translated. Given invalid values would be treated as unset values and use the default, this does not pose a real issue.
  • This will be a change in current behavior. This behavior, using default values if negative, is undocumented. Changing and documenting the new approach will not change the API.

Alternatives

Use math.MaxInt.

  • This would not be the same as infinite as there would be no way to determine if "no limit" should be applied or the maximal limit. This would be a rare situation.
  • This would be a unique way to define infinite. I do not know any other code that does this.
@MrAlias MrAlias added this to the Release v1.5.0 milestone Feb 23, 2022
@MrAlias
Copy link
Contributor Author

MrAlias commented Feb 23, 2022

It also seems like 0 needs to be a supported value. It is stated as a supported value for the OpenTelemetry specification.

If we were to support accepting these values, using the WithSpanLimits option to pass partial SpanLimits would be problematic. The unset values would default to 0, now a valid value. It seems like adding a func DefaultSpanLimits() SpanLimits function that returns a SpanLimits struct with the defaults already applied to all fields would be useful.

@Aneurysm9
Copy link
Member

  • The environment variable values are invalid if negative and would need to be translated. Given invalid values would be treated as unset values and use the default, this does not pose a real issue.

I'm not sure I follow here. Are values received from environment variables not strings that would need to be converted to integers with strconv.Atoi()? That should handle negative values just fine.

@MrAlias
Copy link
Contributor Author

MrAlias commented Feb 23, 2022

I'm not sure I follow here. Are values received from environment variables not strings that would need to be converted to integers with strconv.Atoi()? That should handle negative values just fine.

Right, but the specification considers negative values for environment variables as invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants