Skip to content

feat(profiler): implement ProfileType.UnmarshalText method#3881

Merged
nsrip-dd merged 1 commit into
DataDog:mainfrom
crdueck:profile-type-unmarshal-text
Aug 14, 2025
Merged

feat(profiler): implement ProfileType.UnmarshalText method#3881
nsrip-dd merged 1 commit into
DataDog:mainfrom
crdueck:profile-type-unmarshal-text

Conversation

@crdueck

@crdueck crdueck commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

This change supports configuration use cases where the profile type is parsed from text sources like environment variables or config file, such that the parsed values can be passed to profiler.WithProfileTypes.

Question for reviewers, should I implement a MarshalText method as well for completeness? These methods are related because UnmarshalText is expected to be able to unmarshal the output from MarshalText.

Motivation

Related to discussion: #3872

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!

This supports configuration use cases where the profile type is parsed
from text sources like environment variables or config file.
@crdueck
crdueck requested a review from a team as a code owner August 13, 2025 18:02

@nsrip-dd nsrip-dd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Stray thoughts that don't block this PR, putting here for posterity: it would be cool if we could automatically generate this for every exported ProfileType, but OTOH I don't anticipate adding new ones any time soon and it doesn't feel worth pulling in a third-party tool to do it. We could iterate over profileTypes, I suppose, but then we'd need to distinguish public and private types. Like, I wouldn't want to accept "trace" without some refactoring, or "goroutinewait" since we might delete it. What's in this PR is good for now.

Question for reviewers, should I implement a MarshalText method as well for completeness? These methods are related because UnmarshalText is expected to be able to unmarshal the output from MarshalText.

Personally I don't think that'll be necessary. We already have a String method that does basically the same thing, but we only use it internally. There's no way to get the enabled profile types back out of the profiler. We can add such a method later if somebody comes to us with a use-case.

@nsrip-dd
nsrip-dd merged commit c72fe0b into DataDog:main Aug 14, 2025
108 checks passed
@crdueck
crdueck deleted the profile-type-unmarshal-text branch August 15, 2025 18:51
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.

2 participants