Module: OpenTelemetry::Helpers::SqlProcessor::SqlCommenter::SqlQuerySetter
- Extended by:
- SqlQuerySetter
- Included in:
- SqlQuerySetter
- Defined in:
- lib/opentelemetry/helpers/sql_processor/commenter.rb
Overview
SqlQuerySetter is responsible for formatting trace context as SQL comments and appending them to SQL queries according to the SQL Commenter specification.
Format: /key='value',key2='value2'/ Values are URL-encoded per the SQL Commenter spec
Instance Method Summary collapse
-
#set(carrier, headers) ⇒ Object
Appends trace context as a SQL comment to the carrier (SQL query string).
Instance Method Details
#set(carrier, headers) ⇒ Object
Appends trace context as a SQL comment to the carrier (SQL query string)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/opentelemetry/helpers/sql_processor/commenter.rb', line 34 def set(carrier, headers) return if headers.empty? return if carrier.frozen? # Convert headers hash to SQL commenter format # Format: /*key1='value1',key2='value2'*/ comment_parts = headers.map do |key, value| # URL encode values as per SQL Commenter spec (using URI component encoding) encoded_value = CGI.escapeURIComponent(value.to_s) "#{key}='#{encoded_value}'" end # Append to end of query (spec recommendation) carrier << " /*#{comment_parts.join(',')}*/" end |