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

Implement Python API for submitting logs #26978

Merged
merged 1 commit into from
Jul 31, 2024
Merged

Implement Python API for submitting logs #26978

merged 1 commit into from
Jul 31, 2024

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Jun 22, 2024

Motivation

Expose the new functionality to Python checks #26753

Additional Notes

After the base PR is merged this PR will re-target main

@ofek ofek added team/integrations team/agent-metrics-logs qa/done Skip QA week as QA was done before merge and regressions are covered by tests labels Jun 22, 2024
@ofek ofek requested review from a team as code owners June 22, 2024 19:33
---
enhancements:
- |
Implement API that allows Python checks to send logs for
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Implement API that allows Python checks to send logs for
Implements API that allows Python checks to send logs for

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this is desirable as these entries get directly put on the Agent release change log. In that context, it's less so that we are describing this specific patch but rather as a whole. Does that make sense?

Copy link
Contributor

@rtrieu rtrieu left a comment

Choose a reason for hiding this comment

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

Minor feedback but otherwise looks good!

@pr-commenter
Copy link

pr-commenter bot commented Jul 2, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=40520993 --os-family=ubuntu

Note: This applies to commit a775579

@pr-commenter
Copy link

pr-commenter bot commented Jul 2, 2024

Regression Detector

Regression Detector Results

Run ID: 17736aeb-9360-4daa-92b7-fbc816faa9fb Metrics dashboard Target profiles

Baseline: fc52f43
Comparison: a775579

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI links
otel_to_otel_logs ingress throughput +0.10 [-0.71, +0.91] Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.00, +0.00] Logs
file_tree memory utilization -0.41 [-0.49, -0.33] Logs
basic_py_check % cpu utilization -0.63 [-3.14, +1.88] Logs
idle memory utilization -0.64 [-0.68, -0.60] Logs
uds_dogstatsd_to_api_cpu % cpu utilization -2.21 [-3.09, -1.32] Logs
pycheck_1000_100byte_tags % cpu utilization -2.22 [-6.90, +2.45] Logs
tcp_syslog_to_blackhole ingress throughput -3.93 [-16.32, +8.46] Logs

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@ofek ofek force-pushed the ofek/logs branch 2 times, most recently from 4cd843a to b489f51 Compare July 5, 2024 14:55
Base automatically changed from lucas.liseth/go-interface-for-logs-from-integrations to main July 22, 2024 14:31
@dd-mergequeue dd-mergequeue bot requested review from a team as code owners July 22, 2024 14:31
Py_RETURN_NONE;
}

char *log_line, *check_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand Python's documentation correctly, these should be const char* as the memory is owned by python

This would imply the cb_send_log_t type should also be updated to pass both parameters as pointers to constant chars

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same as every function in this file; are you certain?

Copy link
Contributor

Choose a reason for hiding this comment

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

Quite certain:

Other formats take a str or a read-only bytes-like object, such as bytes, and provide a const char * pointer to its buffer. In this case the buffer is “borrowed”: it is managed by the corresponding Python object, and shares the lifetime of this object. You won’t have to release any memory yourself.

https://docs.python.org/3/c-api/arg.html#strings-and-buffers

It doesn't make an actual difference for most purposes, but having a const char' makes it clear that we don't own that memory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! This will be done in a follow-up PR.

rtloader/common/builtins/datadog_agent.c Show resolved Hide resolved

This function is callable as the `datadog_agent.send_log` Python method and
uses the `cb_send_log()` callback to retrieve the value from the agent
with CGO. If the callback has not been set `None` will be returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

If the callback has not been set None will be returned.

This seems to imply that a different result would be returned if a callback was set, which isn't the case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every function has this documentation; are they all incorrect?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's incorrect, but the last sentence seems misleading since None is always returned.
Now to be clear, this is definitely in the nit picking realm and can be ignored

comp/logs/integrations/impl/integrations.go Outdated Show resolved Hide resolved
comp/logs/integrations/def/component.go Outdated Show resolved Hide resolved
comp/logs/integrations/impl/integrations_test.go Outdated Show resolved Hide resolved
cmd/agent/subcommands/run/command.go Outdated Show resolved Hide resolved
comp/logs/integrations/fx/fx.go Outdated Show resolved Hide resolved
comp/logs/integrations/mock/mock.go Outdated Show resolved Hide resolved
@pgimalac
Copy link
Member

I realized that most of my comments are about code from #26753 which is already merged, you might want to pull main to remove those commits

@ofek
Copy link
Contributor Author

ofek commented Jul 31, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jul 31, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 22m.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Jul 31, 2024

🚨 MergeQueue: This merge request is in error

Gitlab pipeline didn't start on its own and we were unable to create it... Please retry.

If you need support, contact us on Slack #devflow with those details!

@ofek
Copy link
Contributor Author

ofek commented Jul 31, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jul 31, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 22m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit eee54f7 into main Jul 31, 2024
220 checks passed
@dd-mergequeue dd-mergequeue bot deleted the ofek/logs branch July 31, 2024 14:20
@github-actions github-actions bot added this to the 7.57.0 milestone Jul 31, 2024
carlosroman added a commit that referenced this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qa/done Skip QA week as QA was done before merge and regressions are covered by tests team/agent-metrics-logs team/integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants