Skip to content
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

Extend a set of options in WriteOption to allow defining the log location as custom project, folder, org or billing account #684

Closed
minherz opened this issue Sep 24, 2021 · 1 comment · Fixed by #727
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API. lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@minherz
Copy link
Contributor

minherz commented Sep 24, 2021

Currently, the set of WriteOption options is limited to

enum OptionType implements Option.OptionType {
LOG_NAME,
RESOURCE,
LABELS;

and does not allow to customize log name. The location of the log is produced based on the project id which is taken from the logging client options:
String projectId = serviceOptions.getProjectId();
WriteLogEntriesRequest.Builder builder = WriteLogEntriesRequest.newBuilder();
String logName = LOG_NAME.get(options);
if (logName != null) {
builder.setLogName(LogName.ofProjectLogName(projectId, logName).toString());
}

This project id is retrieved from authentication workflow and is not necessary the same with the needed log destination. There also cases when the destination should be other than a project

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Sep 24, 2021
@minherz minherz assigned minherz and unassigned simonz130 Sep 24, 2021
@minherz minherz added lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 24, 2021
@minherz
Copy link
Contributor Author

minherz commented Sep 24, 2021

The implementation should be similar to TailOption. However, there should be a constraint to provide only one option among project, folder, org and billing_acc ids.
Also it worth to add tests that will validate the log name constraints:

  • [LOG_NAME] must be URL-encoded
  • [LOG_NAME] must be less than 512 characters long and can only include the following characters: upper and lower case alphanumeric characters, forward-slash, underscore, hyphen, and period.
  • [LOG_NAME] must NOT start with forward-slash
  • [PROJECT] must be less than or equal than 30 characters long and can only include the following characters: lowercase letters, numbers, and hyphens.
  • [PROJECT] must start with a letter, cannot end with a hyphen and cannot contain restricted strings, such as google and ssl.
  • [FOLDER] and [ORGANIZATION] can only include numeric characters.
  • [BILLINGACCOUNT] must follow XXXXXX-XXXXXX-XXXXXX pattern where X can be lower case alphanumeric characters.

It can be a good idea to extend the above validation to other *Option values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
3 participants