Skip to content

Conversation

@hannahkm
Copy link
Contributor

@hannahkm hannahkm commented Sep 5, 2025

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

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

hannahkm and others added 3 commits September 5, 2025 15:06
- 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.
@pr-commenter
Copy link

pr-commenter bot commented Sep 5, 2025

Benchmarks

Benchmark execution time: 2025-10-27 18:51:38

Comparing candidate commit 7fc1f29 in PR branch hannahkm/implement-v1-serialization with baseline commit abd2718 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@datadog-official
Copy link
Contributor

datadog-official bot commented Sep 5, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7fc1f29 | Docs | Was this helpful? Give us feedback!

Comment on lines +450 to +483
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
}
}
Copy link
Contributor Author

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.

@hannahkm hannahkm changed the base branch from hannahkm/msgp-payload-interface to main October 27, 2025 18:35
@hannahkm hannahkm changed the title draft: implement v1 trace protocol serialization feat: v1 trace protocol implementation Oct 27, 2025
@hannahkm hannahkm marked this pull request as ready for review October 27, 2025 19:11
@hannahkm hannahkm requested review from a team as code owners October 27, 2025 19:11
func checkEndpoint(c *http.Client, endpoint string, protocol float64) error {
b := []byte{0x90} // empty array
if protocol == traceProtocolV1 {
b = []byte{0x80} // empty map
Copy link
Contributor Author

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 {
Copy link
Contributor Author

@hannahkm hannahkm Oct 27, 2025

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.

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.

3 participants