-
Notifications
You must be signed in to change notification settings - Fork 70
Add event logs to open telemetry exporter #839
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b70d43e
WIP
attilakreiner 4f5102d
fix
attilakreiner 88756f6
fix
attilakreiner 39c2286
WIP k3po
attilakreiner 40f8da4
WIP k3po 2
attilakreiner 1775c77
fix use scripts from engine spec
attilakreiner 71663fc
fix rm traceId, spanId
attilakreiner 9213bac
fix IT
attilakreiner ee194fe
ref
attilakreiner 1544c29
fix override
attilakreiner c21499d
fix schema
attilakreiner 05cf397
fix
attilakreiner 143514e
Revert "fix override"
attilakreiner 059d9e1
WIP event id
attilakreiner c04a46a
WIP event.name
attilakreiner e1c0542
WIP test event id
attilakreiner 979d80a
Merge branch 'develop' into otlp-logs
attilakreiner 48204db
fix apicurio event
attilakreiner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
WIP k3po
- Loading branch information
commit 39c2286aeb09bf10080414ec89eaad29562a55a7
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
....spec/src/main/scripts/io/aklivity/zilla/specs/exporter/otlp/application/event/server.rpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # | ||
| # Copyright 2021-2023 Aklivity Inc | ||
| # | ||
| # Licensed under the Aklivity Community License (the "License"); you may not use | ||
| # this file except in compliance with the License. You may obtain a copy of the | ||
| # License at | ||
| # | ||
| # https://www.aklivity.io/aklivity-community-license/ | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations under the License. | ||
| # | ||
|
|
||
| accept "zilla://streams/app0" | ||
| option zilla:window 8192 | ||
|
|
||
| accepted | ||
| connected | ||
|
|
||
| accept "http://localhost:4318/v1/logs" | ||
| accepted | ||
| connected | ||
|
|
||
| read http:method "POST" | ||
| read http:version "HTTP/1.1" | ||
| read http:header "Host" "localhost:4318" | ||
| read | ||
| '{' | ||
| '"resourceLogs":[' | ||
| '{' | ||
| '"resource":{' | ||
| '"attributes":[' | ||
| '{' | ||
| '"key":"service.namespace",' | ||
| '"value":{' | ||
| '"stringValue":"example"' | ||
| '}' | ||
| '}' | ||
| ']' | ||
| '},' | ||
| '"scopeLogs":[' | ||
| '{' | ||
| '"scope":{' | ||
| '"name":"OtlpLogsSerializer",' | ||
| '"version":"1.0.0"' | ||
| '},' | ||
| '"logRecords":[' | ||
| '{' | ||
| '"timeUnixNano":42000000,' | ||
| '"observedTimeUnixNano":42000000,' | ||
| '"traceId":"8000000000000001",' | ||
| '"spanId":"100000004",' | ||
|
attilakreiner marked this conversation as resolved.
Outdated
|
||
| '"body":{' | ||
| '"stringValue":"body"' | ||
| '},' | ||
| '"attributes":[' | ||
| '{' | ||
| '"key":"event.name",' | ||
| '"value":{' | ||
| '"stringValue":"test.test"' | ||
| '}' | ||
| '},' | ||
| '{' | ||
| '"key":"extension",' | ||
| '"value":{' | ||
| '"stringValue":"test event message"' | ||
| '}' | ||
| '}' | ||
| ']' | ||
| '}' | ||
| ']' | ||
| '}' | ||
| ']' | ||
| '}' | ||
| ']' | ||
| '}' | ||
| read closed | ||
|
|
||
| write http:status "200" "OK" | ||
| write close | ||
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
...porter-otlp.spec/src/main/scripts/io/aklivity/zilla/specs/exporter/otlp/config/event.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # | ||
| # Copyright 2021-2023 Aklivity Inc | ||
| # | ||
| # Licensed under the Aklivity Community License (the "License"); you may not use | ||
| # this file except in compliance with the License. You may obtain a copy of the | ||
| # License at | ||
| # | ||
| # https://www.aklivity.io/aklivity-community-license/ | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations under the License. | ||
| # | ||
|
|
||
| --- | ||
| name: test | ||
| telemetry: | ||
| attributes: | ||
| service.namespace: example | ||
| exporters: | ||
| test0: | ||
| type: otlp | ||
| options: | ||
| interval: 1 | ||
| signals: | ||
| - logs | ||
| endpoint: | ||
| location: http://localhost:4318 | ||
| bindings: | ||
| net0: | ||
| type: test | ||
| kind: server | ||
| options: | ||
| events: | ||
| - timestamp: 42 | ||
| message: test event message | ||
| exit: app0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...otlp.spec/src/main/scripts/io/aklivity/zilla/specs/exporter/otlp/network/event/client.rpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # | ||
| # Copyright 2021-2023 Aklivity Inc | ||
| # | ||
| # Licensed under the Aklivity Community License (the "License"); you may not use | ||
| # this file except in compliance with the License. You may obtain a copy of the | ||
| # License at | ||
| # | ||
| # https://www.aklivity.io/aklivity-community-license/ | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations under the License. | ||
| # | ||
|
|
||
| connect "zilla://streams/net0" | ||
| option zilla:window 8192 | ||
|
|
||
| connected | ||
|
attilakreiner marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...rc/main/java/io/aklivity/zilla/runtime/exporter/otlp/internal/serializer/EventReader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /* | ||
| * Copyright 2021-2023 Aklivity Inc | ||
| * | ||
| * Licensed under the Aklivity Community License (the "License"); you may not use | ||
| * this file except in compliance with the License. You may obtain a copy of the | ||
| * License at | ||
| * | ||
| * https://www.aklivity.io/aklivity-community-license/ | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| */ | ||
| package io.aklivity.zilla.runtime.exporter.otlp.internal.serializer; | ||
|
|
||
| import java.io.StringReader; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import jakarta.json.Json; | ||
| import jakarta.json.JsonArray; | ||
| import jakarta.json.JsonArrayBuilder; | ||
| import jakarta.json.JsonObjectBuilder; | ||
| import jakarta.json.JsonReader; | ||
|
|
||
| import org.agrona.DirectBuffer; | ||
|
|
||
| import io.aklivity.zilla.runtime.engine.EngineContext; | ||
| import io.aklivity.zilla.runtime.engine.binding.function.MessageReader; | ||
| import io.aklivity.zilla.runtime.engine.event.EventFormatter; | ||
| import io.aklivity.zilla.runtime.exporter.otlp.internal.types.event.EventFW; | ||
|
|
||
| public class EventReader | ||
| { | ||
| private static final int MESSAGE_COUNT_LIMIT = 100; | ||
| private static final String TIME_UNIX_NANO = "timeUnixNano"; | ||
| private static final String OBSERVED_TIME_UNIX_NANO = "observedTimeUnixNano"; | ||
| private static final String TRACE_ID = "traceId"; | ||
| private static final String SPAN_ID = "spanId"; | ||
| private static final String BODY = "body"; | ||
| private static final String ATTRIBUTES = "attributes"; | ||
| private static final String BODY_FORMAT = "{\"stringValue\": \"%s\"}"; | ||
| private static final String STRING_ATTRIBUTE_FORMAT = "{\"key\":\"%s\", \"value\":{\"stringValue\": \"%s\"}}"; | ||
| private static final String INT_ATTRIBUTE_FORMAT = "{\"key\":\"%s\", \"value\":{\"intValue\": \"%d\"}}"; | ||
|
|
||
| private final EngineContext context; | ||
| private final MessageReader readEvent; | ||
| private final EventFormatter formatter; | ||
| private final EventFW eventRO = new EventFW(); | ||
|
|
||
| private JsonArrayBuilder eventsJson; | ||
| private JsonObjectBuilder eventJson; | ||
| private JsonArrayBuilder eventAttributesJson; | ||
|
|
||
| public EventReader( | ||
| EngineContext context) | ||
| { | ||
| this.context = context; | ||
| this.readEvent = context.supplyEventReader(); | ||
| this.formatter = context.supplyEventFormatter(); | ||
| } | ||
|
|
||
| public JsonArray readEvents() | ||
| { | ||
| eventsJson = Json.createArrayBuilder(); | ||
| readEvent.read(this::handleEvent, MESSAGE_COUNT_LIMIT); | ||
| return eventsJson.build(); | ||
| } | ||
|
|
||
| private void handleEvent( | ||
| int msgTypeId, | ||
| DirectBuffer buffer, | ||
| int index, | ||
| int length) | ||
| { | ||
| final EventFW event = eventRO.wrap(buffer, index, index + length); | ||
| String qname = context.supplyQName(event.namespacedId()); | ||
| eventJson = Json.createObjectBuilder(); | ||
| long nanos = TimeUnit.MILLISECONDS.toNanos(event.timestamp()); | ||
| eventJson.add(TIME_UNIX_NANO, nanos); | ||
| eventJson.add(OBSERVED_TIME_UNIX_NANO, nanos); | ||
| eventJson.add(TRACE_ID, String.format("%x", event.traceId())); | ||
| eventJson.add(SPAN_ID, String.format("%x", event.namespacedId())); | ||
| addBody("body"); | ||
| eventAttributesJson = Json.createArrayBuilder(); | ||
| addStringAttribute("event.name", "test.test"); | ||
| String extension = formatter.format(msgTypeId, buffer, index, length); | ||
| addStringAttribute("extension", extension); | ||
| //addIntAttribute("id", 42); | ||
| eventJson.add(ATTRIBUTES, eventAttributesJson); | ||
| eventsJson.add(eventJson); | ||
| System.out.println(eventJson); | ||
| System.out.printf("%s 0x%016x [%d]\n", qname, event.traceId(), event.timestamp()); | ||
|
attilakreiner marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| private void addBody( | ||
| String body) | ||
| { | ||
| String json = String.format(BODY_FORMAT, body); | ||
| JsonReader reader = Json.createReader(new StringReader(json)); | ||
| eventJson.add(BODY, reader.readObject()); | ||
| } | ||
|
|
||
| private void addStringAttribute( | ||
| String key, | ||
| String value) | ||
| { | ||
| String json = String.format(STRING_ATTRIBUTE_FORMAT, key, value); | ||
| JsonReader reader = Json.createReader(new StringReader(json)); | ||
| eventAttributesJson.add(reader.readObject()); | ||
| } | ||
|
|
||
| private void addIntAttribute( | ||
| String key, | ||
| int value) | ||
| { | ||
| String json = String.format(INT_ATTRIBUTE_FORMAT, key, value); | ||
| JsonReader reader = Json.createReader(new StringReader(json)); | ||
| eventAttributesJson.add(reader.readObject()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.