instrumentation

package
v0.20.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2024.

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

Constants

View Source
const (
	DefaultLicenseKeySecretName = "newrelic-key-secret"
)

Variables

This section is empty.

Functions

func GetLanguageInstrumentations

func GetLanguageInstrumentations(instCandidates []*v1beta1.Instrumentation) ([]*v1beta1.Instrumentation, error)

GetLanguageInstrumentations is used to collect all instrumentations and validate that only a single instrumentation exists for each language, and return them together, modifying the slice items in place

func GetSecretNameFromInstrumentations

func GetSecretNameFromInstrumentations(insts []*v1beta1.Instrumentation) (string, error)

GetSecretNameFromInstrumentations is used to get a single secret key name from a list of Instrumentation's. It will use the default if none is provided. If any of them are different by name, this will fail, as we can only bind a single license key to a single pod.

Types

type Health

type Health struct {
	Healthy            bool               `json:"healthy" yaml:"healthy"`
	Status             string             `json:"status" yaml:"status"`
	StartTime          int64              `json:"start_time_unix_nano" yaml:"start_time_unix_nano"`
	StatusTime         int64              `json:"status_time_unix_nano" yaml:"status_time_unix_nano"`
	LastError          string             `json:"last_error" yaml:"last_error"`
	ComponentHealthMap map[string]*Health `json:"component_health_map,omitempty" yaml:"component_health_map,omitempty"`
}

Health in the opamp format

type HealthCheck

type HealthCheck interface {
	GetHealth(ctx context.Context, url string) (health Health, err error)
}

HealthCheck our api contract

type HealthCheckApi

type HealthCheckApi struct {
	// contains filtered or unexported fields
}

HealthCheckApi .

func NewHealthCheckApi

func NewHealthCheckApi(httpClient *http.Client) *HealthCheckApi

NewHealthCheckApi returns a newly constructed health check client

func (*HealthCheckApi) GetHealth

func (h *HealthCheckApi) GetHealth(ctx context.Context, url string) (health Health, err error)

GetHealth to get the health via some url to decode the response in opamp format, provided we got a 200

type HealthMonitor

type HealthMonitor struct {
	// contains filtered or unexported fields
}

HealthMonitor .

func NewHealthMonitor

func NewHealthMonitor(
	instrumentationStatusUpdater InstrumentationStatusUpdater,
	healthCheck HealthCheck,
	tickInterval time.Duration,
	podMetricWorkers int,
	instrumentationsMetricWorkers int,
	instrumentationsMetricPersistWorkers int,
) *HealthMonitor

NewHealthMonitor returns a new instance of a health monitor which check the health of pods via the health sidecar

func (*HealthMonitor) InstrumentationRemove

func (m *HealthMonitor) InstrumentationRemove(instrumentation *v1beta1.Instrumentation)

InstrumentationRemove to remove the instrumentation

func (*HealthMonitor) InstrumentationSet

func (m *HealthMonitor) InstrumentationSet(instrumentation *v1beta1.Instrumentation)

InstrumentationSet to set the instrumentation

func (*HealthMonitor) NamespaceRemove

func (m *HealthMonitor) NamespaceRemove(ns *corev1.Namespace)

NamespaceRemove to remove the namespace

func (*HealthMonitor) NamespaceSet

func (m *HealthMonitor) NamespaceSet(ns *corev1.Namespace)

NamespaceSet to set the namespace

func (*HealthMonitor) PodRemove

func (m *HealthMonitor) PodRemove(pod *corev1.Pod)

PodRemove to remove the pod

func (*HealthMonitor) PodSet

func (m *HealthMonitor) PodSet(pod *corev1.Pod)

PodSet to set the pod

func (*HealthMonitor) Shutdown

func (m *HealthMonitor) Shutdown(ctx context.Context) error

Shutdown is used to shutdown all new work. anything already processing will continue. this could be called multiple times. Calling this will block until either it's finished or the context expires

func (*HealthMonitor) Stop

func (m *HealthMonitor) Stop(ctx context.Context) error

Stop is used to stop all work. this could be called multiple times. Calling this will block until either it's finished or the context expires

type InstrumentationLocator

type InstrumentationLocator interface {
	GetInstrumentations(ctx context.Context, ns corev1.Namespace, pod corev1.Pod) ([]*v1beta1.Instrumentation, error)
}

InstrumentationLocator is used to find instrumentations

type InstrumentationPodMutator

type InstrumentationPodMutator struct {
	// contains filtered or unexported fields
}

func NewMutator

func NewMutator(
	logger logr.Logger,
	client client.Client,
	sdkInjector SdkInjector,
	secretReplicator SecretReplicator,
	instrumentationLocator InstrumentationLocator,
	operatorNamespace string,
) *InstrumentationPodMutator

NewMutator is used to get a new instance of a mutator

func (*InstrumentationPodMutator) Mutate

Mutate is used to mutate a pod based on some instrumentation(s)

type InstrumentationStatusUpdater

type InstrumentationStatusUpdater interface {
	UpdateInstrumentationStatus(ctx context.Context, instrumentation *v1beta1.Instrumentation) error
}

type InstrumentationStatusUpdaterImpl

type InstrumentationStatusUpdaterImpl struct {
	client.Client
}

func NewInstrumentationStatusUpdater

func NewInstrumentationStatusUpdater(client client.Client) *InstrumentationStatusUpdaterImpl

func (*InstrumentationStatusUpdaterImpl) UpdateInstrumentationStatus

func (i *InstrumentationStatusUpdaterImpl) UpdateInstrumentationStatus(ctx context.Context, instrumentation *v1beta1.Instrumentation) error

type NewrelicInstrumentationLocator

type NewrelicInstrumentationLocator struct {
	// contains filtered or unexported fields
}

NewrelicInstrumentationLocator is the base struct for locating instrumentations

func NewNewRelicInstrumentationLocator

func NewNewRelicInstrumentationLocator(logger logr.Logger, client client.Client, operatorNamespace string) *NewrelicInstrumentationLocator

NewNewRelicInstrumentationLocator is the constructor for getting instrumentations

func (*NewrelicInstrumentationLocator) GetInstrumentations

GetInstrumentations is used to get all instrumentations in the cluster. While we could limit it to the operator namespace, it's more helpful to list anything in the logs that may have been excluded.

type NewrelicSdkInjector

type NewrelicSdkInjector struct {
	// contains filtered or unexported fields
}

NewrelicSdkInjector is the base struct used to inject our instrumentation into a pod

func NewNewrelicSdkInjector

func NewNewrelicSdkInjector(logger logr.Logger, client client.Client, injectorRegistry *apm.InjectorRegistery) *NewrelicSdkInjector

NewNewrelicSdkInjector is used to create our injector

func (*NewrelicSdkInjector) Inject

Inject is used to utilize a list of instrumentations, and if the injectors language matches the instrumentation, trigger the injector

type NewrelicSecretReplicator

type NewrelicSecretReplicator struct {
	// contains filtered or unexported fields
}

NewrelicSecretReplicator is the base struct used for copying the secrets

func NewNewrelicSecretReplicator

func NewNewrelicSecretReplicator(logger logr.Logger, client client.Client) *NewrelicSecretReplicator

NewNewrelicSecretReplicator is the constructor for copying secrets

func (*NewrelicSecretReplicator) ReplicateSecret

func (sr *NewrelicSecretReplicator) ReplicateSecret(ctx context.Context, ns corev1.Namespace, pod corev1.Pod, operatorNamespace string, secretName string) error

ReplicateSecret is used to copy the secret from the operator namespace to the pod namespace if the secret doesn't already exist

type SdkInjector

type SdkInjector interface {
	Inject(ctx context.Context, insts []*v1beta1.Instrumentation, ns corev1.Namespace, pod corev1.Pod) corev1.Pod
}

SdkInjector is used to inject our instrumentation into a pod

type SecretReplicator

type SecretReplicator interface {
	ReplicateSecret(ctx context.Context, ns corev1.Namespace, pod corev1.Pod, operatorNamespace string, secretName string) error
}

SecretReplicator is used to copy secrets from one namespace to another

Directories

Path Synopsis
util

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL