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