Reputation: 171
I am looking for a way to send a open-telemetry trace payload to a deployed otel collector , this payload is to be sent on gRPC protocol.
I have been using postman rest client to send an http request with a JSON payload on the url : localhost:55681/v1/traces , is something similar possible to do with gRPC.
Upvotes: 1
Views: 2787
Reputation: 2473
OpenTelemetry
can use grpc
or http
. Encoding on grpc
is protobuf
. You have couple of options on http
. You can send proto-json
or just json
. There are couple of differences between proto-json
and json
. Below is a sample proto-json
that you can curl POST to an OpenTelemetry collector.
curl -H 'Content-Type: application/json' -X POST http://localhost:4318/v1/traces -d '$DATA'
Data is:
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "deployment.environment",
"value": { "stringValue": "stage" }
},
{ "key": "service.name", "value": { "stringValue": "Foo App" } },
{ "key": "service.version", "value": { "stringValue": "v1.0.0" } },
{ "key": "telemetry.sdk.language", "value": { "stringValue": "go" } },
{
"key": "telemetry.sdk.name",
"value": { "stringValue": "opentelemetry" }
},
{
"key": "telemetry.sdk.version",
"value": { "stringValue": "1.16.0" }
}
]
},
"scopeSpans": [
{
"scope": { "name": "foo" },
"spans": [
{
"traceId": "ba8c19fd8b342b534a8dc212573c4055",
"spanId": "beeca1383d3dc369",
"parentSpanId": "63087c13860db67e",
"name": "LogOperation",
"kind": 1,
"startTimeUnixNano": "1697646563738900000",
"endTimeUnixNano": "1697646563738927375",
"links": [
{
"traceId": "01000000000000000000000000000000",
"spanId": "0100000000000000",
"attributes": [
{ "key": "one", "value": { "boolValue": true } },
{ "key": "two", "value": { "boolValue": true } }
]
}
],
"status": {}
}
]
}
],
"schemaUrl": "https://opentelemetry.io/schemas/1.17.0"
}
]
}
Upvotes: -1