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

Bugs fix #2409

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 57 additions & 7 deletions packages/hub-web/examples/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,63 @@ async function listen() {

do {
try {
const url = `${server}/v1/events?from_event_id=${from_event_id}`;
const response = await axios.get(url);
for (const event of response.data.events) {
console.log(event);
}
if (response.data.events.length <= 1) {
// wait a bit if there are no events
import axios from "axios";

const handleEvents = async () => {
try {
// Safely construct the URL using the URL object
const serverUrl = new URL(`${server}/v1/events`);
serverUrl.searchParams.append("from_event_id", from_event_id);

// Execute the request using axios
const response = await axios.get(serverUrl.toString());

// Process each event from the response
for (const event of response.data.events) {
console.log(event);
}

// Check for absence or minimal number of events
if (response.data.events.length <= 1) {
console.log("No events or only one event found. Waiting...");
// Implement wait logic here if needed
}
} catch (error) {
// Handle errors and provide meaningful feedback
console.error("Error fetching events:", error.message);
}
};

handleEvents();
import axios from "axios";

const handleEvents = async () => {
try {
// Safely construct the URL using the URL object
const serverUrl = new URL(`${server}/v1/events`);
serverUrl.searchParams.append("from_event_id", from_event_id);

// Execute the request using axios
const response = await axios.get(serverUrl.toString());

// Process each event from the response
for (const event of response.data.events) {
console.log(event);
}

// Check for absence or minimal number of events
if (response.data.events.length <= 1) {
console.log("No events or only one event found. Waiting...");
// Implement wait logic here if needed
}
} catch (error) {
// Handle errors and provide meaningful feedback
console.error("Error fetching events:", error.message);
}
};

handleEvents();

await new Promise((resolve) => setTimeout(resolve, 1000));
}
from_event_id = response.data.nextPageEventId;
Expand Down
9 changes: 7 additions & 2 deletions scripts/hubble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,16 @@ setup_grafana() {
ensure_grafana

# Step 2: Wait for Grafana to be ready
wait_for_grafana() {
echo "Waiting for Grafana to be ready..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $grafana_url/api/health)" != "200" ]]; do
sleep 2;
while [[ "$(curl -s -o /dev/null -w '%{http_code}' "$grafana_url/api/health")" != "200" ]]; do
sleep 2
done
echo "Grafana is ready."
}

# Call the function to wait for Grafana
wait_for_grafana

# Step 3: Add Graphite as a data source using Grafana's API
add_datasource
Expand Down