Files
impala/www/query_profile.tmpl
Surya Hebbar 1144d728d7 IMPALA-14180: Fix imported query profiles navbar and datetime
This change corrects the improper rendering of nanosecond walltime
event timestamps in the text profile section of imported query profiles.

The timestamps are now displayed in minutes and seconds, instead of
being displayed in date format. (i.e. 2s120ms, 2ms498us)

The navbar rendering from incorrect declaration in webUI ES6 refactor
IMPALA-13389 has also been corrected.

Incorrectly added columns "Coordinator Slots" and "Executor Slots" in
IMPALA-13726: Add admission control slots to /queries page in webui
have been removed from the imported query profile section.

Change-Id: Id1ad10f469aec085e5b485b4c20d6ab89fe58034
Reviewed-on: http://gerrit.cloudera.org:8080/23067
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2025-06-25 22:00:46 +00:00

177 lines
5.8 KiB
Cheetah

{{?__raw__}}{{{profile}}}{{/__raw__}}
{{^__raw__}}
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
{{> www/common-header.tmpl }}
{{> www/query_detail_tabs.tmpl }}
<script src="{{ __common__.host-url }}/www/scripts/compression_util.js" type="module"></script>
<br/>
<div id="profile_download_section">
<h4>Download Profile (Available Formats):
<a style="font-size:16px;" class="btn btn-primary profile-download"
href="{{ __common__.host-url }}/query_profile_encoded?query_id={{query_id}}"
download="thrift_profile_{{query_id}}">Thrift</a>
<a style="font-size:16px;" class="btn btn-primary profile-download"
href="{{ __common__.host-url }}/query_profile_json?query_id={{query_id}}"
download="json_profile_{{query_id}}">Json</a>
<a style="font-size:16px;" class="btn btn-primary profile-download"
href="{{ __common__.host-url }}/query_profile_plain_text?query_id={{query_id}}"
download="profile_{{query_id}}">Text</a>
</h4>
</div>
<pre id="plain_text_profile_field">{{profile}}</pre>
<script type="module">
$("#profile-tab").addClass("active");
import {inflateParseJSON}
from "{{ __common__.host-url }}/www/scripts/compression_util.js";
const db_open_req = indexedDB.open("imported_queries");
let db;
const supported_tabs = ["Query", "Timeline", "Text plan", "Profile"];
function formatNanoseconds(ns) {
const NS_IN_US = 1_000;
const NS_IN_MS = 1_000_000;
const NS_IN_SEC = 1_000_000_000;
const NS_IN_MIN = 60 * NS_IN_SEC;
const NS_IN_HOUR = 60 * NS_IN_MIN;
let remaining = ns;
const parts = [];
const hours = Math.floor(remaining / NS_IN_HOUR);
if (hours > 0) {
parts.push(`${hours}h`);
remaining %= NS_IN_HOUR;
}
const minutes = Math.floor(remaining / NS_IN_MIN);
if (minutes > 0) {
parts.push(`${minutes}m`);
remaining %= NS_IN_MIN;
}
const seconds = Math.floor(remaining / NS_IN_SEC);
if (parts.length < 2 && seconds > 0) {
parts.push(`${seconds}s`);
remaining %= NS_IN_SEC;
}
const milliseconds = Math.floor(remaining / NS_IN_MS);
if (parts.length < 2 && milliseconds > 0) {
parts.push(`${milliseconds}ms`);
remaining %= NS_IN_MS;
}
const microseconds = Math.floor(remaining / NS_IN_US);
if (parts.length < 2 && microseconds > 0) {
parts.push(`${microseconds}us`);
remaining %= NS_IN_US;
}
if (parts.length < 2 && remaining > 0) {
parts.push(`${remaining}ns`);
}
// If input was 0 ns
return parts.length ? parts.join('') : '0ns';
}
function profileToString(profile, indent="") {
let info_strings = "";
if (profile.info_strings) {
profile.info_strings.forEach(info => {
info_strings = `${info_strings}${indent} ${info.key}: ${info.value}\n`;
});
}
let event_sequences = "";
if (profile.event_sequences && profile.event_sequences.length > 0) {
event_sequences = `${event_sequences}${indent} Event Sequences:\n`;
profile.event_sequences.forEach(eventSeq => {
event_sequences = `${event_sequences}${indent} Offset: ${eventSeq.offset}\n`;
event_sequences = `${event_sequences}${indent} Events:\n`;
eventSeq.events.forEach(event => {
event_sequences = `${event_sequences}${indent} ${event.label}: ${formatNanoseconds(event.timestamp)}\n`;
});
});
}
let child_profiles = "";
if (profile.child_profiles) {
profile.child_profiles.forEach(childProfile => {
child_profiles = `${child_profiles}${profileToString(childProfile, indent + " ")}`;
});
}
let counters = "";
if (profile.counters && profile.counters.length > 0) {
counters = `${counters}${indent} Counters:\n`;
profile.counters.forEach(counter => {
counters = `${counters}${indent} ${counter.counter_name}: ${counter.value} ${counter.unit}\n`;
});
}
return `${indent}${profile.profile_name}:\n${info_strings}${event_sequences}${child_profiles}${counters}`;
}
document.querySelectorAll('.profile-download').forEach((profile_link) => {
profile_link.download = profile_link.download.replace(/\W/g,'_');
});
if (window.location.search.includes("imported")) {
profile_download_section.remove();
const alert_message = document.getElementsByClassName("alert alert-danger")[0];
if (alert_message) {
alert_message.remove();
}
let nav_links = document.getElementsByClassName("nav nav-tabs")[0];
nav_links = nav_links.getElementsByClassName("nav-link");
for (let i = 0; i < nav_links.length;) {
if (supported_tabs.includes(nav_links[i].textContent)) {
nav_links[i].href = `${nav_links[i].href}&imported=true`;
i++;
} else {
nav_links[i].parentElement.remove();
}
}
db_open_req.onsuccess = (e) => {
db = e.target.result;
db.onerror = (e) => {
console.log("IndexedDB error");
console.log(e);
}
const profile_store = db.transaction("profiles", "readonly").objectStore("profiles");
profile_store.get(getQueryID()).onsuccess = (e) => {
plain_text_profile_field.textContent = profileToString(
inflateParseJSON(e.target.result.profile).contents);
};
};
}
</script>
{{> www/common-footer.tmpl }}
{{/__raw__}}