Skip to content

tracer: Report stats on errorstack#3752

Merged
dd-mergequeue[bot] merged 4 commits into
hannahkm/errortracefrom
hannahkm/report-metrics
Jul 16, 2025
Merged

tracer: Report stats on errorstack#3752
dd-mergequeue[bot] merged 4 commits into
hannahkm/errortracefrom
hannahkm/report-metrics

Conversation

@hannahkm

@hannahkm hannahkm commented Jul 14, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Creates two new telemetry metrics:

  1. errorstack.source: a count representing the number of stacks calculated for an error. Includes a tag (source) indicating where this calculation happened. This tag can either be errortrace or takeStacktrace.
  2. errorstack.duration: a distribution representing how long (in milliseconds) it took for the stacks to be calculated. This also includes the same source tag as above.

Motivation

Following the work in #3709, we want to keep track of how and where error stacks are being calculated. Our main points of comparison are in the new errortrace package vs the existing takeStacktrace function. This can help us determine how customers pick up on the package and if we need to made any modifications.

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 golangci-lint run 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!

@pr-commenter

pr-commenter Bot commented Jul 14, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-07-16 14:39:44

Comparing candidate commit b28c891 in PR branch hannahkm/report-metrics with baseline commit 248d78b in branch hannahkm/errortrace.

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

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀


// Wrap takes in an error and records the stack trace at the moment that it was thrown.
func Wrap(err error, n uint, skip uint) *TracerError {
telemetry.Count(telemetry.NamespaceTracers, "errorstack.source", []string{"source:TracerError"}).Submit(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only question here: Would there be situation where we actually wrap an error but it doesn't end up in the spans? (setTagError never call for this error)

Technically, this doesn't change anything for this PR. However, it worths keeping in mind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can maybe see this happening if we were to wrap an error somewhere and not explicitly set it on the span somehow. For the sake of keeping existing functionality around, I'm not wrapping built-in error types as they pass through setTagError (also that wouldn't solve the issue of incorrect stack traces, I think). But yeah, it's worth thinking about!

As we start migrating to errortrace internally, we can keep this in mind. I'm sure there are edge cases that we might need to investigate in the future...

@hannahkm
hannahkm marked this pull request as ready for review July 16, 2025 14:45
@hannahkm
hannahkm requested review from a team as code owners July 16, 2025 14:45
@kakkoyun kakkoyun changed the title [WIP] report stats on errorstack Report stats on errorstack Jul 16, 2025
@kakkoyun kakkoyun changed the title Report stats on errorstack tracer: Report stats on errorstack Jul 16, 2025
@kakkoyun

Copy link
Copy Markdown
Member

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Jul 16, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-07-16 15:52:27 UTC ℹ️ Start processing command /merge


2025-07-16 15:52:37 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in hannahkm/errortrace is approximately 0s (p90).


2025-07-16 16:05:09 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue
dd-mergequeue Bot merged commit f367dbc into hannahkm/errortrace Jul 16, 2025
221 checks passed
@dd-mergequeue
dd-mergequeue Bot deleted the hannahkm/report-metrics branch July 16, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants