Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kakfa exporter - kafka key by TraceID #25909

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3c3b675
kafka exporter - using batchpersignal to SplitTraces by traceId
arik-dig Aug 13, 2023
3f0ccbb
Merge remote-tracking branch 'origin/main' into feat/kakfa-exporter-k…
arik-dig Aug 20, 2023
19b29d2
using traceutil TraceIDToHexOrEmptyString
arik-dig Aug 21, 2023
21421bc
add KeyData
arik-dig Aug 21, 2023
371ae71
init trace marshalers by KeyData
arik-dig Aug 21, 2023
9bd2428
verify default value for KeyData
arik-dig Aug 21, 2023
6d26b8b
using dedicated pdataTracesMarshalerByTraceId
arik-dig Aug 21, 2023
175b24b
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Aug 21, 2023
c1f045a
create newPdataTracesMarshalerByTraceId
arik-dig Aug 21, 2023
2f7c207
add comment about key_data = traceID
arik-dig Aug 21, 2023
3b9388e
using key_data of traceID
arik-dig Aug 21, 2023
ae8fefe
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Aug 22, 2023
9c7bb5a
add change log yaml file
arik-dig Aug 22, 2023
f577e95
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Aug 23, 2023
ca210ca
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Aug 27, 2023
e09138e
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 3, 2023
6568027
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 4, 2023
709bc5a
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 5, 2023
cb25535
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 6, 2023
2789405
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 7, 2023
dde0fa3
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 10, 2023
495de39
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 12, 2023
62c50c6
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 12, 2023
39c3467
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 13, 2023
4134f9d
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 13, 2023
8550caf
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Sep 14, 2023
e5c230e
Merge branch 'main' into feat/kakfa-exporter-key-by-traceid
arik-dig Oct 1, 2023
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
3 changes: 3 additions & 0 deletions exporter/kafkaexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/jaegertracing/jaeger v1.41.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.83.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal v0.83.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.83.0
github.com/stretchr/testify v1.8.4
github.com/xdg-go/scram v1.1.2
Expand Down Expand Up @@ -82,6 +83,8 @@ require (

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal => ../../pkg/batchpersignal

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger => ../../pkg/translator/jaeger

retract (
Expand Down
24 changes: 16 additions & 8 deletions exporter/kafkaexporter/pdata_marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal"
)

type pdataLogsMarshaler struct {
Expand Down Expand Up @@ -74,16 +76,22 @@ type pdataTracesMarshaler struct {
}

func (p pdataTracesMarshaler) Marshal(td ptrace.Traces, topic string) ([]*sarama.ProducerMessage, error) {
bts, err := p.marshaler.MarshalTraces(td)
if err != nil {
return nil, err
}
return []*sarama.ProducerMessage{
{
var messages []*sarama.ProducerMessage

for _, tracesById := range batchpersignal.SplitTraces(td) {
bts, err := p.marshaler.MarshalTraces(tracesById)
if err != nil {
return nil, err
}
var traceId = tracesById.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).TraceID()
key := []byte(traceId.String())
messages = append(messages, &sarama.ProducerMessage{
Topic: topic,
Value: sarama.ByteEncoder(bts),
},
}, nil
Key: sarama.ByteEncoder(key),
})
}
return messages, nil
}

func (p pdataTracesMarshaler) Encoding() string {
Expand Down