Skip to content

feat: Normalise environment string captured by app info package #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

i-like-robots
Copy link
Contributor

The FT may use multiple values across different platforms to indicate the environment that an app is running in. For example, AWS resources may be assigned an environment variable named ENVIRONMENT and the value "p" which is short for "production".

Follows #1112 (specifically this comment)

@i-like-robots i-like-robots force-pushed the matth/normalise-environment branch from 3c196aa to 89146fc Compare March 26, 2025 11:25
The FT may use multiple values across different platforms to indicate
the environment that an app is running in. For example, AWS resources
may be assigned an environment variable named ENVIRONMENT with the
value "p" which is short for "production".
@i-like-robots i-like-robots force-pushed the matth/normalise-environment branch from 89146fc to e6f8cbd Compare March 26, 2025 11:27
@rowanmanning
Copy link
Member

Been thinking about this properly and I wonder whether this is a breaking change? We're currently doing no validation based on this and so it's possible systems have their own checks like appInfo.environment === 'p'. In the interest of fixing your specific issue I think there are a few options:

  1. Add a new property to appInfo called normalizedEnvironment or similar and migrate to using this across the rest of the Reliability Kit packages. I don't love this because we're adding a maintenance overhead and I'd rather environment just be normalised.

  2. Update the check within logger itself to search for production, prod, or p here. This would fix the immediate issue in the specific package you're having trouble with at the expense of a little more complexity.

  3. Suck up the breaking change. I'm happy to do this however I'd like to lump in a few more changes, e.g. @sjparkinson is keen for us to rely on OpenTelemetry resource detectors for some of this stuff and appInfo is kind of due a bit of a rethink. So this option will take longer.

@sjparkinson
Copy link
Contributor

Little bit tangental, but in my thinking on this I've felt that there's a missing attribute needed in order to allow us to normalise the deployment environment values (which I'd love to do). Something like deployment.environment_id so that you can still distinguish between different test environments or review apps etc.

@sjparkinson
Copy link
Contributor

Oh looks like the deployment.environment attribute is being renamed too: https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/

Which does sort of leave room for a ID attribute or something.

@i-like-robots
Copy link
Contributor Author

Been thinking about this properly and I wonder whether this is a breaking change?

If the property is a documented part of a public interface then I reckon this must be a breaking change 👍

Update the check within logger itself to search for production, prod, or p

This would resolve the issue we're having. As production/prod/p is as close to a standard as we get at the FT I assume this change would help implementors towards the expected behaviour and not be surprising.

Suck up the breaking change. I'm happy to do this however I'd like to lump in a few more changes

Then perhaps we do go for the above and a major version bump is saved for adding lots of value for people to upgrade to.

@rowanmanning
Copy link
Member

OK cool 👍 then we'll do the following:

  • @i-like-robots we'll get the logger to work with different production-like environments. I can do it tomorrow or feel free to PR it yourself if you have time!

  • @sjparkinson I feel like we should talk about what ideal looks like for the app-info package. I don't know if we'll ever be able to rely fully on the OpenTelemetry resource detectors because we have lots of FT-specific stuff like the SYSTEM_CODE environment variable. Maybe standardising this stuff would be a useful piece of work? Then we can adopt whatever standard in the next major version of this package

rowanmanning added a commit that referenced this pull request Mar 27, 2025
This disables log prettification if the environment is either `prod` or
`p`, which we use across some systems. This is done in the logger rather
than app-info because that would be a breaking change. If app-info
normalises the environment in a later version then we can switch logger
back to expecting `production` only.

Co-Authored-By: Matt Hinchliffe <i-like-robots@users.noreply.github.com>
See-also: #1368
@rowanmanning
Copy link
Member

Closing in favour of #1373

rowanmanning added a commit that referenced this pull request Mar 27, 2025
This disables log prettification if the environment is either `prod` or
`p`, which we use across some systems. This is done in the logger rather
than app-info because that would be a breaking change. If app-info
normalises the environment in a later version then we can switch logger
back to expecting `production` only.

Co-Authored-By: Matt Hinchliffe <i-like-robots@users.noreply.github.com>
See-also: #1368
rowanmanning added a commit that referenced this pull request Mar 27, 2025
This disables log prettification if the environment is either `prod` or
`p`, which we use across some systems. This is done in the logger rather
than app-info because that would be a breaking change. If app-info
normalises the environment in a later version then we can switch logger
back to expecting `production` only.

Co-Authored-By: Matt Hinchliffe <i-like-robots@users.noreply.github.com>
See-also: #1368
rowanmanning added a commit that referenced this pull request Mar 27, 2025
This disables log prettification if the environment is either `prod` or
`p`, which we use across some systems. This is done in the logger rather
than app-info because that would be a breaking change. If app-info
normalises the environment in a later version then we can switch logger
back to expecting `production` only.

Co-Authored-By: Matt Hinchliffe <i-like-robots@users.noreply.github.com>
See-also: #1368
@next-team next-team mentioned this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants