Skip to content

Conversation

@mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Sep 14, 2025

Which problem is this PR solving?

Description of the changes

  • This PR adds attributes for events in the ClickHouse storage.

How was this change tested?

Started the ClickHouse server on my local machine using

./clickhouse server

Initialized the tables using

/Users/mzaryab/clickhouse client --multiquery < schema.sql

Seeded the database using test.sql

/Users/mzaryab/clickhouse client --multiquery < test.sql

Wrote a Go unit test to run GetTraces and got the following output

Span: POST /api/order, Start: 2025-09-14 03:03:10 +0000 UTC, Duration: 2.5s
Event: checkout, Timestamp: 2025-09-14 03:03:08 +0000 UTC
Event Attribute: payment_verified = true
Event Attribute: amount = 199.99
Event Attribute: transaction_id = 78901
Event Attribute: payment_method = credit_card
Event Attribute: receipt = eyJyZWNlaXB0IjoidmFsaWQifQ==
Event: payment, Timestamp: 2025-09-14 03:03:09 +0000 UTC
Event Attribute: transaction_complete = true
Event Attribute: processing_fee = 2.99
Event Attribute: merchant_id = 456
Event Attribute: currency = USD
Event Attribute: confirmation = eyJzdGF0dXMiOiJjb21wbGV0ZSJ9
Link: TraceID: 00000000000000000000000000000001, SpanID: 0000000000000001, TraceState: state1
Link: TraceID: 00000000000000000000000000000003, SpanID: 0000000000000003, TraceState: state1
Attribute: payment_successful = true
Attribute: idempotent = true
Attribute: checkout_time = 1.234
Attribute: memory_usage = 78.9
Attribute: order_id = 98765
Attribute: items_count = 3
Attribute: http.method = POST
Attribute: db.system = mysql
Attribute: order_payload = eyJpdGVtcyI6WyJib29rIiwiY2hlY2tvdXQiXX0=

Checklist

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1 mahadzaryab1 added the changelog:exprimental Change to an experimental part of the code label Sep 14, 2025
@codecov
Copy link

codecov bot commented Sep 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.62%. Comparing base (832d9d8) to head (1341a67).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7512      +/-   ##
==========================================
- Coverage   96.64%   96.62%   -0.03%     
==========================================
  Files         377      378       +1     
  Lines       23145    23146       +1     
==========================================
- Hits        22368    22364       -4     
- Misses        592      596       +4     
- Partials      185      186       +1     
Flag Coverage Δ
badger_v1 9.04% <ø> (+0.01%) ⬆️
badger_v2 1.70% <ø> (+<0.01%) ⬆️
cassandra-4.x-v1-manual 11.70% <ø> (+0.01%) ⬆️
cassandra-4.x-v2-auto 1.69% <ø> (+<0.01%) ⬆️
cassandra-4.x-v2-manual 1.69% <ø> (+<0.01%) ⬆️
cassandra-5.x-v1-manual 11.70% <ø> (+0.01%) ⬆️
cassandra-5.x-v2-auto 1.69% <ø> (+<0.01%) ⬆️
cassandra-5.x-v2-manual 1.69% <ø> (+<0.01%) ⬆️
elasticsearch-6.x-v1 16.61% <ø> (+0.01%) ⬆️
elasticsearch-7.x-v1 16.65% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v1 16.79% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v2 1.70% <ø> (+<0.01%) ⬆️
elasticsearch-9.x-v2 1.70% <ø> (+<0.01%) ⬆️
grpc_v1 10.24% <ø> (+0.01%) ⬆️
grpc_v2 1.70% <ø> (+<0.01%) ⬆️
kafka-3.x-v1 9.68% <ø> (+<0.01%) ⬆️
kafka-3.x-v2 1.70% <ø> (+<0.01%) ⬆️
memory_v2 1.70% <ø> (+<0.01%) ⬆️
opensearch-1.x-v1 16.70% <ø> (+0.01%) ⬆️
opensearch-2.x-v1 16.70% <ø> (+0.01%) ⬆️
opensearch-2.x-v2 1.70% <ø> (+<0.01%) ⬆️
opensearch-3.x-v2 1.70% <ø> (+<0.01%) ⬆️
query 1.70% <ø> (+<0.01%) ⬆️
tailsampling-processor 0.47% <ø> (+<0.01%) ⬆️
unittests 95.61% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Sep 14, 2025

Metrics Comparison Summary

Total changes across all snapshots: 53

Detailed changes per snapshot

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 53

  • 🆕 Added: 0 metrics
  • ❌ Removed: 53 metrics
  • 🔄 Modified: 0 metrics

❌ Removed Metrics

  • http_server_request_body_size_bytes (18 variants)
View diff sample
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="0",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="100",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="1000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="25",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
...
- `http_server_request_duration_seconds` (17 variants)
View diff sample
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.005",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.01",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.025",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.05",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.075",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.1",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
...
- `http_server_response_body_size_bytes` (18 variants)
View diff sample
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="0",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="100",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="1000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
-http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="25",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.62.0",server_address="localhost",server_port="13133",url_scheme="http"}
...

➡️ View full metrics file

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review September 14, 2025 18:48
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner September 14, 2025 18:48
}

func populateComplexAttributes(span ptrace.Span, complexAttributes []Attribute[string]) {
func populateComplexAttributes(span ptrace.Span, attributes pcommon.Map, complexAttributes []Attribute[string]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why pass attributes explicitly? Aren't they part of span argument?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see why, span is for warnings. It should be in the last position as an argument, and maybe called spanForWarnings

@yurishkuro
Copy link
Member

Wrote a Go unit test to run GetTraces and got the following output

when will we be ready to integrate CH into db e2e tests? We can disable most of the tests for now, but it would be good to have CI going, rather than manual testing.

Signed-off-by: Mahad Zaryab <[email protected]>
Comment on lines 247 to 251
BoolAttributes: zipAttributes(boolAttributeKeys[i], boolAttributeValues[i]),
DoubleAttributes: zipAttributes(doubleAttributeKeys[i], doubleAttributeValues[i]),
IntAttributes: zipAttributes(intAttributeKeys[i], intAttributeValues[i]),
StrAttributes: zipAttributes(strAttributeKeys[i], strAttributeValues[i]),
ComplexAttributes: zipAttributes(complexAttributeKeys[i], complexAttributeValues[i]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array bounds error: The code accesses event attribute arrays using index i without checking if the arrays have sufficient length. If any of the event attribute arrays (boolAttributeKeys, boolAttributeValues, etc.) have fewer elements than the number of events, this will cause an index out of bounds panic at runtime. Add bounds checking before accessing these arrays, or ensure all arrays have the same length as the events arrays.

Suggested change
BoolAttributes: zipAttributes(boolAttributeKeys[i], boolAttributeValues[i]),
DoubleAttributes: zipAttributes(doubleAttributeKeys[i], doubleAttributeValues[i]),
IntAttributes: zipAttributes(intAttributeKeys[i], intAttributeValues[i]),
StrAttributes: zipAttributes(strAttributeKeys[i], strAttributeValues[i]),
ComplexAttributes: zipAttributes(complexAttributeKeys[i], complexAttributeValues[i]),
BoolAttributes: safeZipAttributes(boolAttributeKeys, boolAttributeValues, i),
DoubleAttributes: safeZipAttributes(doubleAttributeKeys, doubleAttributeValues, i),
IntAttributes: safeZipAttributes(intAttributeKeys, intAttributeValues, i),
StrAttributes: safeZipAttributes(strAttributeKeys, strAttributeValues, i),
ComplexAttributes: safeZipAttributes(complexAttributeKeys, complexAttributeValues, i),

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a bad suggestion. If there is some hiccup in the storage / driver and we get malformed data back the server will panic, which is not good. I would add an extra function to check that all array sizes are correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to address this in a follow-up PR

@mahadzaryab1
Copy link
Collaborator Author

Wrote a Go unit test to run GetTraces and got the following output

when will we be ready to integrate CH into db e2e tests? We can disable most of the tests for now, but it would be good to have CI going, rather than manual testing.

@yurishkuro I think we should be able to do so once we complete the Writer implementation

EventStrAttributeKeys [][]string
EventStrAttributeValues [][]string
EventComplexAttributeKeys [][]string
EventComplexAttributeValues [][]string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SpanRow struct repeats the same shape as an assortment of standalone variables in reader.go. Why not move the struct there, use it for loading, and reuse it here?

ComplexAttributeValues []string
EventNames []string
EventTimestamps []time.Time
EventBoolAttributeKeys [][]string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This group of fields should be its own struct because you will have to repeat them for Links.

@yurishkuro
Copy link
Member

I think we should be able to do so once we complete the Writer implementation

Why don't we do that instead of going after more exotic data elements? I would start with having CI-tested read/write cycle for core fields, then incrementally add more fields.

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Comment on lines +162 to +166
BoolAttributes: zipAttributes(boolAttributeKeys[i], boolAttributeValues[i]),
DoubleAttributes: zipAttributes(doubleAttributeKeys[i], doubleAttributeValues[i]),
IntAttributes: zipAttributes(intAttributeKeys[i], intAttributeValues[i]),
StrAttributes: zipAttributes(strAttributeKeys[i], strAttributeValues[i]),
ComplexAttributes: zipAttributes(complexAttributeKeys[i], complexAttributeValues[i]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array bounds vulnerability: The buildEvents function accesses event attribute arrays by index [i] without bounds checking. If the attribute arrays have fewer elements than the names/timestamps arrays, this will cause a panic with 'index out of range'. The function should validate that all attribute arrays have at least i+1 elements before accessing index [i], or use safe indexing with length checks.

Suggested change
BoolAttributes: zipAttributes(boolAttributeKeys[i], boolAttributeValues[i]),
DoubleAttributes: zipAttributes(doubleAttributeKeys[i], doubleAttributeValues[i]),
IntAttributes: zipAttributes(intAttributeKeys[i], intAttributeValues[i]),
StrAttributes: zipAttributes(strAttributeKeys[i], strAttributeValues[i]),
ComplexAttributes: zipAttributes(complexAttributeKeys[i], complexAttributeValues[i]),
BoolAttributes: safeZipAttributes(boolAttributeKeys, boolAttributeValues, i),
DoubleAttributes: safeZipAttributes(doubleAttributeKeys, doubleAttributeValues, i),
IntAttributes: safeZipAttributes(intAttributeKeys, intAttributeValues, i),
StrAttributes: safeZipAttributes(strAttributeKeys, strAttributeValues, i),
ComplexAttributes: safeZipAttributes(complexAttributeKeys, complexAttributeValues, i),

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@yurishkuro yurishkuro merged commit 34d99f7 into jaegertracing:main Sep 19, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage changelog:exprimental Change to an experimental part of the code v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants