Skip to content

Commit

Permalink
Set GenAi subtype for spans
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx committed Dec 3, 2024
1 parent 9daa1d2 commit 0075c49
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion enrichments/trace/internal/elastic/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/elastic/opentelemetry-lib/enrichments/trace/config"
"go.opentelemetry.io/collector/pdata/pcommon"
semconv "go.opentelemetry.io/collector/semconv/v1.25.0"
semconv "go.opentelemetry.io/collector/semconv/v1.26.0"
)

// EnrichResource derives and adds Elastic specific resource attributes.
Expand Down
2 changes: 1 addition & 1 deletion enrichments/trace/internal/elastic/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/pdata/pcommon"
semconv "go.opentelemetry.io/collector/semconv/v1.25.0"
semconv "go.opentelemetry.io/collector/semconv/v1.26.0"
)

func TestResourceEnrich(t *testing.T) {
Expand Down
8 changes: 7 additions & 1 deletion enrichments/trace/internal/elastic/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/elastic/opentelemetry-lib/enrichments/trace/config"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"
semconv "go.opentelemetry.io/collector/semconv/v1.25.0"
semconv "go.opentelemetry.io/collector/semconv/v1.26.0"
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
"google.golang.org/grpc/codes"
)
Expand Down Expand Up @@ -82,6 +82,7 @@ type spanEnrichmentContext struct {
isHTTP bool
isDB bool
messagingDestinationTemp bool
isGenAi bool
}

func (s *spanEnrichmentContext) Enrich(span ptrace.Span, cfg config.Config) {
Expand Down Expand Up @@ -171,6 +172,8 @@ func (s *spanEnrichmentContext) Enrich(span ptrace.Span, cfg config.Config) {
case semconv.AttributeDBSystem:
s.isDB = true
s.dbSystem = v.Str()
case semconv.AttributeGenAiSystem:
s.isGenAi = true
}
return true
})
Expand Down Expand Up @@ -361,6 +364,9 @@ func (s *spanEnrichmentContext) setSpanTypeSubtype(span ptrace.Span) {
case s.isHTTP:
spanType = "external"
spanSubtype = "http"
case s.isGenAi:
spanType = "external"
spanSubtype = "genai"
default:
switch span.Kind() {
case ptrace.SpanKindInternal:
Expand Down
2 changes: 1 addition & 1 deletion enrichments/trace/internal/elastic/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"
semconv "go.opentelemetry.io/collector/semconv/v1.25.0"
semconv "go.opentelemetry.io/collector/semconv/v1.26.0"
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
"google.golang.org/grpc/codes"
)
Expand Down

0 comments on commit 0075c49

Please sign in to comment.