New observability package#3188
Conversation
dprotaso
commented
Jun 25, 2025
- include observability package
- go mod changes
- commit vendor
|
/hold for review |
|
/assign @Cali0707 @evankanderson @skonto |
|
new OTel libs were cut today - I just bumped them |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3188 +/- ##
=======================================
Coverage ? 75.96%
=======================================
Files ? 205
Lines ? 11690
Branches ? 0
=======================================
Hits ? 8880
Misses ? 2539
Partials ? 271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| return Config{ | ||
| Protocol: ProtocolNone, | ||
| } |
There was a problem hiding this comment.
Should we default the export interval?
There was a problem hiding this comment.
I think 0 for "do the right thing" makes sense.
There was a problem hiding this comment.
I am wondering if we should allow "" to mean either "prometheus" or "none" (i.e. make empty string an acceptable value)...
There was a problem hiding this comment.
either "prometheus" or "none"
I think that would cause confusion since it's not explicit
evankanderson
left a comment
There was a problem hiding this comment.
I'm assuming there's a future PR that adds interfaces for recording metrics, traces, etc, along with examples of usage.
There was a problem hiding this comment.
Why not put this in the observability package directly (what users are going to use that package, but not configmap.Parse())?
There was a problem hiding this comment.
I wanted to keep k8s api deps out of this since it includes a lot of types.
We'll be able to reduce queue proxy binary size: knative/serving#9957 (comment)
| return &ProfilingServer{ | ||
| ProfilingHandler: h, | ||
| Server: &http.Server{ | ||
| Addr: ":" + port, |
There was a problem hiding this comment.
For metrics / prometheus, you allow setting the listen address, but you don't here. Intentional?
There was a problem hiding this comment.
Not intentional - just moving the existing profile server from metrics package into a separate one here.
| for _, tc := range cases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| ctx := context.Background() | ||
| _, err := NewMeterProvider(ctx, tc.c) |
There was a problem hiding this comment.
If you set Endpoint for Prometheus (at least), you'll get a bit of extra code coverage. (You may also want to .validate() your configs.)
There was a problem hiding this comment.
let me add a test for prometheus endpoint. (done)
You may also want to .validate() your configs.)
Can you clarify? Are you asking I call Validate on the cfg that's passed to NewMeterProvider?
|
flake - metrics: TestMetricsExport/OpenCensus /retest |
Actually I don't think we need this - we can just use OTel libraries - see this diff on how I added a custom metric to the webhook. 8b5f38b |
|
|
||
| var globalViews map[string][]metric.View = make(map[string][]metric.View) | ||
|
|
||
| // Register should be called during package init |
There was a problem hiding this comment.
Is go package init order guaranteed to be single-threaded?
If not, you may need to lock this map or use an atomic map.
There was a problem hiding this comment.
Yeah the spec has
https://go.dev/ref/spec#Package_initialization
followed by calling all init functions in the order they appear in the source, possibly in multiple files, as presented to the compiler.
Then in https://go.dev/ref/spec#Program_initialization
Package initialization—variable initialization and the invocation of init functions—happens in a single goroutine, sequentially, one package at a time.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, evankanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
/hold cancel |