Detect checks if New Relic should be included
()
| 23 | |
| 24 | // Detect checks if New Relic should be included |
| 25 | func (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 |
| 52 | func (n *NewRelicFramework) findNewRelicAgent(agentDir string) (string, error) { |
nothing calls this directly
no test coverage detected