-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect artifact size metrics after caching the content
The caching machinery stores all headers from the response coming from content-handler. With this commit, we are introducing an proprietary header that contains the size of the served artifact or artifact available after the redirect, X-PULP-ARTIFACT-SIZE. closes #5817
- Loading branch information
Showing
4 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Started collecting artifact size metrics even after caching the served content. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from opentelemetry import metrics | ||
|
||
from pulpcore.app.util import MetricsEmitter, get_domain, get_worker_name | ||
|
||
|
||
class ArtifactsSizeCounter(MetricsEmitter): | ||
def __init__(self): | ||
self.meter = metrics.get_meter("artifacts.size.meter") | ||
self.counter = self.meter.create_counter( | ||
"artifacts.size.counter", | ||
unit="Bytes", | ||
description="Counts the size of served artifacts", | ||
) | ||
|
||
def add(self, amount): | ||
attributes = { | ||
"domain_name": get_domain().name, | ||
"worker_process": get_worker_name(), | ||
} | ||
self.counter.add(int(amount), attributes) | ||
|
||
|
||
artifacts_size_counter = ArtifactsSizeCounter.build() |