-
Notifications
You must be signed in to change notification settings - Fork 834
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
Experimental support for Log AnyValue body #5880
Conversation
Codecov ReportAttention:
... and 11 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
Is this effectively a new serialization type? What is the advantage over declaring a new interface (like
or even just allowing |
@jackshirazi the log record body field is defined in the data model as type any. See proto definition for body, and AnyValue. So far, we've only known about use cases where log record body is a string, so we've restricted it. However, new use cases have emerged which require the log record body to include structure:
So its not as simple as having a type that can be serializes to |
I haven't heard any criticism of this approach so I've gone ahead and tidied it up and marked it ready for review. |
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.
Hey @jack-berg this is great! I had a few comments/questions, but overall this feels solid to me.
...mon/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java
Outdated
Show resolved
Hide resolved
extensions/incubator/src/main/java/io/opentelemetry/extension/incubator/logs/AnyValueBytes.java
Outdated
Show resolved
Hide resolved
extensions/incubator/src/main/java/io/opentelemetry/extension/incubator/logs/AnyValueBytes.java
Show resolved
Hide resolved
...ubator/src/main/java/io/opentelemetry/extension/incubator/logs/ExtendedLogRecordBuilder.java
Show resolved
Hide resolved
...sions/incubator/src/main/java/io/opentelemetry/extension/incubator/logs/KeyAnyValueList.java
Outdated
Show resolved
Hide resolved
extensions/incubator/src/test/java/io/opentelemetry/extension/incubator/logs/AnyValueTest.java
Show resolved
Hide resolved
sdk/logs/src/test/java/io/opentelemetry/sdk/logs/AnyValueBodyTest.java
Outdated
Show resolved
Hide resolved
public byte[] getValue() { | ||
return value; | ||
public ByteBuffer getValue() { | ||
return ByteBuffer.wrap(raw).asReadOnlyBuffer(); |
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.
Stoked!
assertThat(anyValue.getValue()).isEqualTo(new byte[] {'a', 'b'}); | ||
ByteBuffer value = anyValue.getValue(); | ||
// AnyValueBytes returns read only view of ByteBuffer | ||
assertThatThrownBy(value::array).isInstanceOf(ReadOnlyBufferException.class); |
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.
👍🏻
This also very much relates to the ongoing discussions around |
Will merge tomorrow if there are no additional comments. Need to leave time for the followup #5938 before the next release. |
In the interest of being very conservative, I've removed the new Anyone wishing to access the |
Resolves #5847.
This adds experimental support for recording AnyValue for log record bodies. A summary:
LogRecordBuilder#setBody(..)
which acceptsAnyValue
as an argument.Body#getType()
. If it isAnyValue
, they can cast it to AnyValueBody, access the AnyValue, and encode it however they see fit. If the exporter protocol doesn't understand how to export AnyValueBody, it can useBody#asString()
, which will encode the AnyValue data into a String. The AnyValueBody#asString() implementation currently produces a java-toString style response, but we could substitute a JSON encoding to make it even more useful.Will need to followup on this to update LogMarshaler to properly encode this to OTLP. Currently, it will just send to the
asString()
representation.