newrelic / go-agent

New Relic Go Agent
Apache License 2.0
756 stars 296 forks source link

Specify service version during initial newrelic configuration #898

Open clarkmcc opened 2 months ago

clarkmcc commented 2 months ago

Summary

Currently, I'm using Github Actions to indicate to new relic when I release a new version of my app, but this does not work well when there are multiple versions of my application deployed, especially during rolling deployments, or canary deployments.

Desired Behaviour

My service's version information is already baked into my binaries, it would be great if I could so something like

newrelic.NewApplication(newrelic.ConfigAppVersion(version.String))

This is basically how datadog does it, and is much better when tracking down version-specific issues across multiple running versions of the app.

Possible Solution

Additional context

nr-swilloughby commented 2 months ago

Thank you for this enhancement request. We're reviewing it and will let you know how we can proceed with it.

nr-swilloughby commented 2 months ago

For clarification, do you want this to replace the github workflow so that it would register the version as a deployment marker, or do you just want each running instance to report its own version in a way you can query or group data later?

clarkmcc commented 2 months ago

Full disclosure, I am sticking with Datadog for now. But what I would like is the latter -- where the metrics, logs, errors etc are all associated with a specific version of an application. In this way of if I have two versions running at the same time which is common among the various deployment models that are out there, then I can more easily correlate errors with specific versions.

nr-swilloughby commented 2 months ago

Based on that being what you're actually looking to accomplish, although app version isn't explicitly one of the configuration settings, your best bet with how things are implemented now is to use one of the existing means to put a custom value to represent the application version. For example, you can specify up to three app names separated by semicolons such as myapp;myapp-prod;myapp-prod-1.0 to use app name rollups. Or you could add custom metadata by setting NEW_RELIC_METADATA_APPVERSION=prod-1.0 to your environment.

clarkmcc commented 2 months ago

Yeah but that isn't first-class support for these different types of deployment models. Sure that would show me the app version in the UI, but the reason that I want the version captured is so that all metrics, all events, etc can be faceted by the version, allowing me to easily see anomalous behavior introduced by a specific version. Can this be done with custom metadata?

nr-swilloughby commented 2 months ago

The details on this and which approach best suits your needs are better handled by a technical support engineer instead of the agent development team, but in a nutshell I believe there are a number of ways you can include custom attributes with the application traces that can be queried to find telemetry based on those attributes. These can include global metadata such as via NEW_RELIC_METADATA_* environment variables, custom attributes and metrics selectively applied to transactions and segments as needed, and custom labels.