Commit Graph

9 Commits

Author SHA1 Message Date
Vincent Bernat
6b27794dd2 common/kafka: fix logger for kfake 2025-11-17 21:54:45 +01:00
Vincent Bernat
a3507a3ff2 commong: move logging functions into */logs.go
The idea is that we should be able to skip it to find the true call
site. However, in some case, there is no true call site as we are in an
internal goroutine (like for Kafka). We can't do too complex things as
it would cost more CPU.

Here is the tentative. We should keep the last valid caller.

```go
// Run adds more context to an event, including "module" and "caller".
func (h contextHook) Run(e *zerolog.Event, _ zerolog.Level, _ string) {
	callStack := stack.Callers()
	callStack = callStack[3:] // Trial and error, there is a test to check it works.

	// We want to get the next caller that is in our own module but that is not logs.go.
	for _, call := range callStack {
		module := call.FunctionName()
		if !strings.HasPrefix(module, stack.ModuleName) || strings.HasSuffix(call.FileName(), "/logs.go") {
			continue
		}
		caller := callStack[0].SourceFile(true)
		e.Str("caller", caller)
		module = strings.SplitN(module, ".", 2)[0]
		e.Str("module", module)
		break
	}
}
```
2025-11-05 08:22:33 +01:00
Vincent Bernat
801f3f1676 common/kafka: also logs output of kfake cluster 2025-09-23 07:06:58 +02:00
Vincent Bernat
756e4a8fbd */kafka: switch to franz-go
The concurrency of this library is easier to handle than Sarama.
Notably, it is more compatible with the new model of "almost share
nothing" we use for the inlet and the outlet. The lock for workers in
outlet is removed. We can now use sync.Pool to allocate slice of bytes
in inlet.

It may also be more performant.

In the future, we may want to commit only when pushing data to
ClickHouse. However, this does not seem easy when there is a rebalance.
In case of rebalance, we need to do something when a partition is
revoked to avoid duplicating data. For example, we could flush the
current batch to ClickHouse. Have a look at the
`example/mark_offsets/main.go` file in franz-go repository for a
possible approach. In the meantime, we rely on autocommit.

Another contender could be https://github.com/segmentio/kafka-go. Also
see https://github.com/twmb/franz-go/pull/1064.
2025-07-27 21:44:28 +02:00
Vincent Bernat
d2ebd76a5d common/kafka: switch to github.com/IBM/sarama 2023-07-18 08:02:49 +02:00
Vincent Bernat
a912da7fa1 build: use gofumpt
Undecided if we need to use it. I think it's nice.
2023-02-11 10:03:45 +01:00
Vincent Bernat
18ee3eac6f build: switch to Go 1.19
This enables us to use atomic.Pointer!
2022-08-19 17:46:49 +02:00
Vincent Bernat
8be1bca4fd license: AGPL-3.0-only
```
git ls-files \*.js \*.go \
  | xargs sed -i '1i // SPDX-FileCopyrightText: 2022 Free Mobile\n// SPDX-License-Identifier: AGPL-3.0-only\n'
git ls-files \*.vue \
  | xargs sed -i '1i <!-- SPDX-FileCopyrightText: 2022 Free Mobile -->\n<!-- SPDX-License-Identifier: AGPL-3.0-only -->\n'
```
2022-06-29 11:42:28 +02:00
Vincent Bernat
1dc253764d global: split Akvorado into 3 services 2022-04-01 20:21:53 +02:00