Skip to content

Implement a mechanism for adding ad-hoc listeners to OKHTTP requests#6660

Merged
nikita-tkachenko-datadog merged 3 commits intomasterfrom
nikita-tkachenko/okhttp-listeners
Feb 14, 2024
Merged

Implement a mechanism for adding ad-hoc listeners to OKHTTP requests#6660
nikita-tkachenko-datadog merged 3 commits intomasterfrom
nikita-tkachenko/okhttp-listeners

Conversation

@nikita-tkachenko-datadog
Copy link
Copy Markdown
Contributor

@nikita-tkachenko-datadog nikita-tkachenko-datadog commented Feb 10, 2024

What Does This Do

Adds a mechanism for registering ad-hoc event listeners for okhttp requests.
A listener can be registered when building a request:

class MyListener extends OkHttpUtils.CustomListener {
    // override event handlers
} 

final Request request =
        new Request.Builder()
            .url(...)
            .post(...)
            .tag(OkHttpUtils.CustomListener.class, new MyListener())
            .build();

Motivation

This is needed for CI Visibility telemetry. There are metrics like requests count, errors count, request size, etc for events/coverages intake, CI Visibility Git API and other endpoitns.

Additional Notes

EventListener.NONE is what all the requests are using by default: it is a listener that has an empty handler for every event.
With the new mechanism this "empty" listener is replaced with a custom one for those requests that have the corresponding tag.

This PR only adds the means for registering custom listeners. Actual listeners will be added in a separate PR.

Jira ticket: CIVIS-2427

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Feb 10, 2024

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master nikita-tkachenko/okhttp-listeners
git_commit_date 1707816252 1707815927
git_commit_sha 8f172ea 5e7db9c
release_version 1.31.0-SNAPSHOT~8f172eab66 1.31.0-SNAPSHOT~5e7db9cafb
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1707820257 1707820257
ci_job_id 432548172 432548172
ci_pipeline_id 28195148 28195148
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
module Agent Agent
parent None None
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 9 unstable metrics.

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-02-13T10:07:01 2024-02-13T10:25:55
git_branch master nikita-tkachenko/okhttp-listeners
git_commit_date 1707816252 1707815927
git_commit_sha 8f172ea 5e7db9c
release_version 1.31.0-SNAPSHOT~8f172eab66 1.31.0-SNAPSHOT~5e7db9cafb
start_time 2024-02-13T10:06:48 2024-02-13T10:25:42
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1707820257 1707820257
ci_job_id 432548172 432548172
ci_pipeline_id 28195148 28195148
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 14 unstable metrics.

Copy link
Copy Markdown
Contributor

@nayeem-kamal nayeem-kamal left a comment

Choose a reason for hiding this comment

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

LGTM.

@nikita-tkachenko-datadog nikita-tkachenko-datadog merged commit da71297 into master Feb 14, 2024
@nikita-tkachenko-datadog nikita-tkachenko-datadog deleted the nikita-tkachenko/okhttp-listeners branch February 14, 2024 20:45
@github-actions github-actions Bot added this to the 1.30.0 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants