awslabs / awslabs/aws-embedded-metrics-java

Validate Namespace Does Not Allow Whitespace, Which Is Allowed by EMF Spec

Open
#158 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
48
Forks
39
PR merge metrics
No merged PRs in 30d

Description

The [Validator#validateNamespace](https://github.com/awslabs/aws-embedded-metrics-java/blob/master/src/main/java/software/amazon/cloudwatchlogs/emf/util/Validator.java#L150) function uses [the regex](https://github.com/awslabs/aws-embedded-metrics-java/blob/master/src/main/java/software/amazon/cloudwatchlogs/emf/Constants.java#L27) `^[a-zA-Z0-9._#:/-]+$`, which does not allow whitespace in namespaces.

However, per [CloudWatch docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace):
> Possible [namespace] characters are: alphanumeric characters (0-9A-Za-z), period (.), hyphen (-), underscore (_), forward slash (/), hash (#), colon (:), and the space character.

Changing this to `^[a-zA-Z0-9 ._#:/-]+$` would solve the problem.

This is an issue for me, as I am trying to upgrade an old codebase from version 1.0 to version 4.0, however we used (out of my control) a namespace with whitespace in it. To retain continuity, and not have to manually finagle with alarms, I'd like to see this changed to allow whitespace.

I can submit PR for this, but want to confirm if this deviation from CloudWatch standard was on purpose?

Contributor guide

Open the contributing guide

Research direction

Start with Validator.java at Validator#validateNamespace and the namespace regex in Constants.java. Compare the validation rule with the CloudWatch namespace characters cited in the issue, then verify that namespaces containing spaces are accepted while the existing allowed characters remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.