Send webhooks via the Agent EVP Proxy when supported#316
Conversation
916b09e to
cc56d74
Compare
ded1755 to
3f00968
Compare
9836328 to
77679f6
Compare
|
I've changed the detection of the EVP Proxy support to be lazy, so it is checked when it's first needed and the result is cached for 1 hour. This way we don't block at boot time and in the worst case scenario we add a 10 second delay (the timeout of the /info request) once every hour. Most times, the Agent will respond in a few milliseconds or not respond at all (ie: if it's not there or doesn't support the /info API) which will not block. This also lets us support Agent upgrades without having to restart Jenkins. |
b53f7d8 to
2386e37
Compare
And use Mockito.spy to simplify tests
2386e37 to
576f959
Compare
19fa753 to
a0d6d5f
Compare
a0d6d5f to
612116c
Compare
8f8b206 to
c265e86
Compare
|
|
||
| protected boolean checkEvpProxySupportAndUpdateLogic() { | ||
| if (evpProxySupported) { | ||
| return true; // Once we have seen an Agent that supports EVP Proxy, we never check again. |
There was a problem hiding this comment.
Could we have the case of customers downgrading the DD Agent?
There was a problem hiding this comment.
I decided to not support that case so we don't have to always query /info.
There was a problem hiding this comment.
I guess dropping a log message or pointing this case on docs would be great.
| traceBuildLogic = new DatadogWebhookBuildLogic(this); | ||
| tracePipelineLogic = new DatadogWebhookPipelineLogic(this); |
There was a problem hiding this comment.
Could we have race conditions here? Like, the logic started using the version with APM, and then, the logic changes, and it changes to WebHooks? Do we need to protect this case?
There was a problem hiding this comment.
If some spans get sent as traces and others as webhooks, nothing bad happens. I just checked it and the backend even displays them as the same pipeline because of the same trace id!
|
|
||
| protected boolean checkEvpProxySupportAndUpdateLogic() { | ||
| if (evpProxySupported) { | ||
| return true; // Once we have seen an Agent that supports EVP Proxy, we never check again. |
There was a problem hiding this comment.
I guess dropping a log message or pointing this case on docs would be great.
| traceBuildLogic = new DatadogWebhookBuildLogic(this); | ||
| tracePipelineLogic = new DatadogWebhookPipelineLogic(this); |
What does this PR do?
I also added tests for the whole webhooks logic, which didn't have any. They are mostly copies of the tests for the traces logic.
Description of the Change
fetchAgentSupportedEndpoints()method toDatadogAgentClientthat queries the/infoAgent API.postWebhook()method part of the abstractDatadogClientso thatDatadogWebhookBuildLogicandDatadogWebhookPipelineLogiccan call it on either aDatadogAgentClientor aDatadogHttpClientinstance.postWebhook()inDatadogAgentClient. It sends webhook-type payloads using the Agent EVP Proxy.DatadogTraceBuildLogicandDatadogWebhookBuildLogicare now@Overrides of abstract methods of their parentDatadogBaseBuildLogicsoDatadogAgentClientcan use either implementation (depending on the output offetchAgentSupportedEndpoints). Same forDatadog*PipelineLogic.Verification Process
Open Questions
/infoAPI when initializing theDatadogAgentClient. Is this okay?I've added 3 retries at startup time to wait for the Agent.