Documentation ¶
Index ¶
- Constants
- func ContextInject(ctx context.Context, h RequestTagsProvider) context.Context
- func ConvertMapToComment(tags map[string]string) string
- func ExtractTraceparent(ctx context.Context) propagation.MapCarrier
- func GetFunctionName(i any) string
- type CommenterConfig
- type CommenterOptions
- type RequestTagsProvider
- type StaticTags
Constants ¶
const ( Route string = "route" Controller = "controller" Action = "action" Framework = "framework" Driver = "db_driver" Traceparent = "traceparent" Application = "application" )
Constants used as key string for tags. It is not necessary that all SQLCommenter frameworks/ORMs will contain all these keys i.e. it is on best-effort basis.
Variables ¶
This section is empty.
Functions ¶
func ContextInject ¶
func ContextInject(ctx context.Context, h RequestTagsProvider) context.Context
ContextInject injects the tags key-value pairs into context, which can be later passed into drivers/ORMs to finally inject them into SQL queries.
func ConvertMapToComment ¶
ConvertMapToComment returns a comment string given a map of key-value pairs of tags. There are few steps involved here:
- Sorting the tags by key string
- url encoding the key value pairs
- Formatting the key value pairs as "key1=value1,key2=value2" format.
func ExtractTraceparent ¶
func ExtractTraceparent(ctx context.Context) propagation.MapCarrier
ExtractTraceparent extracts the traceparent field using OpenTelemetry library.
func GetFunctionName ¶
GetFunctionName returns the name of the function passed.
Types ¶
type CommenterConfig ¶
type CommenterConfig struct { EnableDBDriver bool EnableRoute bool EnableFramework bool EnableController bool EnableAction bool EnableTraceparent bool EnableApplication bool }
CommenterConfig contains configurations for SQLCommenter library. We can enable and disable certain tags by enabling these configurations.
type CommenterOptions ¶
type CommenterOptions struct { Config CommenterConfig Tags StaticTags }
CommenterOptions contains all options regarding SQLCommenter library. This includes the configurations as well as any static tags.
type RequestTagsProvider ¶
RequestTagsProvider adds a basic interface for other libraries like gorilla/mux to implement.
type StaticTags ¶
StaticTags are few tags that can be set by the application and will be constant for every API call.