Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ jobs:
# TODO: This needs to be updated once wasi-otel is merged into big Spin.
- name: Setup Spin
run: |
curl -LO https://github.com/asteurer/spin/releases/download/v0.1.0-otel/spin-linux-amd64
echo "9b2bbcc98ddf2faeb31a8feda3672df0562052150abc96acf5351cc7d3b51f9a spin-linux-amd64" | sha256sum --check
curl -LO https://github.com/asteurer/spin/releases/download/v0.2.0-otel/spin-linux-amd64
echo "94e31a56502026f83c12a843cf4aa7f3b5bf1d5a97fd18348fe78ab7f2ba4548 spin-linux-amd64" | sha256sum --check
chmod +x spin-linux-amd64
mkdir -p $HOME/.local/bin
mv spin-linux-amd64 $HOME/.local/bin/spin
Expand Down
5 changes: 3 additions & 2 deletions rust/src/logs/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ impl<'a> Serialize for AnyValueWrapper<'a> {
opentelemetry::logs::AnyValue::Bytes(bytes) => {
// This is a workaround for JSON not having a way to differentiate between an array of bytes and an array of integers.
let encoded = base64::engine::general_purpose::STANDARD.encode(bytes.as_ref());
serializer.serialize_str(&format!("{{base64}}:{}", encoded))
serializer
.serialize_str(&format!("data:application/octet-stream;base64,{}", encoded))
}
opentelemetry::logs::AnyValue::ListAny(list) => {
serialize_seq!(list, serializer, |v| &AnyValueWrapper(v))
Expand Down Expand Up @@ -129,7 +130,7 @@ mod tests {
"key2": 123.456,
"key3": 41,
//'Hello, world!' encoded to base64
"key4": "{base64}:SGVsbG8sIHdvcmxkIQ==",
"key4": "data:application/octet-stream;base64,SGVsbG8sIHdvcmxkIQ==",
"key5": "This is a string",
"key6": [1, 2, 3],
"key7": {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('logAnyValueToWasi', () => {
key2: 123.456,
key3: 41,
// 'Hello, world!' encoded to base64
key4: '{base64}:SGVsbG8sIHdvcmxkIQ==',
key4: 'data:application/octet-stream;base64,SGVsbG8sIHdvcmxkIQ==',
key5: 'This is a string',
key6: [1, 2, 3],
key7: {
Expand Down
5 changes: 4 additions & 1 deletion ts/src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ function logAttributesToWasi(attrs: AnyValueMap): WasiKeyValue[] {

export function logAnyValueToWasi(v: AnyValue): string {
if (v instanceof Uint8Array) {
return JSON.stringify('{base64}:' + Buffer.from(v).toString('base64'));
return JSON.stringify(
'data:application/octet-stream;base64,' +
Buffer.from(v).toString('base64')
);
} else if (v === null || v === undefined) {
return 'null';
} else if (typeof v === 'string') {
Expand Down
4 changes: 4 additions & 0 deletions ts/types/interfaces/wasi-otel-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ declare module 'wasi:otel/types@0.2.0-draft' {
*
* This corresponds with the `AnyValue` type defined in the [attribute spec](https://opentelemetry.io/docs/specs/otel/common/#anyvalue).
* Because WIT doesn't support recursive types, the data needs to be serialized. JSON is used as the encoding format.
*
* Byte arrays require special encoding since JSON cannot distinguish them from number arrays.
* They are base64-encoded with a prefix that follows the Data URI RFC 2397 convention:
* `data:application/octet-stream;base64,<BASE64_ENCODED_BYTES>`
*/
export type Value = string;
/**
Expand Down
4 changes: 4 additions & 0 deletions ts/wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ interface types {
///
/// This corresponds with the `AnyValue` type defined in the [attribute spec](https://opentelemetry.io/docs/specs/otel/common/#anyvalue).
/// Because WIT doesn't support recursive types, the data needs to be serialized. JSON is used as the encoding format.
///
/// Byte arrays require special encoding since JSON cannot distinguish them from number arrays.
/// They are base64-encoded with a prefix that follows the Data URI RFC 2397 convention:
/// `data:application/octet-stream;base64,<BASE64_ENCODED_BYTES>`
type value = string;

/// An immutable representation of the entity producing telemetry as attributes.
Expand Down
4 changes: 4 additions & 0 deletions wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ interface types {
///
/// This corresponds with the `AnyValue` type defined in the [attribute spec](https://opentelemetry.io/docs/specs/otel/common/#anyvalue).
/// Because WIT doesn't support recursive types, the data needs to be serialized. JSON is used as the encoding format.
///
/// Byte arrays require special encoding since JSON cannot distinguish them from number arrays.
/// They are base64-encoded with a prefix that follows the Data URI RFC 2397 convention:
/// `data:application/octet-stream;base64,<BASE64_ENCODED_BYTES>`
type value = string;

/// An immutable representation of the entity producing telemetry as attributes.
Expand Down