mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
+6



![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)





Mario
GitHub
Javier Molina Reyes
Zach Leslie
Joe Elliott
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Ryan Perry
Kim Nylander
Suraj Nath
Alex Bikfalvi
Andrey Karpov
Jennifer Villa
Martin Disibio
Markus Toivonen
Daniel Strobusch
Carles Garcia
835e1fd250
* Block-builder PoC * Add unit test for block-builder (#4289) * Add unit test for block-builder * fmt * Update tests * cmon * Deterministically build blocks for partition sections (#4327) * Pull main (#4342) * chore: remove gofakeit dependency (#4274) * Further reduce Labes() calls in the metrics registry (#4283) * Respect passed headers in read path requests (#4287) * Ingester: Validate completed blocks (#4256) * Add validate method to block Signed-off-by: Joe Elliott <[email protected]> * Add Validate usage in the ingester Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * add test and fix replay Signed-off-by: Joe Elliott <[email protected]> * increment metric Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * Add `invalid_utf8` to reasons spans could be rejected (#4293) * Add `invalid_utf8` to reasons spans could be rejected * Update changelog * Update docs * Ensure test covers invalid UTF-8 and not slack time * add signals for duplicate rf1 data (#4296) Signed-off-by: Joe Elliott <[email protected]> * Bump anchore/sbom-action from 0.17.5 to 0.17.7 (#4307) Bumps [anchore/sbom-action](https://github.com/anchore/sbom-action) from 0.17.5 to 0.17.7. - [Release notes](https://github.com/anchore/sbom-action/releases) - [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md) - [Commits](https://github.com/anchore/sbom-action/compare/v0.17.5...v0.17.7) --- updated-dependencies: - dependency-name: anchore/sbom-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Update readme with explore traces info (#4263) * docs: Update readme with explore traces info Co-authored-by: Kim Nylander <[email protected]> * chore: remove spanlogger (#4312) * chore: remove spanlogger * Query-Frontend: Add middleware to drop headers (#4298) * header strip ware Signed-off-by: Joe Elliott <[email protected]> * comment Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * remove header strip wear from metrics summary Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * Increase length of time compactions have to fail (#4315) * increase length of time compactions have to fail Signed-off-by: Joe Elliott <[email protected]> * gen Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * docs: mark serverless as deprecated (#4017) * docs: mark serverless as deprecated * Changelog + readme * docs: Remove duplicated examples (#4295) This removes duplicates examples from the Configure TraceQL metrics page. Signed-off-by: Alex Bikfalvi <[email protected]> * tempo-cli: support dropping multiple traces in a single operation (#4266) * tempo-cli: support dropping multiple traces in a single operation * update final log message --------- Co-authored-by: Suraj Nath <[email protected]> * [DOC] Add clarification for metrics summary and traceQL metrics (#4316) * Add clarification for metrics summary and traceQL metrics * Apply suggestions from code review Co-authored-by: Jennifer Villa <[email protected]> * Update docs/sources/tempo/api_docs/metrics-summary.md --------- Co-authored-by: Jennifer Villa <[email protected]> * TraceQL metrics time range fixes (#4325) * Disconnect job time range filtering from step, so that results in split backend/recent range is accurate * changelog * Fix to assert metrics query range before alignment because alignment may increase it, which is not the responsibility of the caller to account for (#4331) * Add doc about configuring TLS with Helm (#4328) * Add doc about configuring TLS with Helm * Add memberlist and readinessProbe to example * Include server config for listening on TLS * Add note about scraping * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Markus Toivonen <[email protected]> * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Kim Nylander <[email protected]> * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Kim Nylander <[email protected]> * Add memcached config for TLS --------- Co-authored-by: Markus Toivonen <[email protected]> Co-authored-by: Kim Nylander <[email protected]> * [DOC] Add TLS info to Helm chart doc (#4334) --------- Signed-off-by: Joe Elliott <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Alex Bikfalvi <[email protected]> Co-authored-by: Javier Molina Reyes <[email protected]> Co-authored-by: Zach Leslie <[email protected]> Co-authored-by: Joe Elliott <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ryan Perry <[email protected]> Co-authored-by: Kim Nylander <[email protected]> Co-authored-by: Suraj Nath <[email protected]> Co-authored-by: Alex Bikfalvi <[email protected]> Co-authored-by: Andrey Karpov <[email protected]> Co-authored-by: Jennifer Villa <[email protected]> Co-authored-by: Martin Disibio <[email protected]> Co-authored-by: Markus Toivonen <[email protected]> * WIP: Rhythm ingest path (#4314) * Validate distributor config. Finish encoder/decoder tests * Repair tests * Make SingleBinary work out of the box by defaulting to partition 0 * Fix first time startup where blockbuilder fails before ingester can create topic * Fix initial startup cycle time and delay * Add more failure modes to the block-builder (#4345) * Add more tests to the block-builder * stuff * Add comments * [Rhythm] Metrics generator read from kafka first pass (#4359) * Metrics generator read from kafka first pass * review feedback * Multiple fixes in block-builder (#4364) * [rhythm] git merge origin/main (#4376) * chore: remove gofakeit dependency (#4274) * Further reduce Labes() calls in the metrics registry (#4283) * Respect passed headers in read path requests (#4287) * Ingester: Validate completed blocks (#4256) * Add validate method to block Signed-off-by: Joe Elliott <[email protected]> * Add Validate usage in the ingester Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * add test and fix replay Signed-off-by: Joe Elliott <[email protected]> * increment metric Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * Add `invalid_utf8` to reasons spans could be rejected (#4293) * Add `invalid_utf8` to reasons spans could be rejected * Update changelog * Update docs * Ensure test covers invalid UTF-8 and not slack time * add signals for duplicate rf1 data (#4296) Signed-off-by: Joe Elliott <[email protected]> * Bump anchore/sbom-action from 0.17.5 to 0.17.7 (#4307) Bumps [anchore/sbom-action](https://github.com/anchore/sbom-action) from 0.17.5 to 0.17.7. - [Release notes](https://github.com/anchore/sbom-action/releases) - [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md) - [Commits](https://github.com/anchore/sbom-action/compare/v0.17.5...v0.17.7) --- updated-dependencies: - dependency-name: anchore/sbom-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Update readme with explore traces info (#4263) * docs: Update readme with explore traces info Co-authored-by: Kim Nylander <[email protected]> * chore: remove spanlogger (#4312) * chore: remove spanlogger * Query-Frontend: Add middleware to drop headers (#4298) * header strip ware Signed-off-by: Joe Elliott <[email protected]> * comment Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * remove header strip wear from metrics summary Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * Increase length of time compactions have to fail (#4315) * increase length of time compactions have to fail Signed-off-by: Joe Elliott <[email protected]> * gen Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * docs: mark serverless as deprecated (#4017) * docs: mark serverless as deprecated * Changelog + readme * docs: Remove duplicated examples (#4295) This removes duplicates examples from the Configure TraceQL metrics page. Signed-off-by: Alex Bikfalvi <[email protected]> * tempo-cli: support dropping multiple traces in a single operation (#4266) * tempo-cli: support dropping multiple traces in a single operation * update final log message --------- Co-authored-by: Suraj Nath <[email protected]> * [DOC] Add clarification for metrics summary and traceQL metrics (#4316) * Add clarification for metrics summary and traceQL metrics * Apply suggestions from code review Co-authored-by: Jennifer Villa <[email protected]> * Update docs/sources/tempo/api_docs/metrics-summary.md --------- Co-authored-by: Jennifer Villa <[email protected]> * TraceQL metrics time range fixes (#4325) * Disconnect job time range filtering from step, so that results in split backend/recent range is accurate * changelog * Fix to assert metrics query range before alignment because alignment may increase it, which is not the responsibility of the caller to account for (#4331) * Add doc about configuring TLS with Helm (#4328) * Add doc about configuring TLS with Helm * Add memberlist and readinessProbe to example * Include server config for listening on TLS * Add note about scraping * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Markus Toivonen <[email protected]> * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Kim Nylander <[email protected]> * Update docs/sources/tempo/configuration/network/tls.md Co-authored-by: Kim Nylander <[email protected]> * Add memcached config for TLS --------- Co-authored-by: Markus Toivonen <[email protected]> Co-authored-by: Kim Nylander <[email protected]> * [DOC] Add TLS info to Helm chart doc (#4334) * fix deprecation warning by switching to DoBatchWithOptions (#4343) Signed-off-by: Daniel Strobusch <[email protected]> * bump dskit to v0.0.0-20241115082728-f2a7eb3aa0e9 to leverage benefits for context causes for DoBatch calls. (#4341) See https://github.com/grafana/dskit/issues/576 Signed-off-by: Daniel Strobusch <[email protected]> * Bump github.com/minio/minio-go/v7 from 7.0.70 to 7.0.80 (#4282) * Bump github.com/minio/minio-go/v7 from 7.0.70 to 7.0.80 Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.70 to 7.0.80. - [Release notes](https://github.com/minio/minio-go/releases) - [Commits](https://github.com/minio/minio-go/compare/v7.0.70...v7.0.80) --- updated-dependencies: - dependency-name: github.com/minio/minio-go/v7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Update serverless vendor --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zach Leslie <[email protected]> * update default config values to better align with production workloads (#4340) * update default config values to better align with production workloads * Update CHANGELOG.md and config docs * Ingester memory improvements by adjusting prealloc (#4344) * remove trace ids Signed-off-by: Joe Elliott <[email protected]> * linear buckets Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * tuney tune Signed-off-by: Joe Elliott <[email protected]> * metric misses and increase pool size Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> * Bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.13.0 to 1.16.0 (#4302) * Bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.13.0 to 1.16.0 Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.13.0 to 1.16.0. - [Release notes](https://github.com/Azure/azure-sdk-for-go/releases) - [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md) - [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.13.0...sdk/azcore/v1.16.0) --- updated-dependencies: - dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update serverless vendor --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zach Leslie <[email protected]> * Use Prometheus fast regexp (#4329) * basic integration Signed-off-by: Joe Elliott <[email protected]> * patch tests for new meaning Signed-off-by: Joe Elliott <[email protected]> * patch up more tests Signed-off-by: Joe Elliott <[email protected]> * add basic tests Signed-off-by: Joe Elliott <[email protected]> * changelog + docs Signed-off-by: Joe Elliott <[email protected]> * remove benches Signed-off-by: Joe Elliott <[email protected]> * Cleaned up + tests Signed-off-by: Joe Elliott <[email protected]> * comment Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> * Update docs/sources/tempo/traceql/_index.md Co-authored-by: Kim Nylander <[email protected]> * comment Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> Co-authored-by: Kim Nylander <[email protected]> * Fix broken link in service-graphs docs (#4351) * Fix minor typo in TraceQL docs (#4356) * Bump default memcached version (#4363) * Exemplar fixes (#4366) * Fix exemplars based on duration to convert to seconds, fix various other issues * changelog * fix: initialize histogram buckets to 0 to avoid them being downsampled (#4368) * initialized histogram buckets to 0 to avoid them being downsampled * Ingester/Generator Live trace cleanup (#4365) * moved trace sizes somewhere shareable Signed-off-by: Joe Elliott <[email protected]> * use tracesizes in ingester Signed-off-by: Joe Elliott <[email protected]> * make tests work Signed-off-by: Joe Elliott <[email protected]> * trace bytes in generator Signed-off-by: Joe Elliott <[email protected]> * remove traceCount Signed-off-by: Joe Elliott <[email protected]> * live trace shenanigans Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * Update modules/generator/processor/localblocks/livetraces.go Co-authored-by: Mario <[email protected]> * Update modules/ingester/instance.go Co-authored-by: Mario <[email protected]> * Test cleanup. Add sz test, restore commented out and fix e2e Signed-off-by: Joe Elliott <[email protected]> * remove todo comment Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]> Co-authored-by: Mario <[email protected]> * Bump anchore/sbom-action from 0.17.7 to 0.17.8 (#4371) Bumps [anchore/sbom-action](https://github.com/anchore/sbom-action) from 0.17.7 to 0.17.8. - [Release notes](https://github.com/anchore/sbom-action/releases) - [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md) - [Commits](https://github.com/anchore/sbom-action/compare/v0.17.7...v0.17.8) --- updated-dependencies: - dependency-name: anchore/sbom-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update for IDs change * Only run blockbuilder if ingest enabled --------- Signed-off-by: Joe Elliott <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Alex Bikfalvi <[email protected]> Signed-off-by: Daniel Strobusch <[email protected]> Co-authored-by: Javier Molina Reyes <[email protected]> Co-authored-by: Zach Leslie <[email protected]> Co-authored-by: Joe Elliott <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ryan Perry <[email protected]> Co-authored-by: Kim Nylander <[email protected]> Co-authored-by: Suraj Nath <[email protected]> Co-authored-by: Alex Bikfalvi <[email protected]> Co-authored-by: Andrey Karpov <[email protected]> Co-authored-by: Jennifer Villa <[email protected]> Co-authored-by: Martin Disibio <[email protected]> Co-authored-by: Markus Toivonen <[email protected]> Co-authored-by: Daniel Strobusch <[email protected]> Co-authored-by: Carles Garcia <[email protected]> * [rhythm] Changes to simplify operations (#4389) * Use mapping for assigning partitions * Use mapping for assigning partitions in the generator too * Add support for SASL auth to kafka clients * Add metrics to ingest (#4395) * [rhythm] Extract block-builder into its own module (#4396) * Extract block-builder into its own module * Update /operations and examples * No ephemeral storage * No rolling strategy either * fmt and compile * Address review comment * [rhythm] Correctly pass start/end time when appending a trace (#4410) * Correctly pass start/end times * Different code, same result * [rhythm] Multiple fixes to block-builder consumption (#4413) * Multiple fixes to cycle consumption * fmt * happy now? * ups * Rhythm: Separate non-flushing local blocks processor to store new queue data for reads (#4411) * wip: separate non-flushing local blocks processor to store new queue data for reads * Make real config for non-flushing local blocks processor, optional, validate wal config and use defaults if needed * Fix defaulting of second WAL config * [rhythm] Make ID generator more robust (#4416) * Make ID generator more robust * Simplify * Update toc3ff5ba61* Fix registering of kafka read client metrics (#4502) * [rhythm] Make ID generator more robust (#4416) (#4507) * Make ID generator more robust * Simplify * Removed references to Loki and Mimir (#4509) Signed-off-by: Joe Elliott <[email protected]> * [Rhythm] Block builder test updates (#4510) * Make blockbuilder tests closer to real kafka and less implementation specific by always enabling support for consumer groups, call commit control func in order * Verify last committed offset in each test * hide test function * lint * lint * [Rhythm] Block-builder consumption loop (#4480) * Alternate block-builder consume * Set timeout on PollFetches, reduce initial poll delay, update 1 test to work using real consumergroup functionality * restore metrics * Re-add original partition lag metric, polled in separate goroutine. Fix consume loop to only consume full-duration cycles for more determinism * merge conflict * Review feedback * Review feedback * Comment * code cleanup, lint * logs * code cleanup * lint * Review feedback * Remove missed lookback_on_no_commit config in e2e tests and regen manifest * Review feedback * Fix rewind to latest commit to init correctly, it didn't work in some clusters (#4532) * [rhythm] merge main at2c44177(#4531) * Fixes * More fixes --------- Signed-off-by: Joe Elliott <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Alex Bikfalvi <[email protected]> Signed-off-by: Daniel Strobusch <[email protected]> Co-authored-by: Javier Molina Reyes <[email protected]> Co-authored-by: Zach Leslie <[email protected]> Co-authored-by: Joe Elliott <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ryan Perry <[email protected]> Co-authored-by: Kim Nylander <[email protected]> Co-authored-by: Suraj Nath <[email protected]> Co-authored-by: Alex Bikfalvi <[email protected]> Co-authored-by: Andrey Karpov <[email protected]> Co-authored-by: Jennifer Villa <[email protected]> Co-authored-by: Martin Disibio <[email protected]> Co-authored-by: Markus Toivonen <[email protected]> Co-authored-by: Daniel Strobusch <[email protected]> Co-authored-by: Carles Garcia <[email protected]>
376 lines
9.6 KiB
Go
376 lines
9.6 KiB
Go
package kotel
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"math"
|
|
"net"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/twmb/franz-go/pkg/kgo"
|
|
"go.opentelemetry.io/otel"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/metric"
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
|
|
)
|
|
|
|
var ( // interface checks to ensure we implement the hooks properly
|
|
_ kgo.HookBrokerConnect = new(Meter)
|
|
_ kgo.HookBrokerDisconnect = new(Meter)
|
|
_ kgo.HookBrokerWrite = new(Meter)
|
|
_ kgo.HookBrokerRead = new(Meter)
|
|
_ kgo.HookProduceBatchWritten = new(Meter)
|
|
_ kgo.HookFetchBatchRead = new(Meter)
|
|
)
|
|
|
|
const (
|
|
dimensionless = "1"
|
|
bytes = "by"
|
|
)
|
|
|
|
type Meter struct {
|
|
provider metric.MeterProvider
|
|
meter metric.Meter
|
|
instruments instruments
|
|
|
|
mergeConnectsMeter bool
|
|
}
|
|
|
|
// MeterOpt interface used for setting optional config properties.
|
|
type MeterOpt interface {
|
|
apply(*Meter)
|
|
}
|
|
|
|
type meterOptFunc func(*Meter)
|
|
|
|
// MeterProvider takes a metric.MeterProvider and applies it to the Meter
|
|
// If none is specified, the global provider is used.
|
|
func MeterProvider(provider metric.MeterProvider) MeterOpt {
|
|
return meterOptFunc(func(m *Meter) {
|
|
if provider != nil {
|
|
m.provider = provider
|
|
}
|
|
})
|
|
}
|
|
|
|
// WithMergedConnectsMeter merges the `messaging.kafka.connect_errors.count`
|
|
// counter into the `messaging.kafka.connects.count` counter, adding an
|
|
// attribute "outcome" with the values "success" or "failure". This option
|
|
// shall be used when a single metric with different dimensions is preferred
|
|
// over two separate metrics that produce data at alternating intervals.
|
|
// For example, it becomes possible to alert on the metric no longer
|
|
// producing data.
|
|
func WithMergedConnectsMeter() MeterOpt {
|
|
return meterOptFunc(func(m *Meter) {
|
|
m.mergeConnectsMeter = true
|
|
})
|
|
|
|
}
|
|
|
|
func (o meterOptFunc) apply(m *Meter) {
|
|
o(m)
|
|
}
|
|
|
|
// NewMeter returns a Meter, used as option for kotel to instrument franz-go
|
|
// with instruments.
|
|
func NewMeter(opts ...MeterOpt) *Meter {
|
|
m := &Meter{}
|
|
for _, opt := range opts {
|
|
opt.apply(m)
|
|
}
|
|
if m.provider == nil {
|
|
m.provider = otel.GetMeterProvider()
|
|
}
|
|
m.meter = m.provider.Meter(
|
|
instrumentationName,
|
|
metric.WithInstrumentationVersion(semVersion()),
|
|
metric.WithSchemaURL(semconv.SchemaURL),
|
|
)
|
|
m.instruments = m.newInstruments()
|
|
return m
|
|
}
|
|
|
|
// instruments ---------------------------------------------------------------
|
|
|
|
type instruments struct {
|
|
connects metric.Int64Counter
|
|
connectErrs metric.Int64Counter
|
|
disconnects metric.Int64Counter
|
|
|
|
writeErrs metric.Int64Counter
|
|
writeBytes metric.Int64Counter
|
|
|
|
readErrs metric.Int64Counter
|
|
readBytes metric.Int64Counter
|
|
|
|
produceBytes metric.Int64Counter
|
|
produceRecords metric.Int64Counter
|
|
fetchBytes metric.Int64Counter
|
|
fetchRecords metric.Int64Counter
|
|
}
|
|
|
|
func (m *Meter) newInstruments() instruments {
|
|
// connects and disconnects
|
|
connects, err := m.meter.Int64Counter(
|
|
"messaging.kafka.connects.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of connections opened, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create connects instrument, %v", err)
|
|
}
|
|
|
|
var connectErrs metric.Int64Counter
|
|
if !m.mergeConnectsMeter {
|
|
var err error
|
|
connectErrs, err = m.meter.Int64Counter(
|
|
"messaging.kafka.connect_errors.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of connection errors, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create connectErrs instrument, %v", err)
|
|
}
|
|
}
|
|
|
|
disconnects, err := m.meter.Int64Counter(
|
|
"messaging.kafka.disconnects.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of connections closed, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create disconnects instrument, %v", err)
|
|
}
|
|
|
|
// write
|
|
|
|
writeErrs, err := m.meter.Int64Counter(
|
|
"messaging.kafka.write_errors.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of write errors, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create writeErrs instrument, %v", err)
|
|
}
|
|
|
|
writeBytes, err := m.meter.Int64Counter(
|
|
"messaging.kafka.write_bytes",
|
|
metric.WithUnit(bytes),
|
|
metric.WithDescription("Total number of bytes written, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create writeBytes instrument, %v", err)
|
|
}
|
|
|
|
// read
|
|
|
|
readErrs, err := m.meter.Int64Counter(
|
|
"messaging.kafka.read_errors.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of read errors, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create readErrs instrument, %v", err)
|
|
}
|
|
|
|
readBytes, err := m.meter.Int64Counter(
|
|
"messaging.kafka.read_bytes.count",
|
|
metric.WithUnit(bytes),
|
|
metric.WithDescription("Total number of bytes read, by broker"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create readBytes instrument, %v", err)
|
|
}
|
|
|
|
// produce & consume
|
|
|
|
produceBytes, err := m.meter.Int64Counter(
|
|
"messaging.kafka.produce_bytes.count",
|
|
metric.WithUnit(bytes),
|
|
metric.WithDescription("Total number of uncompressed bytes produced, by broker and topic"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create produceBytes instrument, %v", err)
|
|
}
|
|
|
|
produceRecords, err := m.meter.Int64Counter(
|
|
"messaging.kafka.produce_records.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of produced records, by broker and topic"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create produceRecords instrument, %v", err)
|
|
}
|
|
|
|
fetchBytes, err := m.meter.Int64Counter(
|
|
"messaging.kafka.fetch_bytes.count",
|
|
metric.WithUnit(bytes),
|
|
metric.WithDescription("Total number of uncompressed bytes fetched, by broker and topic"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create fetchBytes instrument, %v", err)
|
|
}
|
|
|
|
fetchRecords, err := m.meter.Int64Counter(
|
|
"messaging.kafka.fetch_records.count",
|
|
metric.WithUnit(dimensionless),
|
|
metric.WithDescription("Total number of fetched records, by broker and topic"),
|
|
)
|
|
if err != nil {
|
|
log.Printf("failed to create fetchRecords instrument, %v", err)
|
|
}
|
|
|
|
return instruments{
|
|
connects: connects,
|
|
connectErrs: connectErrs,
|
|
disconnects: disconnects,
|
|
|
|
writeErrs: writeErrs,
|
|
writeBytes: writeBytes,
|
|
|
|
readErrs: readErrs,
|
|
readBytes: readBytes,
|
|
|
|
produceBytes: produceBytes,
|
|
produceRecords: produceRecords,
|
|
fetchBytes: fetchBytes,
|
|
fetchRecords: fetchRecords,
|
|
}
|
|
}
|
|
|
|
// Helpers -------------------------------------------------------------------
|
|
|
|
func strnode(node int32) string {
|
|
if node < 0 {
|
|
return "seed_" + strconv.Itoa(int(node)-math.MinInt32)
|
|
}
|
|
return strconv.Itoa(int(node))
|
|
}
|
|
|
|
// Hooks ---------------------------------------------------------------------
|
|
|
|
func (m *Meter) OnBrokerConnect(meta kgo.BrokerMetadata, _ time.Duration, _ net.Conn, err error) {
|
|
node := strnode(meta.NodeID)
|
|
|
|
if m.mergeConnectsMeter {
|
|
if err != nil {
|
|
m.instruments.connects.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attribute.NewSet(
|
|
attribute.String("node_id", node),
|
|
attribute.String("outcome", "failure"),
|
|
)),
|
|
)
|
|
return
|
|
}
|
|
m.instruments.connects.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attribute.NewSet(
|
|
attribute.String("node_id", node),
|
|
attribute.String("outcome", "success"),
|
|
)),
|
|
)
|
|
return
|
|
}
|
|
|
|
attributes := attribute.NewSet(attribute.String("node_id", node))
|
|
if err != nil {
|
|
m.instruments.connectErrs.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
return
|
|
}
|
|
m.instruments.connects.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|
|
|
|
func (m *Meter) OnBrokerDisconnect(meta kgo.BrokerMetadata, _ net.Conn) {
|
|
node := strnode(meta.NodeID)
|
|
attributes := attribute.NewSet(attribute.String("node_id", node))
|
|
m.instruments.disconnects.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|
|
|
|
func (m *Meter) OnBrokerWrite(meta kgo.BrokerMetadata, _ int16, bytesWritten int, _, _ time.Duration, err error) {
|
|
node := strnode(meta.NodeID)
|
|
attributes := attribute.NewSet(attribute.String("node_id", node))
|
|
if err != nil {
|
|
m.instruments.writeErrs.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
return
|
|
}
|
|
m.instruments.writeBytes.Add(
|
|
context.Background(),
|
|
int64(bytesWritten),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|
|
|
|
func (m *Meter) OnBrokerRead(meta kgo.BrokerMetadata, _ int16, bytesRead int, _, _ time.Duration, err error) {
|
|
node := strnode(meta.NodeID)
|
|
attributes := attribute.NewSet(attribute.String("node_id", node))
|
|
if err != nil {
|
|
m.instruments.readErrs.Add(
|
|
context.Background(),
|
|
1,
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
return
|
|
}
|
|
m.instruments.readBytes.Add(
|
|
context.Background(),
|
|
int64(bytesRead),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|
|
|
|
func (m *Meter) OnProduceBatchWritten(meta kgo.BrokerMetadata, topic string, _ int32, pbm kgo.ProduceBatchMetrics) {
|
|
node := strnode(meta.NodeID)
|
|
attributes := attribute.NewSet(
|
|
attribute.String("node_id", node),
|
|
attribute.String("topic", topic),
|
|
)
|
|
m.instruments.produceBytes.Add(
|
|
context.Background(),
|
|
int64(pbm.UncompressedBytes),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
m.instruments.produceRecords.Add(
|
|
context.Background(),
|
|
int64(pbm.NumRecords),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|
|
|
|
func (m *Meter) OnFetchBatchRead(meta kgo.BrokerMetadata, topic string, _ int32, fbm kgo.FetchBatchMetrics) {
|
|
node := strnode(meta.NodeID)
|
|
attributes := attribute.NewSet(
|
|
attribute.String("node_id", node),
|
|
attribute.String("topic", topic),
|
|
)
|
|
m.instruments.fetchBytes.Add(
|
|
context.Background(),
|
|
int64(fbm.UncompressedBytes),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
m.instruments.fetchRecords.Add(
|
|
context.Background(),
|
|
int64(fbm.NumRecords),
|
|
metric.WithAttributeSet(attributes),
|
|
)
|
|
}
|