diff --git a/cmd/kuriweb/http.go b/cmd/kuriweb/http.go index 9182c38..7c8a53b 100644 --- a/cmd/kuriweb/http.go +++ b/cmd/kuriweb/http.go @@ -16,6 +16,7 @@ import ( "github.com/gorilla/mux" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" + semconv "go.opentelemetry.io/otel/semconv/v1.25.0" "go.opentelemetry.io/otel/trace" ) @@ -114,14 +115,7 @@ func (k attributeStringKey) Value(value string) attribute.KeyValue { } func middlewareTrace() mux.MiddlewareFunc { - methodAttr := attributeStringKey("http.request.method") reqidAttr := attributeStringKey("http.request_id") - routeAttr := attributeStringKey("http.route") - queryAttr := attributeStringKey("url.query") - pathAttr := attributeStringKey("http.path") - uaAttr := attributeStringKey("user_agent.original") - statusAttr := attribute.Key("http.response.status_code") - payloadAttr := attribute.Key("http.response_content_length") return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -134,12 +128,12 @@ func middlewareTrace() mux.MiddlewareFunc { ctx, span = webtracer.Start( ctx, r.Method+" "+hpath, trace.WithAttributes( - methodAttr.Value(r.Method), reqidAttr.Value(reqid), - routeAttr.Value(hpath), - pathAttr.Value(r.URL.Path), - queryAttr.Value(r.URL.RawQuery), - uaAttr.Value(r.UserAgent()), + semconv.HTTPRequestMethodOriginal(r.Method), + semconv.URLFull(hpath), + semconv.URLPath(r.URL.Path), + semconv.URLQuery(r.URL.RawQuery), + semconv.UserAgentOriginal(r.UserAgent()), ), trace.WithSpanKind(trace.SpanKindServer), ) @@ -150,8 +144,8 @@ func middlewareTrace() mux.MiddlewareFunc { if wr, ok := w.(*customResponseWriter); ok { statusCode := xdefault.WithFallback(wr.statusCode, http.StatusOK) span.SetAttributes( - statusAttr.Int(statusCode), - payloadAttr.Int(wr.wroteBytes), + semconv.HTTPResponseStatusCode(statusCode), + semconv.HTTPResponseBodySize(wr.wroteBytes), ) if statusCode > 399 { span.SetStatus(codes.Error, "error during request") diff --git a/cmd/kuriweb/trace.go b/cmd/kuriweb/trace.go index 62478ce..3c43a69 100644 --- a/cmd/kuriweb/trace.go +++ b/cmd/kuriweb/trace.go @@ -93,6 +93,10 @@ func newCommonTraceProvider(ctx context.Context, params TraceProviderParams) (tp return "bigstats:kuriweb", nil }), ), + resource.WithAttributes( + semconv.ServiceName("bigstats:kuriweb"), + semconv.DeploymentEnvironment("production"), + ), ) if err != nil { return nil, fmt.Errorf("making new resource: %w", err) @@ -124,14 +128,19 @@ func newCommonTraceProvider(ctx context.Context, params TraceProviderParams) (tp spanExporter, err = otlptracegrpc.New( ctx, otlptracegrpc.WithEndpointURL(params.Endpoint), + otlptracegrpc.WithInsecure(), otlptracegrpc.WithHeaders(headers), + otlptracegrpc.WithCompressor("gzip"), ) case config.TraceClientTypeHTTP: httpClient := otlptracehttp.NewClient( otlptracehttp.WithEndpointURL(params.Endpoint), otlptracehttp.WithHeaders(headers), + otlptracehttp.WithCompression(otlptracehttp.GzipCompression), + ) + spanExporter, err = otlptrace.New( + ctx, httpClient, ) - spanExporter, err = otlptrace.New(ctx, httpClient) case config.TraceClientTypeStdout: spanExporter, err = stdouttrace.New(stdouttrace.WithPrettyPrint()) default: diff --git a/internal/kurious/ports/http/bootstrap/common_templ.go b/internal/kurious/ports/http/bootstrap/common_templ.go index 556004b..bf9dd21 100644 --- a/internal/kurious/ports/http/bootstrap/common_templ.go +++ b/internal/kurious/ports/http/bootstrap/common_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.513 +// templ: version: v0.2.707 package bootstrap //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -38,7 +38,7 @@ func button(title string, attributes templ.Attributes) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/common.templ`, Line: 3, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/common.templ`, Line: 4, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -72,7 +72,12 @@ func buttonRedirect(id, title string, linkTo string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString("origin-link-" + id)) + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs("origin-link-" + id) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/common.templ`, Line: 10, Col: 26} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -80,12 +85,12 @@ func buttonRedirect(id, title string, linkTo string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(title) + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/common.templ`, Line: 11, Col: 9} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/common.templ`, Line: 12, Col: 9} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -109,7 +114,8 @@ func onclickRedirect(id, to string) templ.ComponentScript { Name: `__templ_onclickRedirect_5c43`, Function: `function __templ_onclickRedirect_5c43(id, to){document.getElementById(id).onclick = () => { location.href = to - }}`, + } +}`, Call: templ.SafeScript(`__templ_onclickRedirect_5c43`, id, to), CallInline: templ.SafeScriptInline(`__templ_onclickRedirect_5c43`, id, to), } diff --git a/internal/kurious/ports/http/bootstrap/core_templ.go b/internal/kurious/ports/http/bootstrap/core_templ.go index c6dbcaf..1a2aa6b 100644 --- a/internal/kurious/ports/http/bootstrap/core_templ.go +++ b/internal/kurious/ports/http/bootstrap/core_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.513 +// templ: version: v0.2.707 package bootstrap //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -30,23 +30,13 @@ func head(title string) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/core.templ`, Line: 4, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/core.templ`, Line: 5, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -65,25 +55,38 @@ func headerNavbar(page PageKind) templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var4 := templ.GetChildren(ctx) - if templ_7745c5c3_Var4 == nil { - templ_7745c5c3_Var4 = templ.NopComponent + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -176,156 +145,12 @@ func footer() templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var12 := templ.GetChildren(ctx) - if templ_7745c5c3_Var12 == nil { - templ_7745c5c3_Var12 = templ.NopComponent + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -434,7 +259,8 @@ func elementScriptsLoad() templ.ComponentScript { const ob = document.getElementById('sortBySelect'); if (ob) ob.onchange = filterBySchool; - });}`, + }); +}`, Call: templ.SafeScript(`__templ_elementScriptsLoad_bfb1`), CallInline: templ.SafeScriptInline(`__templ_elementScriptsLoad_bfb1`), } @@ -448,9 +274,9 @@ func root(page PageKind, _ stats) templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var29 := templ.GetChildren(ctx) - if templ_7745c5c3_Var29 == nil { - templ_7745c5c3_Var29 = templ.NopComponent + templ_7745c5c3_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") @@ -473,7 +299,7 @@ func root(page PageKind, _ stats) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var29.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var11.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/kurious/ports/http/bootstrap/list_course_thematics_templ.go b/internal/kurious/ports/http/bootstrap/list_course_thematics_templ.go index 2cfb6e5..0da14b1 100644 --- a/internal/kurious/ports/http/bootstrap/list_course_thematics_templ.go +++ b/internal/kurious/ports/http/bootstrap/list_course_thematics_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.513 +// templ: version: v0.2.707 package bootstrap //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -23,39 +23,20 @@ func listCoursesByCourseThematic(params ListCoursesParams) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Здесь вы можете найти интересующие вас курсы по теме ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var2 := `Здесь вы можете найти интересующие вас курсы` - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2) + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(params.FilterForm.ActiveLearningType.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/list_course_thematics.templ`, Line: 6, Col: 59} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var3 := `по теме ` - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(params.FilterForm.ActiveLearningType.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/list_course_thematics.templ`, Line: 5, Col: 59} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var5 := `:` - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(":

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -440,9 +439,9 @@ func selectOptionFromPairs(emptyName, activeID string, items []NameIDPair) templ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var19 := templ.GetChildren(ctx) - if templ_7745c5c3_Var19 == nil { - templ_7745c5c3_Var19 = templ.NopComponent + templ_7745c5c3_Var22 := templ.GetChildren(ctx) + if templ_7745c5c3_Var22 == nil { + templ_7745c5c3_Var22 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("