Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Correcting time unit for logs of http-service as well as datasources #1214

Merged
merged 9 commits into from
Nov 27, 2024
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (*Client) getColumnsFromColumnsInfo(columns []gocql.ColumnInfo) []string {
}

func (c *Client) sendOperationStats(ql *QueryLog, startTime time.Time, method string, span trace.Span) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

ql.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *client) AsyncInsert(ctx context.Context, query string, wait bool, args

func (c *client) sendOperationStats(start time.Time, methodType, query string, method string,
span trace.Span, args ...interface{}) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

c.logger.Debug(&Log{
Type: methodType,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/file/ftp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func (f *file) WriteAt(p []byte, off int64) (n int, err error) {
}

func (f *file) sendOperationStats(fl *FileLog, startTime time.Time) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

fl.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/file/ftp/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (f *fileSystem) Rename(oldname, newname string) error {
}

func (f *fileSystem) sendOperationStats(fl *FileLog, startTime time.Time) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

fl.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/file/s3/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (f *s3file) Seek(offset int64, whence int) (int64, error) {

// sendOperationStats logs the FileLog of any file operations performed in S3.
func (f *s3file) sendOperationStats(fl *FileLog, startTime time.Time) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

fl.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/file/s3/fs_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (f *fileSystem) renameDirectory(st, msg *string, oldPath, newPath string) e

// sendOperationStats logs the FileLog of any file operations performed in S3.
func (f *fileSystem) sendOperationStats(fl *FileLog, startTime time.Time) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

fl.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/file/sftp/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (f *fileSystem) Getwd() (string, error) {
}

func (f *fileSystem) sendOperationStats(fl *FileLog, startTime time.Time) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

fl.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/kv-store/badger/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *client) useTransaction(f func(txn *badger.Txn) error) error {

func (c *client) sendOperationStats(start time.Time, methodType string, method string,
span trace.Span, kv ...string) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

c.logger.Debug(&Log{
Type: methodType,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (c *Client) CreateCollection(ctx context.Context, name string) error {
}

func (c *Client) sendOperationStats(ql *QueryLog, startTime time.Time, method string, span trace.Span) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

ql.Duration = duration

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/opentsdb/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (ql *QueryLog) PrettyPrint(writer io.Writer) {
}

func sendOperationStats(logger Logger, start time.Time, operation string, status, message *string, span trace.Span) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

logger.Debug(&QueryLog{
Operation: operation,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/redis/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (ql *QueryLog) String() string {

// logQuery logs the Redis query information.
func (r *redisHook) sendOperationStats(start time.Time, query string, args ...interface{}) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

r.logger.Debug(&QueryLog{
Query: query,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/solr/solr.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (c *Client) createRequest(ctx context.Context, method, url string, params m
}

func (c *Client) sendOperationStats(ctx context.Context, ql *QueryLog, startTime time.Time, method string, span trace.Span) {
duration := time.Since(startTime).Milliseconds()
duration := time.Since(startTime).Microseconds()

ql.Duration = duration

Expand Down
4 changes: 2 additions & 2 deletions pkg/gofr/datasource/sql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func clean(query string) string {
}

func (d *DB) sendOperationStats(start time.Time, queryType, query string, args ...interface{}) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

d.logger.Debug(&Log{
Type: queryType,
Expand Down Expand Up @@ -129,7 +129,7 @@ type Tx struct {
}

func (t *Tx) sendOperationStats(start time.Time, queryType, query string, args ...interface{}) {
duration := time.Since(start).Milliseconds()
duration := time.Since(start).Microseconds()

t.logger.Debug(&Log{
Type: queryType,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/grpc/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func LoggingInterceptor(logger Logger) grpc.UnaryServerInterceptor {
l := RPCLog{
ID: trace.SpanFromContext(ctx).SpanContext().TraceID().String(),
StartTime: start.Format("2006-01-02T15:04:05.999999999-07:00"),
ResponseTime: time.Since(start).Milliseconds(),
ResponseTime: time.Since(start).Microseconds(),
Method: info.FullMethod,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/service/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (h *httpService) createAndSendRequest(ctx context.Context, method string, p

respTime := time.Since(requestStart)

log.ResponseTime = respTime.Milliseconds()
log.ResponseTime = respTime.Microseconds()

if err != nil {
log.ResponseCode = http.StatusInternalServerError
Expand Down
Loading