postman 我需要一个gRPC开放遥测跟踪有效载荷样本

yptwkmov  于 7个月前  发布在  Postman
关注(0)|答案(2)|浏览(74)

我正在寻找一种方法来发送一个开放的遥测跟踪有效载荷到部署的otel收集器,这个有效载荷是在gRPC协议发送。
我一直在使用postman rest客户端发送一个http请求,在url:localhost:55681/v1/traces上发送一个JSON负载,这与gRPC类似。

ifsvaxew

ifsvaxew2#

OpenTelemetry可以使用grpchttp。在grpc上的编码是protobuf。你在http上有几个选项。你可以发送proto-json或只是jsonproto-jsonjson之间有几个区别。下面是一个示例proto-json,你可以将POST curl 到OpenTelemetry收集器。

curl -H 'Content-Type: application/json' -X POST http://localhost:4318/v1/traces -d '$DATA'

字符串
数据为:

{
  "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"
    }
  ]
}

相关问题