-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(profiling): support dynamic agent url (#11319)
https://ddtrace.readthedocs.io/en/stable/advanced_usage.html#agent-configuration Customers can use `tracer.configure()` to set the agent url on the fly, and profiler doesn't use the url passed in. Without this change, the following test fails with the Python exporter having `http://localhost:8126` as endpoint url. ``` def test_tracer_url_configure_after(): t = ddtrace.Tracer() prof = profiler.Profiler(tracer=t) t.configure(hostname="foobar") _check_url(prof, "http://foobar:8126", os.environ.get("DD_API_KEY")) ``` Addressing customer issue [PROF-10698](https://datadoghq.atlassian.net/browse/PROF-10698) ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) [PROF-10698]: https://datadoghq.atlassian.net/browse/PROF-10698?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
9f7551f
commit defea4e
Showing
9 changed files
with
138 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
import os | ||
|
||
from ddtrace.internal import agent | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def _get_endpoint(tracer, agentless=False) -> str: | ||
if agentless: | ||
LOG.warning( | ||
"Agentless uploading is currently for internal usage only and not officially supported. " | ||
"You should not enable it unless somebody at Datadog instructed you to do so." | ||
) | ||
endpoint = "https://intake.profile.{}".format(os.environ.get("DD_SITE", "datadoghq.com")) | ||
else: | ||
tracer_agent_url = tracer.agent_trace_url | ||
endpoint = tracer_agent_url if tracer_agent_url else agent.get_trace_url() | ||
return endpoint | ||
|
||
|
||
def _get_endpoint_path(agentless=False) -> str: | ||
if agentless: | ||
endpoint_path = "/api/v2/profile" | ||
else: | ||
# path is relative because it is appended to the agent base path | ||
endpoint_path = "profiling/v1/input" | ||
return endpoint_path |
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/profiling-dynamic-agent-url-1f285029201620b8.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
features: | ||
- | | ||
profiling: profiler uses agent url configured via ``tracer.configure()`` |
Oops, something went wrong.