google.golang.org/grpc@v1.72.2/stats/opentelemetry/internal/pluginoption.go (about) 1 /* 2 * Copyright 2024 gRPC authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Package internal defines the PluginOption interface. 18 package internal 19 20 import ( 21 "google.golang.org/grpc/metadata" 22 ) 23 24 // SetPluginOption sets the plugin option on Options. 25 var SetPluginOption any // func(*Options, PluginOption) 26 27 // PluginOption is the interface which represents a plugin option for the 28 // OpenTelemetry instrumentation component. This plugin option emits labels from 29 // metadata and also creates metadata containing labels. These labels are 30 // intended to be added to applicable OpenTelemetry metrics recorded in the 31 // OpenTelemetry instrumentation component. 32 // 33 // In the future, we hope to stabilize and expose this API to allow plugins to 34 // inject labels of their choosing into metrics recorded. 35 type PluginOption interface { 36 // GetMetadata creates a MD with metadata exchange labels. 37 GetMetadata() metadata.MD 38 // GetLabels emits labels to be attached to metrics for the RPC that 39 // contains the provided incomingMetadata. 40 GetLabels(incomingMetadata metadata.MD) map[string]string 41 }