| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package request // import "go.opentelemetry.io/collector/pdata/xpdata/request" |
| 5 |
|
| 6 |
import ( |
| 7 |
"encoding/binary" |
| 8 |
"errors" |
| 9 |
) |
| 10 |
|
| 11 |
const ( |
| 12 |
// field 1 << 3, wire type 5 (fixed32) |
| 13 |
protoTag1TypeByte = 0x0D |
| 14 |
|
| 15 |
// version of the request payload format set in the `format_version` field |
| 16 |
requestFormatVersion = uint32(1) |
| 17 |
) |
| 18 |
|
| 19 |
var ErrInvalidFormat = errors.New("invalid request payload format") |
| 20 |
|
| 21 |
// isRequestPayloadV1 returns true if the given payload represents one of the wrappers around standard OpenTelemetry |
| 22 |
// data types defined in internal/request.go and has the version set to 1. |
| 23 |
func isRequestPayloadV1(data []byte) bool { |
| 24 |
if len(data) < 5 { |
| 25 |
return false |
| 26 |
} |
| 27 |
if data[0] != protoTag1TypeByte { |
| 28 |
return false |
| 29 |
} |
| 30 |
return binary.LittleEndian.Uint32(data[1:5]) == requestFormatVersion |
| 31 |
} |