Skip to content

Commit 133f682

Browse files
committed
Merge branch 'aaronc/tracing-metrics' into aaronc/iavlx-sim-bench
2 parents 962533a + f0c3955 commit 133f682

File tree

18 files changed

+99
-19
lines changed

18 files changed

+99
-19
lines changed

client/v2/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ require (
151151
github.com/zondax/ledger-go v1.0.1 // indirect
152152
go.etcd.io/bbolt v1.4.0 // indirect
153153
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
154+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 // indirect
154155
go.opentelemetry.io/contrib/otelconf v0.18.0 // indirect
155156
go.opentelemetry.io/otel v1.38.0 // indirect
156157
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 // indirect

client/v2/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
724724
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
725725
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
726726
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
727+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 h1:bwnLpizECbPr1RrQ27waeY2SPIPeccCx/xLuoYADZ9s=
728+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0/go.mod h1:3nWlOiiqA9UtUnrcNk82mYasNxD8ehOspL0gOfEo6Y4=
727729
go.opentelemetry.io/contrib/otelconf v0.18.0 h1:ciF2Gf00BWs0DnexKFZXcxg9kJ8r3SUW1LOzW3CsKA8=
728730
go.opentelemetry.io/contrib/otelconf v0.18.0/go.mod h1:FcP7k+JLwBLdOxS6qY6VQ/4b5VBntI6L6o80IMwhAeI=
729731
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ require (
5757
github.com/tendermint/go-amino v0.16.0
5858
github.com/test-go/testify v1.1.4
5959
github.com/tidwall/btree v1.8.1
60+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0
6061
go.opentelemetry.io/contrib/otelconf v0.18.0
6162
go.opentelemetry.io/otel v1.38.0
6263
go.opentelemetry.io/otel/log v0.14.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
839839
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
840840
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
841841
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
842+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 h1:bwnLpizECbPr1RrQ27waeY2SPIPeccCx/xLuoYADZ9s=
843+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0/go.mod h1:3nWlOiiqA9UtUnrcNk82mYasNxD8ehOspL0gOfEo6Y4=
842844
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 h1:F7q2tNlCaHY9nMKHR6XH9/qkp8FktLnIcy6jJNyOCQw=
843845
go.opentelemetry.io/contrib/detectors/gcp v1.36.0/go.mod h1:IbBN8uAIIx734PTonTPxAxnjc2pQTxWNkwfstZ+6H2k=
844846
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=

simapp/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ require (
202202
github.com/zondax/ledger-go v1.0.1 // indirect
203203
go.etcd.io/bbolt v1.4.0 // indirect
204204
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
205+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 // indirect
205206
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 // indirect
206207
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
207208
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect

simapp/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,8 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
847847
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
848848
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
849849
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
850+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 h1:bwnLpizECbPr1RrQ27waeY2SPIPeccCx/xLuoYADZ9s=
851+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0/go.mod h1:3nWlOiiqA9UtUnrcNk82mYasNxD8ehOspL0gOfEo6Y4=
850852
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 h1:F7q2tNlCaHY9nMKHR6XH9/qkp8FktLnIcy6jJNyOCQw=
851853
go.opentelemetry.io/contrib/detectors/gcp v1.36.0/go.mod h1:IbBN8uAIIx734PTonTPxAxnjc2pQTxWNkwfstZ+6H2k=
852854
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=

simapp/sim_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/stretchr/testify/require"
2121

2222
"cosmossdk.io/log"
23+
2324
"github.com/cosmos/cosmos-sdk/telemetry"
2425

2526
"cosmossdk.io/store"
@@ -161,9 +162,10 @@ func IsEmptyValidatorSetErr(err error) bool {
161162

162163
func TestAppStateDeterminism(t *testing.T) {
163164
telemetry.TestingInit(t, context.Background())
164-
const numTimesToRunPerSeed = 1
165+
cfg := simcli.NewConfigFromFlags()
166+
numTimesToRunPerSeed := cfg.NumRuns
165167
var seeds []int64
166-
if s := simcli.NewConfigFromFlags().Seed; s != simcli.DefaultSeedValue {
168+
if s := cfg.Seed; s != simcli.DefaultSeedValue {
167169
// We will be overriding the random seed and just run a single simulation on the provided seed value
168170
for j := 0; j < numTimesToRunPerSeed; j++ { // multiple rounds
169171
seeds = append(seeds, s)

systemtests/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ require (
151151
github.com/zondax/ledger-go v1.0.1 // indirect
152152
go.etcd.io/bbolt v1.4.0 // indirect
153153
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
154+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 // indirect
154155
go.opentelemetry.io/contrib/otelconf v0.18.0 // indirect
155156
go.opentelemetry.io/otel v1.38.0 // indirect
156157
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 // indirect

systemtests/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,8 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
733733
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
734734
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
735735
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
736+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0 h1:bwnLpizECbPr1RrQ27waeY2SPIPeccCx/xLuoYADZ9s=
737+
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0/go.mod h1:3nWlOiiqA9UtUnrcNk82mYasNxD8ehOspL0gOfEo6Y4=
736738
go.opentelemetry.io/contrib/otelconf v0.18.0 h1:ciF2Gf00BWs0DnexKFZXcxg9kJ8r3SUW1LOzW3CsKA8=
737739
go.opentelemetry.io/contrib/otelconf v0.18.0/go.mod h1:FcP7k+JLwBLdOxS6qY6VQ/4b5VBntI6L6o80IMwhAeI=
738740
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=

telemetry/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Quick Start For Local Telemetry
2+
3+
To quickly setup a local telemetry environment where OpenTelemetry data is sent to a local instance of Grafana LGTM:
4+
1. start the [Grafana LGTM docker image](https://hub.docker.com/r/grafana/otel-lgtm):
5+
```shell
6+
docker run -p 3000:3000 -p 4317:4317 -p 4318:4318 --rm -ti grafana/otel-lgtm
7+
```
8+
2. create a basic OpenTelemetry configuration file which will send data to the local instance of Grafana LGTM:
9+
```yaml
10+
resource:
11+
attributes:
12+
- name: service.name
13+
value: my_app_name
14+
tracer_provider:
15+
processors:
16+
- simple: # NOTE: you should use batch in production!
17+
exporter:
18+
otlp:
19+
protocol: grpc
20+
endpoint: http://localhost:4317
21+
meter_provider:
22+
readers:
23+
- periodic:
24+
interval: 100 # 100 milliseconds, use something longer in production!
25+
exporter:
26+
otlp:
27+
protocol: grpc
28+
endpoint: http://localhost:4317
29+
logger_provider:
30+
processors:
31+
- simple: # NOTE: you should use batch in production!
32+
exporter:
33+
otlp:
34+
protocol: grpc
35+
endpoint: http://localhost:4317
36+
```
37+
3. set the `OTEL_EXPERIMENTAL_CONFIG_FILE` environment variable to the path of the configuration file:
38+
`export OTEL_EXPERIMENTAL_CONFIG_FILE=path/to/config.yaml`
39+
4. start your application or tests
40+
5. view the data in Grafana LGTM at http://localhost:3000/. The Drilldown views are suggested for getting started.
41+
42+
## OpenTelemetry Initialization
43+
44+
While manual OpenTelemetry initialization is still supported, this package provides a single
45+
point of initialization such that end users can just use the official
46+
OpenTelemetry declarative configuration spec: https://opentelemetry.io/docs/languages/sdk-configuration/declarative-configuration/
47+
End users only need to set the `OTEL_EXPERIMENTAL_CONFIG_FILE` environment variable to the path of
48+
an OpenTelemetry configuration file and that's it.
49+
All the documentation necessary is provided in the OpenTelemetry documentation.
50+
51+
## Developer Usage
52+
53+
Developers need to do two things to use this package properly:
54+
1. Import this package before declaring any otel Tracer, Meter or Logger instances.
55+
2. Make sure Shutdown() is called when the application is shutting down.
56+
Tests can use the TestingInit function at startup to accomplish this.
57+
58+
If these steps are followed, developers can follow the official golang otel conventions
59+
of declaring package-level tracer and meter instances using otel.Tracer() and otel.Meter().
60+
NOTE: it is important to thread context.Context properly for spans, metrics and logs to be
61+
correlated correctly.
62+
When using the SDK's context type, spans must be started with Context.StartSpan to
63+
get an SDK context which has the span set correctly.
64+
For logging, go.opentelemetry.io/contrib/bridges/otelslog provides a way to do this with the standard
65+
library slog package.

0 commit comments

Comments
 (0)