Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new metadata to Datadog traces (attempt 2) #1770

Merged
merged 8 commits into from
Nov 20, 2020

Conversation

macaptain
Copy link
Contributor

Overview

Re-implementation of #1763

Add service, version and error metadata to traces in Datadog APM traces.

What you see in the traces:

  • The service name (default 'web' for Phoenix applications) is the name of the OMG application.
  • Traces are tagged with application version number
  • For API responses which error, the trace is flagged red as an error, the error code is marked on the trace and the error message is found in the tags.

image

Changes

  • Move service name and version getters from the Response module to the Application module.
  • Add a function for customizing trace metadata for Spandex which fetches details from conn.assigns and the service / version getters.
  • Add two tests for the trace metadata function.

Testing

DD_API_KEY=<some-api-key> docker-compose -f docker-compose-watcher.yml -f docker-compose.dev.yml up
make docker-update-watcher
make docker-update-watcher_info

Make API calls to the Watcher endpoints, and check the local-development environment APM Services in Datadog. Look for a service called "Watcher" and check the traces look as expected in the screenshot above.

@macaptain macaptain added the enhancement New feature or request label Nov 16, 2020
Add service, version and error metadata to traces in Datadog APM traces.

What you see in the traces:
* The service name (default 'web' for Phoenix applications) is the name
of the OMG application.
* Traces are tagged with application version number
* For API responses which error, the trace is flagged red as an error,
the error code is marked on the trace and the error message is found
in the tags.
@macaptain macaptain changed the title feat: add new metadata to Datadog traces feat: add new metadata to Datadog traces (attempt 2) Nov 16, 2020

test "api responses without errors get traced with metadata" do
:ok = Application.put_env(@app, :api_mode, :watcher)
version = OMGApplication.version()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if there's a better way to mock the call of version().

Moved from Application to Configuration for WatcherRPC.
apps/omg_watcher_rpc/lib/application.ex Outdated Show resolved Hide resolved
apps/omg_watcher_rpc/lib/web/response.ex Outdated Show resolved Hide resolved
@macaptain macaptain merged commit 0a7a6e8 into master Nov 20, 2020
@macaptain macaptain deleted the add-metadata-to-dd-traces-2 branch November 20, 2020 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants