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

truncate strings that are stored as keywords in ES (#159) #159

Closed
wants to merge 1 commit into from

Conversation

beniwohli
Copy link
Contributor

this should avoid schema errors for values that are too long

closes #156

closes #159

beniwohli added a commit to beniwohli/apm-agent-python that referenced this pull request Feb 13, 2018
this should avoid schema errors for values that are too long

closes elastic#156

closes elastic#159
Copy link

@hmdhk hmdhk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general issue, I'd say handle checking required fields as well, I can see that you have placeholders for some fields. but that's a separated issue.

def keyword_field(string):
if not isinstance(string, compat.string_types) or len(string) <= KEYWORD_MAX_LENGTH:
return string
return string[:KEYWORD_MAX_LENGTH - 1] + u'…'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beniwohli , Adding '…' would add 3 characters to the length which might exceed 1024 limit.

A separate issue: In my opinion '...' is not necessary, I would prefer adding a property to say the name was truncated and let the ui decide about the "ellipsis", but even that I think at this stage is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The character I use there is the unicode ellipsis, so it's only one character :)

I'm not sure adding an additional field for every keyword field to indicate if it was truncated or not is feasible. Having to truncate a field should be an absolute edge case.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sorry my python is a bit rusty 😄 !

It doesn't have to be a field for every keyword field. But my point was that I would prefer not adding anything to the fields that might have a meaning in different contexts and keeping what the data was originally

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to approve the changes, then you can decide about the 'ellipsis'!

return result

def get_process_info(self):
return {
'pid': os.getpid(),
'argv': sys.argv,
'title': None,
'title': None, # Note: if we implement this, the value needs to be wrapped with keyword_field
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your note to your future self 😄 , I do that as well!

beniwohli added a commit to beniwohli/apm-agent-python that referenced this pull request Feb 14, 2018
this should avoid schema errors for values that are too long

closes elastic#156

closes elastic#159
this should avoid schema errors for values that are too long

closes elastic#156

closes elastic#159
@beniwohli beniwohli closed this in 8a486bb Feb 15, 2018
beniwohli added a commit that referenced this pull request Feb 15, 2018
this should avoid schema errors for values that are too long

closes #156

closes #159
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.

Problem validating JSON document against schema - length must be <= 1024, but got 1523
2 participants