Skip to content

Add Datadog APM and metrics hooks to Article module#575

Open
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1777488657-add-datadog-hooks
Open

Add Datadog APM and metrics hooks to Article module#575
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1777488657-add-datadog-hooks

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 29, 2026

Summary

Adds Datadog observability hooks to the Article module for demo purposes. This is a focused, single-module integration covering both APM tracing and custom business metrics.

What's included:

  • Dependencies: dd-trace-api, micrometer-registry-datadog, spring-boot-starter-actuator, spring-boot-starter-aop
  • io.spring.observability package:
    • DatadogConfig — Micrometer registry with common tags (service, framework) and @Timed AOP support
    • ArticleMetrics — Custom counters for articles.created, articles.updated, articles.deleted, articles.favorited
  • @Trace annotations on ArticleCommandService.createArticle() and updateArticle() for Datadog APM spans
  • @Timed annotations on ArticleApi (GET, DELETE) and ArticleFavoriteApi (POST) endpoints
  • Spring Security updated to permit unauthenticated access to /actuator/health, /actuator/info, /actuator/metrics/**
  • Datadog config in application.properties (disabled by default; set DD_METRICS_ENABLED=true and DD_API_KEY to activate)

How to run with Datadog APM:

java -javaagent:dd-java-agent.jar \
  -Ddd.service=realworld-api \
  -Ddd.env=demo \
  -jar build/libs/realworld-0.0.1-SNAPSHOT.jar

Review & Testing Checklist for Human

  • Verify ./gradlew clean test passes (68/68 tests green)
  • Confirm Datadog metrics export is disabled by default (DD_METRICS_ENABLED defaults to false)
  • Review that actuator endpoints are appropriately permitted in WebSecurityConfig

Notes

  • Spotless (./gradlew spotlessCheck) fails on the base branch too with Java 17 due to google-java-format module access restrictions — this is a pre-existing issue, not introduced by this PR.
  • The dd-java-agent.jar is a runtime-only component (not bundled). Download it from Datadog releases when running the app.

Link to Devin session: https://app.devin.ai/sessions/95305e1afc44494abc08f411e3a94c30
Requested by: @achalc


Devin Review

Status Commit
⚪ Not started

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)
Open in Devin Review

- Add dd-trace-api, micrometer-registry-datadog, actuator, and AOP dependencies
- Create observability package with DatadogConfig and ArticleMetrics
- Add @trace annotations to ArticleCommandService for APM spans
- Add @timed annotations to ArticleApi and ArticleFavoriteApi endpoints
- Track custom business metrics: articles created/updated/deleted/favorited
- Configure Datadog metrics export in application.properties
- Update tests with MockBean for ArticleMetrics

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Allow unauthenticated access to /actuator/health, /actuator/info,
and /actuator/metrics/** so monitoring tools and load balancers
can reach them without JWT tokens.

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Ensures article delete and favorite metrics are recorded
for both REST and GraphQL code paths.

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
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.

1 participant