MCPcopy Index your code
hub / github.com/cloudfoundry/java-buildpack / Detect

Method Detect

src/java/frameworks/new_relic.go:25–49  ·  view source on GitHub ↗

Detect checks if New Relic should be included

()

Source from the content-addressed store, hash-verified

23
24// Detect checks if New Relic should be included
25func (n *NewRelicFramework) Detect() (string, error) {
26 // Check for New Relic service binding
27 vcapServices, err := GetVCAPServices()
28 if err != nil {
29 n.context.Log.Warning("Failed to parse VCAP_SERVICES: %s", err.Error())
30 return "", nil
31 }
32
33 // New Relic can be bound as:
34 // - "newrelic" service (marketplace or label)
35 // - Services with "newrelic" tag
36 // - User-provided services with "newrelic" in the name (Docker platform)
37 if vcapServices.HasService("newrelic") || vcapServices.HasTag("newrelic") || vcapServices.HasServiceByNamePattern("newrelic") {
38 n.context.Log.Info("New Relic service detected!")
39 return "New Relic Agent", nil
40 }
41
42 // Also check for NEW_RELIC_LICENSE_KEY environment variable
43 if n.context.Stager.LinkDirectoryInDepDir(filepath.Join(n.context.Stager.BuildDir(), ".new-relic-credentials"), "new-relic-credentials") == nil {
44 return "New Relic Agent", nil
45 }
46
47 n.context.Log.Debug("New Relic not detected")
48 return "", nil
49}
50
51// findNewRelicAgent locates the newrelic.jar in the agent directory
52func (n *NewRelicFramework) findNewRelicAgent(agentDir string) (string, error) {

Callers

nothing calls this directly

Calls 6

HasServiceMethod · 0.80
GetVCAPServicesFunction · 0.70
LinkDirectoryInDepDirMethod · 0.65
BuildDirMethod · 0.65
HasTagMethod · 0.45

Tested by

no test coverage detected