Categorygithub.com/google/sqlcommenter/go/core
modulepackage
0.1.2
Repository: https://github.com/google/sqlcommenter.git
Documentation: pkg.go.dev

# README

SQLCommenter Core [In development]

SQLcommenter is a plugin/middleware/wrapper to augment application related information/tags with SQL Statements that can be used later to correlate user code with SQL statements.

This package contains configuration options, framework interface and support functions for all the sqlcommenter go modules

Installation

This is a support package and will be installed indirectly by other go sqlcommenter packages

Usages

Configuration

Users are given control over what tags they want to append by using core.CommenterConfig struct.

type CommenterConfig struct {
    EnableDBDriver    bool
    EnableRoute       bool
    EnableFramework   bool
    EnableController  bool
    EnableAction      bool
    EnableTraceparent bool
    EnableApplication bool
}

Users can also set the values for some static tags by using core.StaticTags struct.

type StaticTags struct {
    Application string
    DriverName  string
}

These two structs together form the core.CommenterOptions struct, which is used by sqlcommenter/go/database/sql.

type CommenterOptions struct {
    Config CommenterConfig
    Tags   StaticTags
}

# Functions

ContextInject injects the tags key-value pairs into context, which can be later passed into drivers/ORMs to finally inject them into SQL queries.
ConvertMapToComment returns a comment string given a map of key-value pairs of tags.
ExtractTraceparent extracts the traceparent field using OpenTelemetry library.
GetFunctionName returns the name of the function passed.

# Constants

Constants used as key string for tags.
Constants used as key string for tags.
Constants used as key string for tags.
Constants used as key string for tags.
Constants used as key string for tags.
Constants used as key string for tags.
Constants used as key string for tags.

# Structs

CommenterConfig contains configurations for SQLCommenter library.
CommenterOptions contains all options regarding SQLCommenter library.
StaticTags are few tags that can be set by the application and will be constant for every API call.

# Interfaces

RequestTagsProvider adds a basic interface for other libraries like gorilla/mux to implement.