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

Add tracing mapping fields into kafka_franz #2836

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions docs/modules/components/pages/inputs/kafka_franz.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ input:
period: ""
check: ""
processors: [] # No default (optional)
extract_tracing_map: root = @ # No default (optional)
```

--
Expand Down Expand Up @@ -694,4 +695,21 @@ processors:
format: json_array
```

=== `extract_tracing_map`

EXPERIMENTAL: A xref:guides:bloblang/about.adoc[Bloblang mapping] that attempts to extract an object containing tracing propagation information, which will then be used as the root tracing span for the message. The specification of the extracted fields must match the format used by the service wide tracer.


*Type*: `string`

Requires version 3.45.0 or newer

```yml
# Examples

extract_tracing_map: root = @

extract_tracing_map: root = this.meta.span
```


18 changes: 18 additions & 0 deletions docs/modules/components/pages/inputs/ockam_kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ input:
period: ""
check: ""
processors: [] # No default (optional)
extract_tracing_map: root = @ # No default (optional)
seed_brokers: [] # No default (optional)
disable_content_encryption: false
enrollment_ticket: "" # No default (optional)
Expand Down Expand Up @@ -701,6 +702,23 @@ processors:
format: json_array
```

=== `kafka.extract_tracing_map`

EXPERIMENTAL: A xref:guides:bloblang/about.adoc[Bloblang mapping] that attempts to extract an object containing tracing propagation information, which will then be used as the root tracing span for the message. The specification of the extracted fields must match the format used by the service wide tracer.


*Type*: `string`

Requires version 3.45.0 or newer

```yml
# Examples

extract_tracing_map: root = @

extract_tracing_map: root = this.meta.span
```

=== `kafka.seed_brokers`

A list of broker addresses to connect to in order to establish connections. If an item of the list contains commas it will be expanded into multiple addresses.
Expand Down
18 changes: 18 additions & 0 deletions docs/modules/components/pages/outputs/kafka_franz.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ output:
client_certs: []
sasl: [] # No default (optional)
timestamp: ${! timestamp_unix() } # No default (optional)
inject_tracing_map: meta = @.merge(this) # No default (optional)
```

--
Expand Down Expand Up @@ -794,4 +795,21 @@ timestamp: ${! timestamp_unix() }
timestamp: ${! metadata("kafka_timestamp_unix") }
```

=== `inject_tracing_map`

EXPERIMENTAL: A xref:guides:bloblang/about.adoc[Bloblang mapping] used to inject an object containing tracing propagation information into outbound messages. The specification of the injected fields will match the format used by the service wide tracer.


*Type*: `string`

Requires version 3.45.0 or newer

```yml
# Examples

inject_tracing_map: meta = @.merge(this)

inject_tracing_map: root.meta.span = this
```


18 changes: 18 additions & 0 deletions docs/modules/components/pages/outputs/ockam_kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ output:
client_certs: []
sasl: [] # No default (optional)
timestamp: ${! timestamp_unix() } # No default (optional)
inject_tracing_map: meta = @.merge(this) # No default (optional)
seed_brokers: [] # No default (optional)
disable_content_encryption: false
enrollment_ticket: "" # No default (optional)
Expand Down Expand Up @@ -813,6 +814,23 @@ timestamp: ${! timestamp_unix() }
timestamp: ${! metadata("kafka_timestamp_unix") }
```

=== `kafka.inject_tracing_map`

EXPERIMENTAL: A xref:guides:bloblang/about.adoc[Bloblang mapping] used to inject an object containing tracing propagation information into outbound messages. The specification of the injected fields will match the format used by the service wide tracer.


*Type*: `string`

Requires version 3.45.0 or newer

```yml
# Examples

inject_tracing_map: meta = @.merge(this)

inject_tracing_map: root.meta.span = this
```

=== `kafka.seed_brokers`

A list of broker addresses to connect to in order to establish connections. If an item of the list contains commas it will be expanded into multiple addresses.
Expand Down
9 changes: 8 additions & 1 deletion internal/impl/kafka/input_kafka_franz.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Finally, it's also possible to specify an explicit offset to consume from by add
service.NewBatchPolicyField("batching").
Description("Allows you to configure a xref:configuration:batching.adoc[batching policy] that applies to individual topic partitions in order to batch messages together before flushing them for processing. Batching can be beneficial for performance as well as useful for windowed processing, and doing so this way preserves the ordering of topic partitions.").
Advanced(),
service.NewExtractTracingSpanMappingField(),
}
}

Expand All @@ -136,7 +137,13 @@ func init() {
if err != nil {
return nil, err
}
return service.AutoRetryNacksBatchedToggled(conf, rdr)

r, err := service.AutoRetryNacksBatchedToggled(conf, rdr)
if err != nil {
return nil, err
}

return conf.WrapBatchInputExtractTracingSpanMapping("kafka_franz", r)
})
if err != nil {
panic(err)
Expand Down
7 changes: 6 additions & 1 deletion internal/impl/kafka/output_kafka_franz.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func FranzKafkaOutputConfigFields() []*service.ConfigField {
Example(`${! metadata("kafka_timestamp_unix") }`).
Optional().
Advanced(),
service.NewInjectTracingSpanMappingField(),
}
}

Expand All @@ -141,7 +142,11 @@ func init() {
if batchPolicy, err = conf.FieldBatchPolicy("batching"); err != nil {
return
}
output, err = NewFranzKafkaWriterFromConfig(conf, mgr.Logger())
if output, err = NewFranzKafkaWriterFromConfig(conf, mgr.Logger()); err != nil {
return
}

output, err = conf.WrapBatchOutputExtractTracingSpanMapping("kafka_franz", output)
return
})
if err != nil {
Expand Down