Skip to content

Instantly share code, notes, and snippets.

@narqo
Created August 31, 2018 17:16
Show Gist options
  • Save narqo/52665c5d776fd53598a3c139e7d8da36 to your computer and use it in GitHub Desktop.
Save narqo/52665c5d776fd53598a3c139e7d8da36 to your computer and use it in GitHub Desktop.

Run delve in headless mode, logging rpc calls to the delve.out file

= ./go/bin/dlv core adjust_server core.250387 --headless --listen 178.162.216.107:40233 --api-version=2 --log --log-output rpc 2> delve.out

Get list of running goroutines:

= dlv connect 178.162.216.107:40233
goroutines
....

Grab raw JSON from delve's debug logging

= tail +12 delve.out | awk '{print $4}' | tail -c +24 | sed 's/\\\"/"/g' > adjust_server-delve.json

Get interesting fields

= jq -r '.Goroutines[] | .startLoc.file,.startLoc.line,.startLoc.function.name' adjust_server-delve.json | sed 'N;N;s/\n/:/g'
17 github.com/adjust/backend/core/attribution/adjust_multi_api.go:79:github.com/adjust/backend/core/attribution.(*AdjustMultiApi).combineApiResponseChannels
2 github.com/adjust/backend/core/cache/clearer.go:44:github.com/adjust/backend/core/cache.backgroundClear
2 github.com/adjust/backend/core/kafka/sarama_async_producer.go:104:github.com/adjust/backend/core/kafka.(*SaramaAsyncProducer).consumeResponses.func2
2 github.com/adjust/backend/core/kafka/sarama_async_producer.go:94:github.com/adjust/backend/core/kafka.(*SaramaAsyncProducer).consumeResponses.func1
311611 github.com/adjust/backend/core/metrics/buffer.go:145:github.com/adjust/backend/core/metrics.(*Buffer).AddM
184634 github.com/adjust/backend/core/metrics/buffer.go:165:github.com/adjust/backend/core/metrics.(*Buffer).CountS
2086 github.com/adjust/backend/core/metrics/buffer.go:185:github.com/adjust/backend/core/metrics.(*Buffer).CountM
1 github.com/adjust/backend/core/metrics/buffer.go:393:github.com/adjust/backend/core/metrics.(*Buffer).startOutChannelConsumer
1 github.com/adjust/backend/core/metrics/v2/reporter.go:179:github.com/adjust/backend/core/metrics/v2.(*GraphiteReporter).flushLoop.func1
1 github.com/adjust/backend/core/metrics/v2/reporter.go:187:github.com/adjust/backend/core/metrics/v2.(*GraphiteReporter).flushLoop
1 github.com/adjust/backend/core/metrics/v2/reporter.go:242:github.com/adjust/backend/core/metrics/v2.(*GraphiteReporter).statusLoop
2 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:233:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*asyncProducer).dispatcher
2 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:304:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*topicProducer).dispatch
20 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:412:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*partitionProducer).dispatch
6 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:542:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*asyncProducer).newBrokerProducer.func1
6 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:588:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*brokerProducer).run
2 github.com/adjust/backend/vendor/github.com/Shopify/sarama/async_producer.go:786:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*asyncProducer).retryHandler
14 github.com/adjust/backend/vendor/github.com/Shopify/sarama/broker.go:473:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*Broker).responseReceiver
4 github.com/adjust/backend/vendor/github.com/Shopify/sarama/client.go:563:github.com/adjust/backend/vendor/github.com/Shopify/sarama.(*client).backgroundMetadataUpdater
2 github.com/adjust/backend/vendor/github.com/aerospike/aerospike-client-go/cluster.go:177:github.com/adjust/backend/vendor/github.com/aerospike/aerospike-client-go.(*Cluster).clusterBoss
2 github.com/adjust/backend/vendor/github.com/bsm/sarama-cluster/consumer.go:383:github.com/adjust/backend/vendor/github.com/bsm/sarama-cluster.(*Consumer).rebalanceError
1 github.com/adjust/backend/vendor/github.com/rcrowley/go-metrics/meter.go:252:github.com/adjust/backend/vendor/github.com/rcrowley/go-metrics.(*meterArbiter).tick
34 /usr/lib/go/src/runtime/proc.go:292:runtime.gopark
2 /usr/lib/go/src/runtime/sema.go:56:sync.runtime_Semacquire
14 /usr/lib/go/src/runtime/sys_linux_amd64.s:527:runtime.futex
3 /usr/lib/go/src/runtime/time.go:102:time.Sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment