Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions contrib/lovoo/goka/carrier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016 Datadog, Inc.

package goka

import (
"github.com/lovoo/goka"

"github.com/DataDog/dd-trace-go/v2/datastreams"
"github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
)

// gokaHeadersCarrier adapts goka.Headers (map[string][]byte) to the text-map
// interfaces used by both APM trace propagation (tracer.Extract/Inject) and Data
// Streams Monitoring (datastreams.ExtractFromBase64Carrier/InjectToBase64Carrier).
// A single carrier serves both because the four interfaces share the same method
// shapes. The carrier shares the underlying map, so Set mutates the goka.Headers
// it wraps.
type gokaHeadersCarrier goka.Headers

var (
_ tracer.TextMapReader = gokaHeadersCarrier(nil)
_ tracer.TextMapWriter = gokaHeadersCarrier(nil)
_ datastreams.TextMapReader = gokaHeadersCarrier(nil)
_ datastreams.TextMapWriter = gokaHeadersCarrier(nil)
)

// ForeachKey implements tracer.TextMapReader and datastreams.TextMapReader.
func (c gokaHeadersCarrier) ForeachKey(handler func(key, val string) error) error {
for k, v := range c {
if err := handler(k, string(v)); err != nil {
return err
}
}
return nil
}

// Set implements tracer.TextMapWriter and datastreams.TextMapWriter.
func (c gokaHeadersCarrier) Set(key, val string) {
c[key] = []byte(val)
}

// ExtractSpanContext extracts the span context propagated in a goka message's
// headers, allowing callers to create manual child spans.
func ExtractSpanContext(headers goka.Headers) (*tracer.SpanContext, error) {
return tracer.Extract(gokaHeadersCarrier(headers))
}
44 changes: 44 additions & 0 deletions contrib/lovoo/goka/example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016 Datadog, Inc.

package goka_test

import (
"log"

gokatrace "github.com/DataDog/dd-trace-go/contrib/lovoo/goka/v2"

"github.com/lovoo/goka"
"github.com/lovoo/goka/codec"
)

func Example() {
tr := gokatrace.NewTracer(
gokatrace.WithService("orders-processor"),
gokatrace.WithDataStreams(),
)

// handle processes an input message. Because the callback is wrapped, it runs
// inside a "kafka.consume" span, and ctx.Emit continues the trace downstream.
handle := func(ctx goka.Context, msg any) {
ctx.Emit("orders-enriched", ctx.Key(), msg)
}

g := goka.DefineGroup(
"orders",
goka.Input("orders", new(codec.String), tr.WrapCallback(handle)),
goka.Output("orders-enriched", new(codec.String)),
)

p, err := goka.NewProcessor(
[]string{"localhost:9092"},
g,
goka.WithContextWrapper(tr.WrapContext),
)
if err != nil {
log.Fatal(err)
}
_ = p
}
103 changes: 103 additions & 0 deletions contrib/lovoo/goka/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
module github.com/DataDog/dd-trace-go/contrib/lovoo/goka/v2

go 1.25.0

require (
github.com/DataDog/dd-trace-go/v2 v2.11.0-dev
github.com/lovoo/goka v1.1.8
github.com/stretchr/testify v1.11.1
)

require (
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/opentelemetry-mapping-go/otlp/attributes v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/proto v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/trace v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/trace/log v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/trace/stats v0.79.0 // indirect
github.com/DataDog/datadog-agent/pkg/trace/traceutil v0.79.0 // indirect
github.com/DataDog/datadog-go/v5 v5.8.3 // indirect
github.com/DataDog/go-libddwaf/v5 v5.0.0 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20260217080614-b0f4edc38a6d // indirect
github.com/DataDog/go-sqllexer v0.2.1 // indirect
github.com/DataDog/go-tuf v1.1.1-0.5.2 // indirect
github.com/DataDog/sketches-go v1.4.8 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Shopify/sarama v1.37.2 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/ebitengine/purego v0.10.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/mock v1.7.0-rc.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.9.0 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.3 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/linkdata/deadlock v0.5.5 // indirect
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 // indirect
github.com/minio/simdjson-go v0.4.5 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/outcaste-io/ristretto v0.2.3 // indirect
github.com/petermattis/goid v0.0.0-20260226131333-17d1149c6ac6 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/puzpuzpuz/xsync/v4 v4.5.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.10.0 // indirect
github.com/shirou/gopsutil/v4 v4.26.3 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tinylib/msgp v1.6.3 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/trailofbits/go-mutexasserts v0.0.0-20250514102930-c1f3d2e37561 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/collector/component v1.56.0 // indirect
go.opentelemetry.io/collector/featuregate v1.56.0 // indirect
go.opentelemetry.io/collector/pdata v1.56.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.150.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/exp v0.0.0-20260209203927-2842357ff358 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/DataDog/dd-trace-go/v2 => ../../..
Loading