Skip to content

Conversation

@jboolean
Copy link
Contributor

@jboolean jboolean commented Nov 5, 2025

NB: This is part of a stack

What does this PR do?

In addition to tool calls, record task spans for session initialization.

image.png

Motivation

We want to record data like clientInfo during session Initialization and this seems like the best way to do it.

I considered a metric, but in the future we will also want to tag the session ID, and metrics do not do well with unique tags. Also, this allows viewing everything together in the LLMObs UI.

A writeup with more context on this design

Relates to MLOB-4373

Future

In future PRs I will add tags for session ID.

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!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Nov 5, 2025
Copy link
Contributor Author

jboolean commented Nov 5, 2025

@jboolean jboolean changed the title Trace initializations with spans feat(contrib/mcp-go): Trace MCP session initializations with MLObs spans Nov 5, 2025
@jboolean jboolean requested review from a team, Kyle-Verhoog, rarguelloF and tomshen November 5, 2025 21:27
@pr-commenter
Copy link

pr-commenter bot commented Nov 5, 2025

Benchmarks

Benchmark execution time: 2025-11-14 15:39:44

Comparing candidate commit 7f50759 in PR branch jb/contrib-mcp-go-init-span with baseline commit 4be1146 in branch main.

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

@jboolean jboolean marked this pull request as ready for review November 5, 2025 21:39
@tomshen tomshen removed their request for review November 6, 2025 15:36
@jboolean jboolean force-pushed the jb/contrib-mcp-go-init-span branch from 498ae3a to 792093f Compare November 7, 2025 18:57
@jboolean jboolean force-pushed the jb/contrib-mcp-go-base branch from 95af4d3 to 4def1e6 Compare November 7, 2025 19:01
@jboolean jboolean force-pushed the jb/contrib-mcp-go-init-span branch 3 times, most recently from f2727e3 to 5f20214 Compare November 7, 2025 19:43
@datadog-official
Copy link
Contributor

datadog-official bot commented Nov 7, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

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

@jboolean jboolean force-pushed the jb/contrib-mcp-go-init-span branch 2 times, most recently from f15f2c6 to 7af0a91 Compare November 10, 2025 14:47
@jboolean jboolean force-pushed the jb/contrib-mcp-go-base branch from cd3a995 to 0a4f2bf Compare November 10, 2025 14:47
Copy link
Contributor Author

I made an update that removes the ttlcache. This was a relic of long term session tracking. I read the mcp-go code and did not see any code paths that would lead to the after or error hooks not being called, so records will always be deleted. This simplifies the design by removing the cleanup function.

It would be hard to support via orchestrion with the cleanup.

@jboolean jboolean requested a review from rarguelloF November 10, 2025 21:05
@jboolean jboolean force-pushed the jb/contrib-mcp-go-base branch from c177b06 to 38e2a00 Compare November 13, 2025 18:32
Base automatically changed from jb/contrib-mcp-go-base to main November 13, 2025 19:39
@jboolean jboolean force-pushed the jb/contrib-mcp-go-init-span branch from 0237e37 to 6bacb1a Compare November 13, 2025 19:41
Copy link
Contributor Author

@genesor Could you take a look please?

@jboolean jboolean assigned hannahkm and unassigned Kyle-Verhoog and rarguelloF Nov 13, 2025
Copy link
Contributor Author

jboolean commented Nov 13, 2025

@hannahkm Would love your review so I can get this in and hopefully soon integrated with dd-source. Thanks!

@jboolean jboolean assigned hannaner and unassigned hannahkm Nov 13, 2025
@jboolean jboolean requested review from genesor and hannaner November 14, 2025 16:22
@jboolean jboolean assigned hannahkm and unassigned hannaner Nov 17, 2025
@jboolean jboolean requested review from hannahkm and removed request for hannaner November 17, 2025 18:00
Copy link
Contributor Author

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Nov 18, 2025

View all feedbacks in Devflow UI.

2025-11-18 15:00:39 UTC ℹ️ Start processing command /merge


2025-11-18 15:00:44 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 22m (p90).


2025-11-18 15:31:25 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit 0013a0e into main Nov 18, 2025
247 of 248 checks passed
@dd-mergequeue dd-mergequeue bot deleted the jb/contrib-mcp-go-init-span branch November 18, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants