fix: critical bugs from code review (data corruption, error contract, HTTP hardening) #5
@ -50,7 +50,7 @@ func setupOtelSDK(ctx context.Context, cfg config.Trace) (shutdown shutdownFunc,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
resource, err := makeServiceResource(ctx)
|
resource, err := makeServiceResource(ctx, cfg.Environment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return shutdown, fmt.Errorf("making service resource: %w", err)
|
return shutdown, fmt.Errorf("making service resource: %w", err)
|
||||||
}
|
}
|
||||||
@ -102,7 +102,10 @@ type TraceProviderParams struct {
|
|||||||
Type config.TraceClientType
|
Type config.TraceClientType
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeServiceResource(ctx context.Context) (*resource.Resource, error) {
|
func makeServiceResource(ctx context.Context, environment string) (*resource.Resource, error) {
|
||||||
|
if environment == "" {
|
||||||
|
environment = "development"
|
||||||
|
}
|
||||||
r, err := resource.New(
|
r, err := resource.New(
|
||||||
ctx,
|
ctx,
|
||||||
resource.WithDetectors(
|
resource.WithDetectors(
|
||||||
@ -113,7 +116,7 @@ func makeServiceResource(ctx context.Context) (*resource.Resource, error) {
|
|||||||
resource.WithHost(),
|
resource.WithHost(),
|
||||||
resource.WithAttributes(
|
resource.WithAttributes(
|
||||||
semconv.ServiceName("bigstats:kuriweb"),
|
semconv.ServiceName("bigstats:kuriweb"),
|
||||||
semconv.DeploymentEnvironment("production"),
|
semconv.DeploymentEnvironment(environment),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -33,6 +33,7 @@ type Trace struct {
|
|||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
APIHeader string `json:"api_header"`
|
APIHeader string `json:"api_header"`
|
||||||
Type TraceClientType `json:"type"`
|
Type TraceClientType `json:"type"`
|
||||||
|
Environment string `json:"environment"`
|
||||||
|
|
||||||
ShowMetrics bool `json:"show_metrics"`
|
ShowMetrics bool `json:"show_metrics"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -384,8 +384,12 @@ func courseAsCreateCourseParams(course sravni.Course) command.CreateCourse {
|
|||||||
startAt = *course.DateStart
|
startAt = *course.DateStart
|
||||||
}
|
}
|
||||||
if course.TimeStart != nil {
|
if course.TimeStart != nil {
|
||||||
startAtUnix := startAt.Unix() + course.TimeStart.Unix()
|
clock := *course.TimeStart
|
||||||
startAt = time.Unix(startAtUnix, 0)
|
startAt = time.Date(
|
||||||
|
startAt.Year(), startAt.Month(), startAt.Day(),
|
||||||
|
clock.Hour(), clock.Minute(), clock.Second(), clock.Nanosecond(),
|
||||||
|
startAt.Location(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var courseDuration time.Duration
|
var courseDuration time.Duration
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
paramsAttr = attribute.Key("params")
|
paramsAttr = attribute.Key("params")
|
||||||
|
|
||||||
webtracer = otel.Tracer("http")
|
webtracer = otel.Tracer("kuriweb.http")
|
||||||
)
|
)
|
||||||
|
|
||||||
type courseTemplServer struct {
|
type courseTemplServer struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user