DatadogTarget: Customize site variable#1433
Conversation
odacremolbap
left a comment
There was a problem hiding this comment.
Nicely done, thanks so much for bringing this.
I asked for some optimizations, let's see what you think.
|
|
||
| type datadogAdapter struct { | ||
| apiKey string | ||
| site string |
There was a problem hiding this comment.
nit: we could do a very slight optimization here.
Creating 2 fields at the adapter called
apiURLapiLogsURL
At the NewTarget function we add the base to the site suffix and assign the result to those variables above.
That way we avoid an fmt.Sprintf for each processed event.
There was a problem hiding this comment.
It's done ✅ I was also tempted to move the newLogsAPIRequest and newAPIRequest into the struct to access it directly, let me know if that's something we'd prefer.
There was a problem hiding this comment.
yep, we could optimize something there and keep at the structure the host + path for:
- metric
- event
- log
instead of joining them at every call.
since that is not related to this PR, I am merging this as is.
Feel free to improve the DatadogTarget adapter with the changes that you mention in a new PR if you will 🚀
Your CRD update is good. Can you execute that and include the updated file in this PR? |
When I run this command, this deletes a lot of files under Thanks for the review! |
|
This is what I get after the ❯ make codegen
+ Generating deepcopy funcs for sources/v1alpha1 targets/v1alpha1 flow/v1alpha1 extensions/v1alpha1 routing/v1alpha1
+ Generating clientsets for sources/v1alpha1 targets/v1alpha1 flow/v1alpha1 extensions/v1alpha1 routing/v1alpha1
+ Generating listers for sources/v1alpha1 targets/v1alpha1 flow/v1alpha1 extensions/v1alpha1 routing/v1alpha1
+ Generating informers for sources/v1alpha1 targets/v1alpha1 flow/v1alpha1 extensions/v1alpha1 routing/v1alpha1
+ Generating injection for sources/v1alpha1 targets/v1alpha1 flow/v1alpha1 extensions/v1alpha1 routing/v1alpha1
❯ git status
On branch datadog-site
Your branch is up to date with 'manomano/datadog-site'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pkg/apis/targets/v1alpha1/deepcopy_generated.go
no changes added to commit (use "git add" and/or "git commit -a")and this is the file's diff diff --git a/pkg/apis/targets/v1alpha1/deepcopy_generated.go b/pkg/apis/targets/v1alpha1/deepcopy_generated.go
index 31c50f22..b3b197a6 100644
--- a/pkg/apis/targets/v1alpha1/deepcopy_generated.go
+++ b/pkg/apis/targets/v1alpha1/deepcopy_generated.go
@@ -1301,6 +1301,11 @@ func (in *DatadogTargetList) DeepCopyObject() runtime.Object {
func (in *DatadogTargetSpec) DeepCopyInto(out *DatadogTargetSpec) {
*out = *in
in.DatadogAPIKey.DeepCopyInto(&out.DatadogAPIKey)
+ if in.DatadogSite != nil {
+ in, out := &in.DatadogSite, &out.DatadogSite
+ *out = new(string)
+ **out = **in
+ }
if in.MetricPrefix != nil {
in, out := &in.MetricPrefix, &out.MetricPrefix
*out = new(string)Yes, the command is expected to re-generate the kubernetes code under Can you post here the output when you exec the |
See https://docs.datadoghq.com/getting_started/site/ Signed-off-by: Adrien Fillon <adrien.fillon@manomano.com>
|
Alright for some reason, they were generated in a folder |
odacremolbap
left a comment
There was a problem hiding this comment.
All good.
Thanks so much @adrien-f

Datadog is multi-site and each site gets its own domain so we need to be able to customize it.
See https://docs.datadoghq.com/getting_started/site/