This message was deleted.
s
This message was deleted.
h
I have used the same trace provider in both app and db.
Copy code
db, err = splunkgorm.Open(PostgresDriver, connString,
			splunksql.WithAttributes([]attribute.KeyValue{
				semconv.DBSystemCockroachdb,
				semconv.DBNameKey.String("test"),
			}),
			splunksql.WithTracerProvider(<passed from app>),
		)
Copy code
func getTraceProvider(svcName string, server string) (*sdkTrace.TracerProvider, error) {
	res, err := sdkResource.Merge(sdkResource.NewWithAttributes(
		semconv.SchemaURL,
		semconv.ServiceNameKey.String(svcName),
		semconv.ServiceNamespaceKey.String(server),
	), sdkResource.Default())
	if err != nil {
		panic(err)
	}

	provider := sdkTrace.NewTracerProvider(
		sdkTrace.WithResource(res),
	)
	otel.SetTracerProvider(provider)
	otel.SetTextMapPropagator(propagation.TraceContext{})
	return provider, nil
}

func configureOtlp(ctx context.Context, server, svcName string) (*sdkTrace.TracerProvider, func()) {
	provider, err := getTraceProvider(svcName, server)

	exp, err := otlptrace.New(
		context.Background(),
		otlptracegrpc.NewClient(
			otlptracegrpc.WithInsecure(),
			otlptracegrpc.WithEndpoint("localhost:4317"),
		),
	)
	if err != nil {
		panic(err)
	}

	bsp := sdkTrace.NewBatchSpanProcessor(exp)
	provider.RegisterSpanProcessor(bsp)

	return provider, func() {
		if err := provider.Shutdown(ctx); err != nil {
			panic(err)
		}
	}
}
p
@User do you have insights on this?
v
Are you passing active span details as part of context? @User We don’t have any sample grpc app but from my experience we should pass active span details in context. For example in this module it’s clearly written that we have to pass active span details to ctx variable: https://github.com/uptrace/opentelemetry-go-extra/tree/main/otelgorm
🙌 1
h
I just checked, we are using gorm v1 which does not support passing context, we will have to upgrade to gorm v2 to do this. Will try out with the update. Thanks!
👍 1
v
Also any specific reason why you went for splunk otel for gorm tracing rather than otelgorm?
h
We use https://v1.gorm.io/ hence I tried using splunk. Had instrumented with otelgorm as well but got the same results so thought this could be the issue.
👌 1