Documentation ¶
Overview ¶
https://github.com/equinix-labs/otel-init-go Copyright [yyyy] [name of copyright owner]
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.
Index ¶
- func ContextWithEnvTraceparent(ctx context.Context) context.Context
- func ContextWithTraceparentString(ctx context.Context, traceparent string) context.Context
- func Init(ctx context.Context, c Config) (context.Context, context.CancelFunc, error)
- func TraceparentStringFromContext(ctx context.Context) string
- type Config
- type SimpleCarrier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithEnvTraceparent ¶
ContextWithEnvTraceparent is a helper that looks for the the TRACEPARENT environment variable and if it's set, it grabs the traceparent and adds it to the context it returns. When there is no envvar or it's empty, the original context is returned unmodified. Depends on global OTel TextMapPropagator.
func ContextWithTraceparentString ¶
ContextWithTraceparentString takes a W3C traceparent string, uses the otel carrier code to get it into a context it returns ready to go. Depends on global OTel TextMapPropagator.
func Init ¶
Init sets up the OpenTelemetry plumbing so it's ready to use. It requires a context.Context and returns context and a func() that encapuslates clean shutdown.
func TraceparentStringFromContext ¶
TraceparentStringFromContext gets the current trace from the context and returns a W3C traceparent string. Depends on global OTel TextMapPropagator.
Types ¶
type Config ¶
type Config struct { Servicename string `json:"service_name"` Endpoint string `json:"endpoint"` Insecure bool `json:"insecure"` Logger logr.Logger }
Config holds the typed values of configuration read from the environment. It is public mainly to make testing easier and most users should never use it directly.
type SimpleCarrier ¶
SimpleCarrier is an abstraction for handling traceparent propagation that needs a type that implements the propagation.TextMapCarrier(). This is the simplest possible implementation that is a little fragile but since we're not doing anything else with it, it's fine for this.
func (SimpleCarrier) Clear ¶
func (otp SimpleCarrier) Clear()
Clear implements the otel interface for propagation.
func (SimpleCarrier) Get ¶
func (otp SimpleCarrier) Get(key string) string
Get implements the otel interface for propagation.
func (SimpleCarrier) Keys ¶
func (otp SimpleCarrier) Keys() []string
Keys implements the otel interface for propagation.
func (SimpleCarrier) Set ¶
func (otp SimpleCarrier) Set(key, value string)
Set implements the otel interface for propagation.