Skip to content

Commit 9768870

Browse files
authored
use new observability package (#964)
* use new observability package * update example observability config * update go.mod/sum
1 parent 83e909e commit 9768870

File tree

4 files changed

+34
-527
lines changed

4 files changed

+34
-527
lines changed

cmd/webhook/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"knative.dev/pkg/controller"
2626
"knative.dev/pkg/injection/sharedmain"
2727
"knative.dev/pkg/logging"
28-
"knative.dev/pkg/metrics"
28+
o11yconfigmap "knative.dev/pkg/observability/configmap"
2929
"knative.dev/pkg/signals"
3030
"knative.dev/pkg/system"
3131
"knative.dev/pkg/webhook"
@@ -109,7 +109,7 @@ func NewConfigValidationController(ctx context.Context, cmw configmap.Watcher) *
109109
// The configmaps to validate.
110110
configmap.Constructors{
111111
logging.ConfigMapName(): logging.NewConfigFromConfigMap,
112-
metrics.ConfigMapName(): metrics.NewObservabilityConfigFromConfigMap,
112+
o11yconfigmap.Name(): o11yconfigmap.Parse,
113113
},
114114
)
115115
}

config/config-observability.yaml

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,53 +37,41 @@ data:
3737
# this example block and unindented to be in the data block
3838
# to actually change the configuration.
3939
40-
# If non-empty, this enables queue proxy writing request logs to stdout.
41-
# The value determines the shape of the request logs and it must be a valid go text/template.
42-
# It is important to keep this as a single line. Multiple lines are parsed as separate entities
43-
# by most collection agents and will split the request logs into multiple records.
44-
#
45-
# The following fields and functions are available to the template:
46-
#
47-
# Request: An http.Request (see https://golang.org/pkg/net/http/#Request)
48-
# representing an HTTP request received by the server.
49-
#
50-
# Response:
51-
# struct {
52-
# Code int // HTTP status code (see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
53-
# Size int // An int representing the size of the response.
54-
# Latency float64 // A float64 representing the latency of the response in seconds.
55-
# }
40+
# metrics-protocol field specifies the protocol used when exporting metrics
41+
# It supports either 'none' (the default), 'prometheus', 'http/protobuf' (OTLP HTTP), 'grpc' (OTLP gRPC)
42+
metrics-protocol: http/protobuf
43+
44+
# metrics-endpoint field specifies the destination metrics should be exporter to.
5645
#
57-
# Revision:
58-
# struct {
59-
# Name string // Knative revision name
60-
# Namespace string // Knative revision namespace
61-
# Service string // Knative service name
62-
# Configuration string // Knative configuration name
63-
# PodName string // Name of the pod hosting the revision
64-
# PodIP string // IP of the pod hosting the revision
65-
# }
46+
# The endpoint MUST be set when the protocol is http/protobuf or grpc.
47+
# The endpoint MUST NOT be set when the protocol is none.
6648
#
67-
logging.request-log-template: '{"httpRequest": {"requestMethod": "{{.Request.Method}}", "requestUrl": "{{js .Request.RequestURI}}", "requestSize": "{{.Request.ContentLength}}", "status": {{.Response.Code}}, "responseSize": "{{.Response.Size}}", "userAgent": "{{js .Request.UserAgent}}", "remoteIp": "{{js .Request.RemoteAddr}}", "serverIp": "{{.Revision.PodIP}}", "referer": "{{js .Request.Referer}}", "latency": "{{.Response.Latency}}s", "protocol": "{{.Request.Proto}}"}, "traceId": "{{index .Request.Header "X-B3-Traceid"}}"}'
49+
# When the protocol is prometheus the endpoint can accept a 'host:port' string to customize the
50+
# listening host interface and port.
51+
metrics-endpoint: http://promstack-kube-prometheus-prometheus.observability:9090/api/v1/otlp/v1/metrics
6852
69-
# metrics.backend-destination field specifies the system metrics destination.
70-
# It supports either prometheus (the default) or stackdriver.
71-
# Note: Using stackdriver will incur additional charges
72-
metrics.backend-destination: prometheus
53+
# metrics-export-interval specifies the global metrics reporting period for control and data plane components.
54+
# If a zero or negative value is passed the default reporting OTel period is used (60 secs).
55+
metrics-export-interval: 60s
7356
74-
# metrics.request-metrics-backend-destination specifies the request metrics
75-
# destination. If non-empty, it enables queue proxy to send request metrics.
76-
# Currently supported values: prometheus, stackdriver.
77-
metrics.request-metrics-backend-destination: prometheus
57+
# runtime-profiling indicates whether it is allowed to retrieve runtime profiling data from
58+
# the pods via an HTTP server in the format expected by the pprof visualization tool. When
59+
# enabled, the Knative Serving pods expose the profiling data on an alternate HTTP port 8008.
60+
# The HTTP context root for profiling is then /debug/pprof/.
61+
runtime-profiling: enabled
62+
63+
# tracing-protocol field specifies the protocol used when exporting metrics
64+
# It supports either 'none' (the default), 'prometheus', 'http/protobuf' (OTLP HTTP), 'grpc' (OTLP gRPC)
65+
# or `stdout` for debugging purposes
66+
tracing-protocol: http/protobuf
67+
68+
# tracing-endpoint field specifies the destination traces should be exporter to.
69+
#
70+
# The endpoint MUST be set when the protocol is http/protobuf or grpc.
71+
# The endpoint MUST NOT be set when the protocol is none.
72+
tracing-endpoint: http://jaeger-collector.observability:4318/v1/traces
7873
79-
# metrics.stackdriver-project-id field specifies the stackdriver project ID. This
80-
# field is optional. When running on GCE, application default credentials will be
81-
# used if this field is not provided.
82-
metrics.stackdriver-project-id: "<your stackdriver project id>"
74+
# tracing-sampling-rate allows the user to specify what percentage of all traces should be exported
75+
# The value should be between 0 (never sample) to 1 (always sample)
76+
tracing-sampling-rate: "1"
8377
84-
# metrics.allow-stackdriver-custom-metrics indicates whether it is allowed to send metrics to
85-
# Stackdriver using "global" resource type and custom metric type if the
86-
# metrics are not supported by "knative_revision" resource type. Setting this
87-
# flag to "true" could cause extra Stackdriver charge.
88-
# If metrics.backend-destination is not Stackdriver, this is ignored.
89-
metrics.allow-stackdriver-custom-metrics: "false"

go.mod

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,16 @@ require (
1414
)
1515

1616
require (
17-
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
18-
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
1917
github.com/beorn7/perks v1.0.1 // indirect
2018
github.com/blang/semver/v4 v4.0.0 // indirect
2119
github.com/blendle/zapdriver v1.3.1 // indirect
2220
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
23-
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
2421
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2522
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2623
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
2724
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
2825
github.com/felixge/httpsnoop v1.0.4 // indirect
2926
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
30-
github.com/go-kit/log v0.2.1 // indirect
31-
github.com/go-logfmt/logfmt v0.5.1 // indirect
3227
github.com/go-logr/logr v1.4.3 // indirect
3328
github.com/go-logr/stdr v1.2.2 // indirect
3429
github.com/go-logr/zapr v1.3.0 // indirect
@@ -37,8 +32,6 @@ require (
3732
github.com/go-openapi/swag v0.23.0 // indirect
3833
github.com/gobuffalo/flect v1.0.3 // indirect
3934
github.com/gogo/protobuf v1.3.2 // indirect
40-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
41-
github.com/golang/protobuf v1.5.4 // indirect
4235
github.com/google/gnostic-models v0.6.9 // indirect
4336
github.com/google/go-cmp v0.7.0 // indirect
4437
github.com/google/uuid v1.6.0 // indirect
@@ -56,10 +49,8 @@ require (
5649
github.com/prometheus/client_model v0.6.2 // indirect
5750
github.com/prometheus/common v0.65.0 // indirect
5851
github.com/prometheus/procfs v0.16.1 // indirect
59-
github.com/prometheus/statsd_exporter v0.22.7 // indirect
6052
github.com/spf13/pflag v1.0.6 // indirect
6153
github.com/x448/float16 v0.8.4 // indirect
62-
go.opencensus.io v0.24.0 // indirect
6354
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
6455
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
6556
go.opentelemetry.io/contrib/instrumentation/runtime v0.62.0 // indirect
@@ -89,14 +80,12 @@ require (
8980
golang.org/x/time v0.10.0 // indirect
9081
golang.org/x/tools v0.34.0 // indirect
9182
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
92-
google.golang.org/api v0.183.0 // indirect
9383
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
9484
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
9585
google.golang.org/grpc v1.73.0 // indirect
9686
google.golang.org/protobuf v1.36.6 // indirect
9787
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9888
gopkg.in/inf.v0 v0.9.1 // indirect
99-
gopkg.in/yaml.v2 v2.4.0 // indirect
10089
gopkg.in/yaml.v3 v3.0.1 // indirect
10190
k8s.io/apiextensions-apiserver v0.33.1 // indirect
10291
k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 // indirect

0 commit comments

Comments
 (0)