-
Notifications
You must be signed in to change notification settings - Fork 120
[Integration][DataDog] Add Support for Live Events #2174
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
base: main
Are you sure you want to change the base?
[Integration][DataDog] Add Support for Live Events #2174
Conversation
…ove webhook processing - Refactored service dependency fetching methods to utilize the new fetch interval constant. - Removed the create_service_dependency_webhook method and adjusted webhook processing logic to streamline event handling. - Updated tests to cover new service dependency functionality and ensure correct API request parameters.
…ependency-live-events
…ependency-live-events
…ependency-live-events
…ependency-live-events
…g-service-dependency-live-events
Signed-off-by: Dennis Bilson <dennis.bilson@port.io>
…ependency-live-events
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Code Suggestions ✨Explore these optional code suggestions:
|
|
||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Enrich service dependency API response
return result | |
result["name"] = service_id | |
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only inconsistent property ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask❓
This is the only inconsistent property ?
Answer:
No. There are two inconsistencies introduced:
- In examples/blueprints.json, the datadogService blueprint defines a relation named "dependency" targeting "datadogServiceDependency", while the .port/resources/port-app-config.yaml and examples/mappings.yaml create entities of kind serviceDependency that set relations.dependencies (plural) on the datadogServiceDependency entities. These don’t align:
- datadogService has relation "dependency"
- datadogServiceDependency entities set "dependencies" relation (plural) pointing to targets, which implies that the datadogServiceDependency blueprint should own a "dependencies" relation, not the service blueprint—or the service blueprint should expose "dependencies" matching the mapping output. Decide which entity owns the relation and make the naming consistent.
- The ServiceDependency selector/mapping use properties named environment and startTime (camelCase), while the new client method get_single_service_dependency expects parameters env and start_time (snake_case). That’s fine internally, but in tests and processor you cast to DatadogServiceDependencySelector where you reference selector.environment and selector.start_time (snake_case in code vs startTime in config/mappings). Ensure the selector schema and code use the same casing (either both camelCase or both snake_case) to avoid runtime attribute errors.
Suggested fixes:
- Harmonize relation naming and ownership:
- Option A: On datadogService blueprint, rename relation "dependency" to "dependencies" and ensure mappings for serviceDependency set the reverse relation appropriately, or
- Option B: Keep relations on datadogServiceDependency, but then don’t define "dependency" on datadogService, or add the reverse relation with matching name.
- Align selector fields:
- If config uses startTime, map it to start_time in code when parsing, or rename in config to start_time. Similarly ensure environment casing matches. Update tests, processor (selector.start_time), and examples to match.
Signed-off-by: Dennis Bilson <dennis.bilson@port.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some good comments
dd_webhook_url = ( | ||
f"{self.api_url}/api/v1/integration/webhooks/configuration/webhooks" | ||
) | ||
|
||
try: | ||
if await self._webhook_exists(dd_webhook_url): | ||
if await self._webhook_exists(f"{dd_webhook_url}/{webhook_name}"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷🏽♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert change, I think constructing the full url at a single point is much cleaner
|
||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only inconsistent property ?
webhook_secret = ocean.integration_config.get("webhook_secret") | ||
if not webhook_secret: | ||
logger.info("No webhook secret found. Skipping authentication") | ||
return True | ||
|
||
authorization = headers.get("authorization") | ||
if not authorization: | ||
logger.warning( | ||
"Webhook authentication failed due to missing Authorization header in the event" | ||
) | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if there is a an existing authorization, but user does not provide a webhook secret to the integration ?
has_event_info = "event_type" in payload | ||
|
||
has_service_info = False | ||
if "tags" in payload: | ||
service_tags = [ | ||
tag for tag in payload["tags"] if tag.startswith("service:") | ||
] | ||
if service_tags: | ||
if all( | ||
len(tag.split(":", 1)) > 1 and tag.split(":", 1)[1] | ||
for tag in service_tags | ||
): | ||
has_service_info = True | ||
|
||
is_valid = has_service_info and has_event_info | ||
if not is_valid: | ||
logger.warning(f"Invalid webhook payload for service dependency: {payload}") | ||
|
||
return is_valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain why we look out for tags starting with service
keyword specifically ?
And how is this consistent with resync ?
User description
Description
What - Added support for Datadog Service Dependency Live Events in the Port Datadog integration. This enables ingestion and processing of live dependency data for services, expanding observability within Port.
Why - Previously, the integration only supported static service dependency data. By introducing live event handling, teams can now track real-time changes in service dependencies, improving incident response, dependency mapping, and operational visibility.
How -
• Extended the Datadog integration to subscribe to and process live service dependency events
• Implemented event transformation and mapping logic to Port’s internal service dependency model.
• Added error handling, retries, and logging to ensure robust ingestion of live events.
• Updated tests and documentation to cover new live event functionality.
Type of change
Please leave one option from the following and delete the rest:
All tests should be run against the port production environment(using a testing org).
Core testing checklist
Integration testing checklist
examples
folder in the integration directory.Preflight checklist
Screenshots
Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.
PR Type
Enhancement
Description
Added live event support for Datadog service dependencies
Implemented service dependency webhook processor for real-time updates
Enhanced client with single service dependency fetching capability
Refactored webhook authentication to shared abstract base class
Diagram Walkthrough
File Walkthrough
5 files
Enhanced client with service dependency fetching
Added service dependency webhook processor registration
Created shared webhook authentication base class
Refactored to use abstract webhook processor
Implemented service dependency webhook event handling
1 files
Updated client test formatting
2 files
Refactored monitor webhook processor tests
Added comprehensive service dependency webhook tests
5 files
Added service dependency resource configuration
Added service dependency to feature list
Updated blueprints with service dependency schema
Added service dependency mapping configuration
Bumped version to 0.3.21
1 files
Added version 0.3.21 release notes