Skip to content

Commit

Permalink
[CI] refcache refresh & cleanup + script update (#5818)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Dec 18, 2024
1 parent c8e8ca9 commit 0f6ae7c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 344 deletions.
2 changes: 1 addition & 1 deletion content/en/blog/2024/profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ many more.
2024 promises to be another big year for OpenTelemetry as we continue to
implement and stabilize our existing tracing, metrics, and log signals while
adding support for profiling, client-side RUM, and more. It’s a great time to
get involvedcheck out our [website](https://opentelemetry.io) to learn more!
get involved! To learn more, check out the rest of the [website](/).

[^1]: Pending due diligence and review by the OpenTelemetry maintainers.

Expand Down
8 changes: 4 additions & 4 deletions content/en/docs/contributing/development.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
title: Development setup and commands to build, serve, and more
linkTitle: Dev setup and more
description:
Learn how to set up a development environment for the opentelemetry.io site.
description: Learn how to set up a development environment for this website.
weight: 60
---

The following instructions explain how to set up a development environment for
the <https://opentelemetry.io/> website.
this website.

## Cloud-IDE setup

Expand All @@ -31,7 +30,8 @@ website files.

## Local setup

1. [Fork][] and then [clone][] this repository.
1. [Fork][] and then [clone][] the website repository at
<{{% _param github_repo %}}>.
2. Go to the repository directory.
3. Install or upgrade to the [**active LTS** release][nodejs-rel] of Node.js.
We recommend using [nvm][] to manage your Node installation. Under Linux,
Expand Down
36 changes: 12 additions & 24 deletions gulp-src/prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function pruneTask() {
},
list: {
type: 'boolean',
description: 'List the <num> + 1 oldest entries. No entries are pruned.',
description: 'List entry prune candidates. No entries are pruned.',
},
}).argv;

Expand Down Expand Up @@ -85,11 +85,6 @@ async function pruneTask() {
const json = await fs.readFile(refcacheFile, 'utf8');
const entries = JSON.parse(json);

if (list) {
listOldest(entries, n + 1);
return;
}

const numEntriesWith4xxStatus = prune4xxEntriesAndReturnCount(entries);

// Create array of entries of prune candidates by date, sorted by LastSeen:
Expand All @@ -111,39 +106,32 @@ async function pruneTask() {
);
}

if (n == 0) {
var keysToPrune = pruneCandidatesByDate__sorted.map((item) => item[0]);
if (n > 0) keysToPrune = keysToPrune.slice(0, n);

if (list) {
listEntries(keysToPrune, entries);
return;
} else if (n == 0) {
console.log(
`WARN: num is ${n} so no entries will be pruned by date. Specify number of entries to prune as --num <n>.`,
);
if (numEntriesWith4xxStatus == 0) return;
}

// Get keys of at most n entries to prune
const keysToPrune = pruneCandidatesByDate__sorted
.slice(0, n)
.map((item) => item[0]);
keysToPrune.forEach((key) => delete entries[key]);
console.log(`INFO: ${keysToPrune.length} entries pruned.`);

const prettyJson = JSON.stringify(entries, null, 2) + '\n';
await fs.writeFile(refcacheFile, prettyJson, 'utf8');
} catch (err) {
console.error(err);
}
}

function listOldest(entries, numberOfEntries) {
const entriesArray = Object.keys(entries)
.map((url) => [url, entries[url].LastSeen, entries[url].StatusCode])
.sort((a, b) => new Date(a[1]) - new Date(b[1]));
const oldestEntries = entriesArray.slice(0, numberOfEntries);

if (oldestEntries.length > 0)
console.log(`Listing oldest ${numberOfEntries} entries:`);

oldestEntries.forEach((e) => {
const date = new Date(e[1]);
console.log(` ${formattedDate(date)} ${formattedTime(date)} for ${e[0]}`);
function listEntries(keys, entries) {
keys.forEach((key) => {
const date = new Date(entries[key].LastSeen);
console.log(` ${formattedDate(date)} ${formattedTime(date)} for ${key}`);
});
}

Expand Down
Loading

0 comments on commit 0f6ae7c

Please sign in to comment.