dynatrace

package module
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 16 Imported by: 4

README

libbuildpack-dynatrace

Base Library for Go-based Cloud Foundry Buildpack integrations with Dynatrace.

Summary

The library provides the Hook struct that implements the libbuildpack.Hook interface that it's requested by the CF Buildpacks.

On the buildpacks, you're expected to provide a hook through a init() function where you can register such hook implementation. For example, a simple implementation could be,

import (
	"github.com/cloudfoundry/libbuildpack"
	"github.com/Dynatrace/libbuildpack-dynatrace"
)

func init() {
	libbuildpack.AddHook(dynatrace.NewHook("nodejs", "process"))
}

Configuration

The Hook will look for credentials in the configurations for existing services. It searches for service credentials depending on the binding type:

  1. File-based: If the VCAP_SERVICES_FILE_PATH environment variable is set, the hook reads the VCAP_SERVICES JSON from the file at that path.
  2. Environment variable: If the env var VCAP_SERVICES is set, it reads the JSON from the VCAP_SERVICES environment variable directly.

In both cases, we look for service names having the 'dynatrace' substring.

We support the following configuration fields,

Key Type Description Required Default
environmentid string The ID for the Dynatrace environment. Yes N/A
apitoken string The API Token for the Dynatrace environment. Yes N/A
apiurl string Overrides the default Dynatrace API URL to connect to. No Default API URL
customoneagenturl string Custom download URL for the OneAgent installer (paas-sh) No empty
skiperrors boolean If true, the deployment doesn't fail if the Dynatrace agent download fails. No false
networkzone string If set, agent is configured to choose communication endpoints located at the field's value. No empty
enablefips boolean If true, the FIPS 140-2 mode is enabled No false
removetechnologies string Removes OneAgent code-modules via a comma-separated list. This is applied before addtechnologies. No empty
addtechnologies string Adds additional OneAgent code-modules via a comma-separated list. See supported values in the "included" row No empty
unconfigured boolean Must be set to true if an installer without the connection metadata is being used via customoneagenturl No false
tenanttoken string Dynatrace Tenant token when unconfigured is set to true empty
dtconnectionpoint string Connection endpoints when unconfigured is set to true empty

For example,

cf create-user-provided-service dynatrace -p '{"environmentid":"...","apitoken":"..."}'

See more at the documentation for cf create-user-provided-service.

We also support standard Dynatrace environment variables.

Requirements

  • Go 1.19 or higher.
  • Deployment targets: Linux and Windows.
  • Development and testing: Linux, Mac OS, and Windows.

Development

You can download or clone the repository.

You can run tests through,

go test ./...

By default, tests simulate the Linux platform. To test against a different target OS, use the -os flag:

go test ./... -os=windows
go test ./... -os=linux

If you modify/add interfaces, you may need to regenerate the mocks. For this you need gomock:

# To download Gomock
go get github.com/golang/mock/gomock
go install github.com/golang/mock/mockgen

# To generate the mocks
go generate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHook

func NewHook(technologies ...string) libbuildpack.Hook

NewHook returns a libbuildpack.Hook instance for integrating monitoring with Dynatrace. The technology names for the agents to download can be set as parameters.

Types

type Command

type Command interface {
	Execute(string, io.Writer, io.Writer, string, ...string) error
}

Command is an interface around libbuildpack.Command. Represents an executor for external command calls. We have it as an interface so that we can mock it and use in the unit tests.

type Hook

type Hook struct {
	libbuildpack.DefaultHook
	Log     *libbuildpack.Logger
	Command Command

	// IncludeTechnologies is used to indicate the technologies we want to download agents for.
	IncludeTechnologies []string

	// MaxDownloadRetries is the maximum number of retries the hook will try to download the agent if they fail.
	MaxDownloadRetries int
}

Hook implements libbuildpack.Hook. It downloads and install the Dynatrace OneAgent.

func (*Hook) AfterCompile

func (h *Hook) AfterCompile(stager *libbuildpack.Stager) error

AfterCompile downloads and installs the Dynatrace agent.

Jump to

Keyboard shortcuts

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