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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ You can also check the

## Unreleased

- Features
- Add SPARQL endpoints in the OpenTelemetry traces

### 6.4.0 – 2026-03-13

- Maintenance
Expand Down
15 changes: 15 additions & 0 deletions app/graphql/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ const setupSparqlClients = (
endpointUrl: SPARQL_GEO_ENDPOINT,
});

const sourceUrlHostname = new URL(sourceUrl).hostname;
const geoEndpointHostname = new URL(SPARQL_GEO_ENDPOINT).hostname;

const saveTimingToContext: TimingCallback = (t, ...args: [string]) => {
ctx.queries.push({
startTime: t.start,
Expand All @@ -118,9 +121,11 @@ const setupSparqlClients = (
return tracer.startActiveSpan("sparqlClient.query.select", async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", sourceUrlHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": sourceUrl,
});
return await originalSparqlClientQuerySelect.call(this, query, ...args);
} finally {
Expand All @@ -140,9 +145,11 @@ const setupSparqlClients = (
async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", sourceUrlHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": sourceUrl,
});
return await originalSparqlClientQueryConstruct.call(
this,
Expand All @@ -167,9 +174,11 @@ const setupSparqlClients = (
async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", sourceUrlHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": sourceUrl,
});
return await originalSparqlClientStreamQuerySelect.call(
this,
Expand All @@ -195,9 +204,11 @@ const setupSparqlClients = (
async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", sourceUrlHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": sourceUrl,
});
return await originalSparqlClientStreamQueryConstruct.call(
this,
Expand All @@ -222,9 +233,11 @@ const setupSparqlClients = (
async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", geoEndpointHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": SPARQL_GEO_ENDPOINT,
});
return await originalGeoSparqlClientQuerySelect.call(
this,
Expand All @@ -249,9 +262,11 @@ const setupSparqlClients = (
async (span) => {
try {
span.setAttribute("db.sparql.has_query_event", true);
span.setAttribute("server.address", geoEndpointHostname);
span.addEvent("sparql.query", {
"db.query.text": query,
"db.system.name": "sparql",
"url.full": SPARQL_GEO_ENDPOINT,
});
return await originalGeoSparqlClientQueryConstruct.call(
this,
Expand Down
Loading