fxrie
September 8, 2023, 9:56am
1
Hi,
at the moment I develop a TCP Excetions that is based on the Golang Tcp type where you can also close the read and write part extra and use own defined delimiter for read line.
My question is: Is there a way to trace the tcp infos to the default k6 integrated metrics?
This is my repo for it atm and it is working so far: GitHub - FxRie/xk6-tcp: A k6 extension for sending data to TCP port
Thanks for help in advance!
Hey @fxrie ,
welcome to the community forum
My question is: Is there a way to trace the tcp infos to the default k6 integrated metrics?
What do you mean by integrated metrics? If a Custom Metric works for you then you can set it by writing some similar code the browser extension.
func (m *NetworkManager) emitRequestMetrics(req *Request) {
state := m.vu.State()
tags := state.Tags.GetCurrentValues().Tags
if state.Options.SystemTags.Has(k6metrics.TagMethod) {
tags = tags.With("method", req.method)
}
if state.Options.SystemTags.Has(k6metrics.TagURL) {
tags = tags.With("url", req.URL())
}
k6metrics.PushIfNotDone(m.vu.Context(), state.Samples, k6metrics.ConnectedSamples{
Samples: []k6metrics.Sample{
{
TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserDataSent, Tags: tags},
Value: float64(req.Size().Total()),
Time: req.wallTime,
},
},
})
}
Let me know if it helps.