Skip to content

Commit 549c0d7

Browse files
fix(adk-go): capture message content by default in spans (#1619)
When the env var `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` is not set, we should capture message content by default. This was disabled by default in #1618. Also adds retry for intermittent errors with grpc connection to collector to avoid traces being lost Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
1 parent c7e0aea commit 549c0d7

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

go/adk/pkg/telemetry/attributes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func setSpanAttributes(ctx context.Context, attrs ...attribute.KeyValue) {
9696
}
9797

9898
func marshalSpanPayload(value any) string {
99-
if !strings.EqualFold(strings.TrimSpace(os.Getenv(captureMessageContentEnvVar)), "true") {
99+
if strings.EqualFold(strings.TrimSpace(os.Getenv(captureMessageContentEnvVar)), "false") {
100100
return "{}"
101101
}
102102
if value == nil {

go/adk/pkg/telemetry/tracing.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/url"
66
"os"
77
"strings"
8+
"time"
89

910
"go.opentelemetry.io/otel"
1011
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc"
@@ -95,7 +96,15 @@ func newGRPCTracerProvider(ctx context.Context, res *resource.Resource) (*sdktra
9596
traceEndpoint = strings.TrimSpace(os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT"))
9697
}
9798

98-
var opts []otlptracegrpc.Option
99+
opts := []otlptracegrpc.Option{
100+
// Retry on transient failures
101+
otlptracegrpc.WithRetry(otlptracegrpc.RetryConfig{
102+
Enabled: true,
103+
InitialInterval: 1 * time.Second,
104+
MaxInterval: 5 * time.Second,
105+
MaxElapsedTime: 30 * time.Second,
106+
}),
107+
}
99108
if traceEndpoint != "" {
100109
// If the endpoint has a valid scheme, host, port, path ("scheme://host:port/path"), set endpoint url.
101110
if u, err := url.Parse(traceEndpoint); err == nil && u.Scheme != "" && u.Host != "" {

0 commit comments

Comments
 (0)