Skip to content

The only tool you need to know what is happening and how to fix it.

chore: cleanup + org id attr

ddux53426faebeb1
diff --git a/backend/app/controllers/otelcontrollers/otel.controller.go b/backend/app/controllers/otelcontrollers/otel.controller.go
index 59160a9f..30286d1e 100644
--- a/backend/app/controllers/otelcontrollers/otel.controller.go
+++ b/backend/app/controllers/otelcontrollers/otel.controller.go
@@ -3,7 +3,6 @@ package otelcontrollers
import (
"context"
"fmt"
- "log"
"net/http"
"github.com/gin-gonic/gin"
@@ -14,7 +13,6 @@ import (
"github.com/tracewayapp/traceway/backend/app/services"
"github.com/tracewayapp/traceway/backend/app/storage"
traceway "go.tracewayapp.com"
- "google.golang.org/protobuf/encoding/protojson"
)
type otelController struct{}
@@ -22,34 +20,28 @@ type otelController struct{}
var OtelController = otelController{}
func (o otelController) ExportTraces(c *gin.Context) {
- fmt.Println("A00")
projectId, err := middleware.GetProjectId(c)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("UseClientAuth middleware must be applied: %w", err))
return
}
- fmt.Println("A0")
if project, exists := c.Get(middleware.ProjectContextKey); exists {
if p, ok := project.(*models.Project); ok && p.OrganizationId != nil {
+ if attrs := traceway.GetAttributesFromContext(c); attrs != nil {
+ attrs.SetTag("organization_id", fmt.Sprintf("%d", *p.OrganizationId))
+ }
if !hooks.CanReport(*p.OrganizationId) {
c.AbortWithStatus(http.StatusTooManyRequests)
return
}
}
}
- fmt.Println("A1")
-
req, err := decodeTraceRequest(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
- fmt.Println("WTF??")
- if jsonBytes, err := protojson.Marshal(req); err == nil {
- log.Printf("[OTEL TRACES] Payload: %s", string(jsonBytes))
- }
-
endpoints, tasks, spans, exceptions, aiTraces, aiConversations := convertTraces(projectId, req)
if len(endpoints) > 0 {
@@ -124,6 +116,9 @@ func (o otelController) ExportMetrics(c *gin.Context) {
if project, exists := c.Get(middleware.ProjectContextKey); exists {
if p, ok := project.(*models.Project); ok && p.OrganizationId != nil {
+ if attrs := traceway.GetAttributesFromContext(c); attrs != nil {
+ attrs.SetTag("organization_id", fmt.Sprintf("%d", *p.OrganizationId))
+ }
if !hooks.CanReport(*p.OrganizationId) {
c.AbortWithStatus(http.StatusTooManyRequests)
return