-
Couldn't load subscription status.
- Fork 484
feat: v1 trace protocol implementation #3947
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
base: main
Are you sure you want to change the base?
Conversation
- Added msgp struct tags to fields in payloadV1 and traceChunk for serialization. - Introduced EncodeMsg methods for payloadV1 and spanListV1 to support msgp encoding. - Updated field types in traceChunk to enhance compatibility with msgp serialization.
BenchmarksBenchmark execution time: 2025-10-27 18:51:38 Comparing candidate commit 7fc1f29 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics. |
| func getSpanKindValue(sk string) uint32 { | ||
| switch sk { | ||
| case ext.SpanKindInternal: | ||
| return 1 | ||
| case ext.SpanKindServer: | ||
| return 2 | ||
| case ext.SpanKindClient: | ||
| return 3 | ||
| case ext.SpanKindProducer: | ||
| return 4 | ||
| case ext.SpanKindConsumer: | ||
| return 5 | ||
| default: | ||
| return 1 // default to internal | ||
| } | ||
| } | ||
|
|
||
| // translate a span kind uint32 value to its string value | ||
| func getSpanKindString(sk uint32) string { | ||
| switch sk { | ||
| case 1: | ||
| return ext.SpanKindInternal | ||
| case 2: | ||
| return ext.SpanKindServer | ||
| case 3: | ||
| return ext.SpanKindClient | ||
| case 4: | ||
| return ext.SpanKindProducer | ||
| case 5: | ||
| return ext.SpanKindConsumer | ||
| default: | ||
| return ext.SpanKindInternal | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these functions covered somewhere in the OpenTelemetry code (either ours or elsewhere)? I could not find anything internal that supports this. We should also check with the OTel team to see if there are better places to put this.
| func checkEndpoint(c *http.Client, endpoint string, protocol float64) error { | ||
| b := []byte{0x90} // empty array | ||
| if protocol == traceProtocolV1 { | ||
| b = []byte{0x80} // empty map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Payload v1 is represented by a message pack map, whereas the empty payload in v0.4 was represented by an array. To prevent failures when we send empty data, we need to check for the payload version and send the correct data type.
| // • https://github.com/DataDog/dd-trace-go/pull/475 | ||
| // • https://github.com/DataDog/dd-trace-go/pull/549 | ||
| // • https://github.com/DataDog/dd-trace-go/pull/976 | ||
| type payloadV04 struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, the old payload (previously named payload and living in payload.go) is named payloadV04 to represent v0.4. The associated functions are moved to payload_v04.go, and v1 payload functionality is added to payload_v1.go.
What does this PR do?
Implements the v1 trace protocol. Includes commits cherry-picked from #3932 since I closed my previous PR.
Motivation
https://datadoghq.atlassian.net/browse/LANGPLAT-750
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!