Skip to content
Open
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
25 changes: 25 additions & 0 deletions src/http_state.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "http_state.hpp"
#include "duckdb/main/query_profiler.hpp"
#include "yyjson.hpp"

using namespace duckdb_yyjson;

namespace duckdb {

Expand Down Expand Up @@ -97,6 +100,28 @@ void HTTPState::WriteProfilingInformation(std::ostream &ss) {
ss << "└─────────────────────────────────────┘\n";
}

//! Write HTTP profiling information to JSON format
//! NOTE: This method is intended to override ClientContextState::WriteProfilingInformationToJSON
//! when DuckDB adds it to the base class. Until then, it's implemented without override.
void HTTPState::WriteProfilingInformationToJSON(duckdb_yyjson::yyjson_mut_doc *doc, duckdb_yyjson::yyjson_mut_val *obj) {
// Skip if no HTTP activity
if (IsEmpty()) {
return;
}

// Create httpfs_stats object with structured metrics
auto httpfs_stats = yyjson_mut_obj(doc);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "total_bytes_received", total_bytes_received);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "total_bytes_sent", total_bytes_sent);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "head_count", head_count);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "get_count", get_count);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "put_count", put_count);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "post_count", post_count);
yyjson_mut_obj_add_uint(doc, httpfs_stats, "delete_count", delete_count);

yyjson_mut_obj_add_val(doc, obj, "httpfs_stats", httpfs_stats);
}

//! Get cache entry, create if not exists
shared_ptr<CachedFile> &HTTPState::GetCachedFile(const string &path) {
lock_guard<mutex> lock(cached_files_mutex);
Expand Down
4 changes: 4 additions & 0 deletions src/include/http_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class HTTPState : public ClientContextState {
Reset();
}
void WriteProfilingInformation(std::ostream &ss) override;
//! Write HTTP profiling information to JSON format
//! NOTE: This method is intended to override ClientContextState::WriteProfilingInformationToJSON
//! when DuckDB adds it to the base class. Until then, it's implemented without override.
void WriteProfilingInformationToJSON(duckdb_yyjson::yyjson_mut_doc *doc, duckdb_yyjson::yyjson_mut_val *obj);

private:
//! Mutex to lock when getting the cached file(Parallel Only)
Expand Down
Loading