Skip to content

Commit

Permalink
chore(trace): Add trace attributes (#127)
Browse files Browse the repository at this point in the history
Adds the package name and reference, if available, to the trace
attributes.

This allows identifying what package/version caused a slow response.
  • Loading branch information
AllexVeldman authored Dec 7, 2024
1 parent 2824051 commit 7ead818
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pyoci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl PyOci {
/// Push a blob to the registry using POST then PUT method
///
/// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#post-then-put
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name))]
async fn push_blob(
&mut self,
// Name of the package, including namespace. e.g. "library/alpine"
Expand Down Expand Up @@ -548,7 +548,7 @@ impl PyOci {
/// Pull a blob from the registry
///
/// This returns the raw response so the caller can handle the blob as needed
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name))]
async fn pull_blob(
&mut self,
// Name of the package, including namespace. e.g. "library/alpine"
Expand All @@ -568,7 +568,7 @@ impl PyOci {
}

/// List the available tags for a package
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name))]
async fn list_tags(&mut self, name: &str) -> anyhow::Result<TagList> {
let url = build_url!(&self, "/v2/{}/tags/list", name);
let request = self.transport.get(url);
Expand All @@ -585,7 +585,7 @@ impl PyOci {
///
/// ImageIndex will be pushed with a version tag if version is set
/// ImageManifest will always be pushed with a digest reference
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name, otel.version = version))]
async fn push_manifest(
&mut self,
name: &str,
Expand Down Expand Up @@ -624,7 +624,7 @@ impl PyOci {
///
/// If the manifest does not exist, Ok<None> is returned
/// If any other error happens, an Err is returned
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name, otel.reference = reference))]
async fn pull_manifest(&mut self, name: &str, reference: &str) -> Result<Option<Manifest>> {
let url = build_url!(&self, "/v2/{}/manifests/{}", name, reference);
let request = self.transport.get(url).header(
Expand Down Expand Up @@ -664,7 +664,7 @@ impl PyOci {
///
/// reference: tag or digest of the manifest to delete
/// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#content-management
#[tracing::instrument(skip_all)]
#[tracing::instrument(skip_all, fields(otel.name = name, otel.reference = reference))]
async fn delete_manifest(&mut self, name: &str, reference: &str) -> Result<()> {
let url = build_url!(&self, "/v2/{}/manifests/{}", name, reference);
let request = self.transport.delete(url);
Expand Down

0 comments on commit 7ead818

Please sign in to comment.