Skip to content

Commit 8f858f3

Browse files
committed
Add otel http and runtime metrics
1 parent 9eff04e commit 8f858f3

File tree

432 files changed

+7088
-53937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+7088
-53937
lines changed

alloy/cloud.otlp.alloy

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,38 +82,38 @@ pyroscope.scrape "application_containers" {
8282
// Traces
8383
otelcol.receiver.otlp "default" {
8484
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.receiver.otlp/
85-
85+
8686
// configures the default grpc endpoint "0.0.0.0:4317"
8787
grpc { }
8888
// configures the default http/protobuf endpoint "0.0.0.0:4318"
8989
http { }
90-
90+
9191
output {
9292
metrics = [otelcol.processor.resourcedetection.default.input]
9393
logs = [otelcol.processor.resourcedetection.default.input]
9494
traces = [otelcol.processor.resourcedetection.default.input]
9595
}
9696
}
97-
97+
9898
otelcol.processor.resourcedetection "default" {
9999
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.processor.resourcedetection/
100100
detectors = ["env", "system"] // add "gcp", "ec2", "ecs", "elastic_beanstalk", "eks", "lambda", "azure", "aks", "consul", "heroku" if you want to use cloud resource detection
101-
101+
102102
system {
103103
hostname_sources = ["os"]
104104
}
105-
105+
106106
output {
107107
metrics = [otelcol.processor.transform.drop_unneeded_resource_attributes.input]
108108
logs = [otelcol.processor.transform.drop_unneeded_resource_attributes.input]
109109
traces = [otelcol.processor.transform.drop_unneeded_resource_attributes.input]
110110
}
111111
}
112-
112+
113113
otelcol.processor.transform "drop_unneeded_resource_attributes" {
114114
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.processor.transform/
115115
error_mode = "ignore"
116-
116+
117117
trace_statements {
118118
context = "resource"
119119
statements = [
@@ -128,7 +128,7 @@ otelcol.processor.transform "drop_unneeded_resource_attributes" {
128128
"delete_key(attributes, \"process.runtime.version\")",
129129
]
130130
}
131-
131+
132132
metric_statements {
133133
context = "resource"
134134
statements = [
@@ -143,7 +143,7 @@ otelcol.processor.transform "drop_unneeded_resource_attributes" {
143143
"delete_key(attributes, \"process.runtime.version\")",
144144
]
145145
}
146-
146+
147147
log_statements {
148148
context = "resource"
149149
statements = [
@@ -158,7 +158,7 @@ otelcol.processor.transform "drop_unneeded_resource_attributes" {
158158
"delete_key(attributes, \"process.runtime.version\")",
159159
]
160160
}
161-
161+
162162
output {
163163
metrics = [otelcol.processor.transform.add_resource_attributes_as_metric_attributes.input]
164164
logs = [otelcol.processor.batch.default.input]
@@ -168,33 +168,33 @@ otelcol.processor.transform "drop_unneeded_resource_attributes" {
168168
]
169169
}
170170
}
171-
171+
172172
otelcol.connector.host_info "default" {
173173
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.connector.host_info/
174174
host_identifiers = ["container.name", "container.id", "service.name"]
175-
175+
176176
output {
177177
metrics = [otelcol.processor.batch.default.input]
178178
}
179179
}
180-
180+
181181
otelcol.processor.transform "add_resource_attributes_as_metric_attributes" {
182182
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.processor.transform/
183183
error_mode = "ignore"
184-
184+
185185
metric_statements {
186186
context = "datapoint"
187187
statements = [
188188
"set(attributes[\"deployment.environment\"], resource.attributes[\"deployment.environment\"])",
189189
"set(attributes[\"service.version\"], resource.attributes[\"service.version\"])",
190190
]
191191
}
192-
192+
193193
output {
194194
metrics = [otelcol.processor.batch.default.input]
195195
}
196196
}
197-
197+
198198
otelcol.processor.batch "default" {
199199
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.processor.batch/
200200
output {

cmd/main.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,26 @@ func main() {
3939
pyroscope.Start(profilingConfig)
4040
}
4141

42-
// Enable tracing if configured.
43-
traceInstaller := &qphttp.TraceInstaller{}
44-
otlpEndpoint, tracingEnabled := os.LookupEnv("QUICKPIZZA_OTLP_ENDPOINT")
45-
if tracingEnabled {
42+
// Enable OpenTelemetry if configured.
43+
otelInstaller := &qphttp.OTelInstaller{}
44+
45+
// TODO: use standard OTEL_EXPORTER_OTLP_ENDPOINT env var
46+
otlpEndpoint, otelEnabled := os.LookupEnv("QUICKPIZZA_OTLP_ENDPOINT")
47+
if otelEnabled {
4648
ctx, cancel := context.WithCancel(context.Background())
4749
defer cancel()
4850

4951
var err error
50-
traceInstaller, err = qphttp.NewTraceInstaller(ctx, otlpEndpoint)
52+
otelInstaller, err = qphttp.NewOTelInstaller(ctx, otlpEndpoint)
5153
if err != nil {
52-
slog.Error("creating otlp trace installer", "err", err)
54+
slog.Error("creating OpenTelemetryinstaller", "err", err)
5355
os.Exit(1)
5456
}
5557

56-
slog.Debug("enabling tracing")
58+
slog.Debug("enabling OpenTelemetry tracing and metrics")
5759

5860
if envBool("QUICKPIZZA_TRUST_CLIENT_TRACEID") {
59-
traceInstaller.Insecure()
61+
otelInstaller.Insecure()
6062
}
6163
}
6264

@@ -65,7 +67,7 @@ func main() {
6567
httpCli := clientFromEnv()
6668

6769
// Create the QuickPizza server.
68-
server := qphttp.NewServer(profilingEnabled, traceInstaller)
70+
server := qphttp.NewServer(profilingEnabled, otelInstaller)
6971

7072
server.AddLivenessProbes()
7173

compose.grafana-cloud.microservices.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,3 @@ services:
110110
QUICKPIZZA_ENABLE_WS_SERVICE: "1"
111111
QUICKPIZZA_OTEL_SERVICE_INSTANCE_ID: "ws"
112112
QUICKPIZZA_OTEL_SERVICE_NAME: "ws"
113-

go.mod

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module github.com/grafana/quickpizza
22

3-
go 1.23.0
3+
go 1.24.0
44

55
toolchain go1.24.6
66

77
require (
88
github.com/go-chi/chi/v5 v5.2.2
99
github.com/go-chi/cors v1.2.1
1010
github.com/go-chi/httplog/v2 v2.1.1
11-
github.com/grafana/otel-profiling-go v0.5.1
1211
github.com/grafana/pyroscope-go v1.2.1
1312
github.com/grafana/pyroscope-go/x/k6 v0.0.0-20240618140011-f1a626fc4fe0
1413
github.com/hashicorp/go-retryablehttp v0.7.7
@@ -23,21 +22,16 @@ require (
2322
github.com/uptrace/bun/driver/sqliteshim v1.2.15
2423
github.com/uptrace/bun/extra/bunotel v1.2.15
2524
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0
26-
go.opentelemetry.io/otel v1.37.0
27-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0
28-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0
29-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0
30-
go.opentelemetry.io/otel/sdk v1.28.0
31-
go.opentelemetry.io/otel/trace v1.37.0
32-
golang.org/x/crypto v0.40.0
33-
golang.org/x/net v0.42.0
34-
google.golang.org/grpc v1.65.0
35-
google.golang.org/protobuf v1.34.2
25+
go.opentelemetry.io/otel v1.38.0
26+
go.opentelemetry.io/otel/trace v1.38.0
27+
golang.org/x/crypto v0.41.0
28+
golang.org/x/net v0.43.0
29+
google.golang.org/grpc v1.75.0
30+
google.golang.org/protobuf v1.36.8
3631
)
3732

3833
require (
3934
github.com/beorn7/perks v1.0.1 // indirect
40-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
4135
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4236
github.com/dustin/go-humanize v1.0.1 // indirect
4337
github.com/felixge/httpsnoop v1.0.3 // indirect
@@ -47,7 +41,6 @@ require (
4741
github.com/google/uuid v1.6.0 // indirect
4842
github.com/gorilla/websocket v1.5.0 // indirect
4943
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
50-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
5144
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
5245
github.com/jinzhu/inflection v1.0.0 // indirect
5346
github.com/klauspost/compress v1.17.9 // indirect
@@ -64,14 +57,13 @@ require (
6457
github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 // indirect
6558
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
6659
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
67-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
68-
go.opentelemetry.io/otel/metric v1.37.0 // indirect
69-
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
60+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
61+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
62+
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
7063
golang.org/x/exp v0.0.0-20250711185948-6ae5c78190dc // indirect
71-
golang.org/x/sys v0.34.0 // indirect
72-
golang.org/x/text v0.27.0 // indirect
73-
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
74-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
64+
golang.org/x/sys v0.36.0 // indirect
65+
golang.org/x/text v0.28.0 // indirect
66+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
7567
gopkg.in/yaml.v3 v3.0.1 // indirect
7668
mellium.im/sasl v0.3.2 // indirect
7769
modernc.org/libc v1.66.3 // indirect

0 commit comments

Comments
 (0)