<commit_before>package rocserv

import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"strings"

	"gitlab.pri.ibanyu.com/middleware/seaweed/xcontext"
	"gitlab.pri.ibanyu.com/middleware/seaweed/xlog"
	"gitlab.pri.ibanyu.com/middleware/seaweed/xtrace"

	"github.com/uber/jaeger-client-go"
)

const (
	TrafficLogID              = "TRAFFIC"
	TrafficLogKeyUID          = "uid"
	TrafficLogKeyGroup        = "group"
	TrafficLogKeyTraceID      = "tid"
	TrafficLogKeySpanID       = "sid"
	TrafficLogKeyParentSpanID = "pid"
	TrafficLogKeyOperation    = "op"
	TrafficLogKeyCaller       = "caller"
	TrafficLogKeyServerType   = "stype"
	TrafficLogKeyServerID     = "srvid"
	TrafficLogKeyServerName   = "sname"
)

func httpTrafficLogMiddleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// NOTE: log before handling business logic
		logTrafficForHttpServer(r.Context())
		next.ServeHTTP(w, r)
	})
}

func trafficKVFromContext(ctx context.Context) (kv map[string]interface{}) {
	kv = map[string]interface{}{}<commit_msg>remove logs in http middleware<commit_after>package rocserv

import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"strings"

	"gitlab.pri.ibanyu.com/middleware/seaweed/xcontext"
	"gitlab.pri.ibanyu.com/middleware/seaweed/xlog"
	"gitlab.pri.ibanyu.com/middleware/seaweed/xtrace"

	"github.com/uber/jaeger-client-go"
)

const (
	TrafficLogID              = "TRAFFIC"
	TrafficLogKeyUID          = "uid"
	TrafficLogKeyGroup        = "group"
	TrafficLogKeyTraceID      = "tid"
	TrafficLogKeySpanID       = "sid"
	TrafficLogKeyParentSpanID = "pid"
	TrafficLogKeyOperation    = "op"
	TrafficLogKeyCaller       = "caller"
	TrafficLogKeyServerType   = "stype"
	TrafficLogKeyServerID     = "srvid"
	TrafficLogKeyServerName   = "sname"
)

func httpTrafficLogMiddleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// NOTE: log before handling business logic, too many useless logs, remove it
		// logTrafficForHttpServer(r.Context())
		next.ServeHTTP(w, r)
	})
}

func trafficKVFromContext(ctx context.Context) (kv map[string]interface{}) {
	kv = map[string]interface{}{}
{'fraction_non_alphanumeric': 0.1190909090909091, 'fraction_numerical': 0.0, 'mean_word_length': 4.118604651162791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5251682', 'n_tokens_mistral': 835, 'n_tokens_neox': 809, 'n_words': 129}