mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
When using conditionally compiled metrics there was only one go_tag to rule them all. That's kind of a shame because when profiling something specific it's nicer to know that only your metrics that you care about are compiled in and metrics that you don't care about aren't. This CL makes it easy to create new profiling go_tags, by abstracting the profiling metric init functions under two builder structs: RealMetricBuilder and FakeMetricBuilder; these builder structs are the only things that need to change between the metrics-ON or OFF versions of conditional metric files (aside from the go_tag controlling conditional compilation of course). Ideally having to create these files manually wouldn't be necessary at all, and we could use a go_template build rule instead, but that doesn't support replacing go:build tags AFAIK. PiperOrigin-RevId: 571153131
24 lines
917 B
Go
24 lines
917 B
Go
// Copyright 2023 The gVisor Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//go:build sentry_profiling
|
|
// +build sentry_profiling
|
|
|
|
package metric
|
|
|
|
// SentryProfiling is a builder that produces conditionally compiled metrics.
|
|
// Metrics made from this are compiled and active at runtime when the
|
|
// "sentry_profiling" go-tag is specified at compilation.
|
|
var SentryProfiling = RealMetricBuilder{}
|