Skip to content

fix: OTLP JSON Event example body #666

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 3 commits into from
Jun 17, 2025

Conversation

IgorPidik
Copy link
Contributor

What

  • fix events.json example by wrapping kvlistValue content in a values property
  • fix indentation

Why

Following the example README and running

$ curl -X POST -H "Content-Type: application/json" -d @events.json -i localhost:4318/v1/logs

results in

HTTP/1.1 400 Bad Request
Content-Type: application/json
Vary: Origin
Date: Sat, 31 May 2025 13:29:10 GMT
Content-Length: 253

{"code":3,"message":"ReadObjectCB: expect { or n, but found [, error found in #10 byte of ...|tValue\": [          |..., bigger context ...|         \"body\": {                \"kvlistValue\": [                  {                    \"key\": \"typ|..."}%

Seems like the kvlistValue(KeyValueList) values need to be wrapped in a values property.

After fixing the example the request response and collector output seem fine:

HTTP/1.1 200 OK
Content-Type: application/json
Vary: Origin
Date: Sat, 31 May 2025 12:31:00 GMT
Content-Length: 21

{"partialSuccess":{}}

collector output:

collector-otel-collector-1  | 2025-05-31T13:29:24.995Z  info    Logs    {"resource": {}, "otelcol.component.id": "debug", "otelcol.component.kind": "exporter", "otelcol.signal": "logs", "resource logs": 1, "log records": 1}
collector-otel-collector-1  | 2025-05-31T13:29:24.996Z  info    ResourceLog #0
collector-otel-collector-1  | Resource SchemaURL:
collector-otel-collector-1  | Resource attributes:
collector-otel-collector-1  |      -> service.name: Str(my.service)
collector-otel-collector-1  | ScopeLogs #0
collector-otel-collector-1  | ScopeLogs SchemaURL:
collector-otel-collector-1  | InstrumentationScope my.library 1.0.0
collector-otel-collector-1  | InstrumentationScope attributes:
collector-otel-collector-1  |      -> my.scope.attribute: Str(some scope attribute)
collector-otel-collector-1  | LogRecord #0
collector-otel-collector-1  | ObservedTimestamp: 2018-12-13 14:51:00.3 +0000 UTC
collector-otel-collector-1  | Timestamp: 2018-12-13 14:51:00.3 +0000 UTC
collector-otel-collector-1  | SeverityText:
collector-otel-collector-1  | SeverityNumber: Info(9)
collector-otel-collector-1  | Body: Map({"referrer":"https://wwww.google.com","title":"Free Online GUID Generator","type":0,"url":"https://www.guidgenerator.com/online-guid-generator.aspx"})
collector-otel-collector-1  | Attributes:
collector-otel-collector-1  |      -> event.name: Str(browser.page_view)
collector-otel-collector-1  | Trace ID:
collector-otel-collector-1  | Span ID:
collector-otel-collector-1  | Flags: 0
collector-otel-collector-1  |   {"resource": {}, "otelcol.component.id": "debug", "otelcol.component.kind": "exporter", "otelcol.signal": "logs"}

Tested using docker image otel/opentelemetry-collector-contrib:0.127.0

Copy link

linux-foundation-easycla bot commented May 31, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: IgorPidik / name: Igor Pidik (df49074, b586e42)
  • ✅ login: reyang / name: Reiley Yang (a2bbb1e)

@IgorPidik IgorPidik marked this pull request as ready for review May 31, 2025 14:05
@IgorPidik IgorPidik requested a review from a team as a code owner May 31, 2025 14:05
@reyang reyang merged commit b594790 into open-telemetry:main Jun 17, 2025
13 of 15 checks passed
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 this pull request may close these issues.

5 participants