-
Notifications
You must be signed in to change notification settings - Fork 772
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
[sdk-logs] Keep LogRecord.State & LogRecord.Attributes in sync if either is updated by a log processor #5169
[sdk-logs] Keep LogRecord.State & LogRecord.Attributes in sync if either is updated by a log processor #5169
Conversation
…ted by a log processor.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #5169 +/- ##
==========================================
+ Coverage 83.37% 83.45% +0.08%
==========================================
Files 297 297
Lines 12386 12398 +12
==========================================
+ Hits 10327 10347 +20
+ Misses 2059 2051 -8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using AttributeData as a underlying cache to keep State and Attributes in sync LGTM as an intermediate solution before deprecating State / ParseStateValues.
When would the deprecation be happening 😀?
Are there real issues reported by the user? How important it is? |
How much cost would this introduce? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with this change. However, I'm concerned about the slippery slope situation where we keep adding patches which make things more complex / less performant - how much confidence do you have @CodeBlanch?
Very little! For users NOT doing any modification to
The pattern I have been recommending previously to component authors was to set both data.State = data.StateValues = this.AddFields(data, listOfKvp);
// or
data.State = data.Attributes = this.AddFields(data, listOfKvp); I didn't want those users to have to pay now for additional logic/work being performed so I have a reference check in the public IReadOnlyList<KeyValuePair<string, object?>>? Attributes
{
set
{
// ...
if (this.ILoggerData.State is not null)
{
this.ILoggerData.State = value;
}
this.AttributeData = value;
}
}
public object? State
{
set
{
if (ReferenceEquals(this.ILoggerData.State, value))
{
return;
}
// ...
}
}
This came to me through an issue reported in one of our internal systems. IMO it is important because it is very very difficult to troubleshoot. This particular user was up and running happily. He then updated GenevaExporter to 1.6.0 and noticed some of his data went missing. After trying a bunch of things he became frustrated and decided to downgrade. A few different engineers looked at it before me and no one was able to figure it out. A lot of pieces, a lot of confusion. The enrichment processor in play causing the pain is owned by some other team. My motivation in trying to address it via SDK is really just to eliminate support burden.
I actually really like the change and I'm slightly annoyed at myself that I didn't think of it initially. Logically I'm not too worried about the perf here (see above). The complexity concern is valid but I do think this smooths out the overall complexity we have with
Presumably 2.0 but that may never happen. |
Based on the context here, I think changelog needs to be updated calling out the breaking change. In addition, the buggy version needs to be unlisted/deprecated.
What's the gap here? How to avoid it in the future? |
src/OpenTelemetry/CHANGELOG.md
Outdated
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
* `LogRecord.Attributes` and `LogRecord.StateValues` will now automatically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this is bit unclear from the user perspective, consider borrow some wording from https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/main/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md#140-beta4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Logically Attributes are the result of processing State so it seems very reasonable expectation to me that if I change the State that Attributes should reflect that.
It seems fair to consider this a bug. I agree that the changelog should more clearly indicate that this is a bug fix that changes behavior.
Based on the context here, I think changelog needs to be updated calling out the breaking change. In addition, the buggy version needs to be unlisted/deprecated.
@reyang are you suggesting unlisting versions 1.5+ of the SDK? With few exceptions (crashing or security related), we normally do not unlist versions for bug fixes. Or do you consider this change a bigger deal than a regular bug fix?
I was asking if this is important or not, and we should communicate in the changelog/listing/unlisting in the proper way which reflects the actual importance (from the users' perspective). So far, I got mixed answers:
|
And the current changelog "LogRecord.Attributes and LogRecord.StateValues will now automatically update if LogRecord.State is set inside a processor." sounds like a feature instead of bug fix (if the user bumped version and see things breaking, it'll be hard for them to correlate while reading through the changelog). This one sounds better IMO https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/CHANGELOG.md#151 ("fixed a breaking change..."). |
Gotcha. In this case, my opinion is that it does not warrant an unlisting.
Agree the changelog should be written in a way that makes this look like a bug fix.. I like the improved wording @CodeBlanch just pushed up. |
I don't think this is important to the point we should backport or deprecate/unlist packages. In ~6 months I've only seen one issue about it. But it was something I was going to bring up on the next SIG for discussion. |
Thanks! The updated wording looks great to me!
Now it sounds like it is not important at all (only affecting very few users, and the impact is less severe) - makes sense to not pushing for hotfix / new release / unlisting / deprecation (in a nutshell, just sit on it until this change got picked by the next release train). |
Relates to #4609
Changes
LogRecord
class so that ifAttributes
\StateValues
orState
is set directly they will be kept in sync.Details
We're still discovering some code out in the wild that isn't handling
State
\Attributes
\StateValues
very well. Example:That code is flawed in that it ignores
Attributes
\StateValues
(which may be set instead ofState
) BUT, if users haveParseStateValues=false
AND they are using an exporter which is preferringState
overAttributes
\StateValues
, it will work fine.The problem is since 1.5.0+ things have changed:
Attributes
\StateValues
will be set from the initial state.Attributes
\StateValues
overState
.The result of those changes is the code above sets a new
State
butAttributes
\StateValues
remains set to what was parsed/resolved from the initialState
value. The initial data is exported and these enrichment processors become broken.To smooth this out what this PR does is keep everything in sync automatically.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes