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

support truncating sourcemap lines #5033

Closed

Conversation

stuartnelson3
Copy link
Contributor

@stuartnelson3 stuartnelson3 commented Mar 29, 2021

Motivation/summary

User-requested feature to limit the line length for returned sourcemaps, as excessively long lines were OOM'ing coordinating nodes.

closes #4149

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

Start a copy of APM server with the source_mapping.max_line_length set to something small. Confirm that when viewing lines, they've been truncated.

Related issues

@@ -240,6 +240,10 @@ apm-server:
# Sourcemapping is enabled by default.
#enabled: true

# Maximum allowed line length in characters. Default maximum line length
# is unlimited, indicated by `0`. Minimum allowed value is 16.
#max_line_length: 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are these options listed elsewhere and the apm-server.yml files generated? or do I add this to e.g. apm-server.docker.yml as well?

Copy link
Member

Choose a reason for hiding this comment

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

Both apm-server.yml and apm-server.docker.yml are generated from _meta/beat.yml. Edit that one and run make update (or just make config).

Cache: &Cache{Expiration: defaultSourcemapCacheExpiration},
IndexPattern: defaultSourcemapIndexPattern,
ESConfig: elasticsearch.DefaultConfig(),
MaxLineLength: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 indicates "no maximum"

Copy link
Member

Choose a reason for hiding this comment

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

maybe add a doc comment to the struct field?

@apmmachine
Copy link
Contributor

apmmachine commented Mar 29, 2021

💔 Tests Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #5033 updated

  • Start Time: 2021-03-30T08:45:52.056+0000

  • Duration: 54 min 12 sec

  • Commit: 7bd6ffb

Test stats 🧪

Test Results
Failed 60
Passed 6222
Skipped 120
Total 6402

Trends 🧪

Image of Build Times

Image of Tests

Test errors 60

Expand to view the tests failures

> Show only the first 10 test failures

Build and Test / System and Environment Tests / test_cache_full – tests.system.test_auth.TestAPIKeyCache
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     self = <test_auth.TestAPIKeyCache testMethod=test_cache_full>
    
        def setUp(self):
            # application
            self.application = "apm"
        
            # apm privileges
            self.privilege_agent_config = "config_agent:read"
            self.privilege_event = "event:write"
            self.privilege_sourcemap = "sourcemap:write"
            self.privileges = {
                "agentConfig": self.privilege_agent_config,
                "event": self.privilege_event,
                "sourcemap": self.privilege_sourcemap
            }
            self.privileges_all = list(self.privileges.values())
            self.privilege_any = "*"
        
            # resources
            self.resource_any = ["*"]
            self.resource_backend = ["-"]
        
            user = os.getenv("ES_USER", "apm_server_user")
            password = os.getenv("ES_PASS", "changeme")
            self.apikey_name = "apm-systemtest"
            self.apikey = APIKeyHelper(self.get_elasticsearch_url(user, password))
        
            # delete all existing api_keys with defined name of current user
            self.apikey.invalidate(self.apikey_name)
            # delete all existing application privileges to ensure they can be created for current user
            for p in self.privileges.keys():
                url = "{}/{}/{}".format(self.apikey.privileges_url, self.application, p)
                requests.delete(url)
                wait_until(lambda: requests.get(url).status_code == 404)
        
    >       super(APIKeyBaseTest, self).setUp()
    
    tests/system/test_auth.py:80: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfc2bba8>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_backend_intake – tests.system.test_auth.TestAPIKeyWithInvalidESConfig
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     self = <test_auth.TestAPIKeyWithInvalidESConfig testMethod=test_backend_intake>
    
        def setUp(self):
            # application
            self.application = "apm"
        
            # apm privileges
            self.privilege_agent_config = "config_agent:read"
            self.privilege_event = "event:write"
            self.privilege_sourcemap = "sourcemap:write"
            self.privileges = {
                "agentConfig": self.privilege_agent_config,
                "event": self.privilege_event,
                "sourcemap": self.privilege_sourcemap
            }
            self.privileges_all = list(self.privileges.values())
            self.privilege_any = "*"
        
            # resources
            self.resource_any = ["*"]
            self.resource_backend = ["-"]
        
            user = os.getenv("ES_USER", "apm_server_user")
            password = os.getenv("ES_PASS", "changeme")
            self.apikey_name = "apm-systemtest"
            self.apikey = APIKeyHelper(self.get_elasticsearch_url(user, password))
        
            # delete all existing api_keys with defined name of current user
            self.apikey.invalidate(self.apikey_name)
            # delete all existing application privileges to ensure they can be created for current user
            for p in self.privileges.keys():
                url = "{}/{}/{}".format(self.apikey.privileges_url, self.application, p)
                requests.delete(url)
                wait_until(lambda: requests.get(url).status_code == 404)
        
    >       super(APIKeyBaseTest, self).setUp()
    
    tests/system/test_auth.py:80: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfbf50b8>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_backend_intake – tests.system.test_auth.TestAPIKeyWithESConfig
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     self = <test_auth.TestAPIKeyWithESConfig testMethod=test_backend_intake>
    
        def setUp(self):
            # application
            self.application = "apm"
        
            # apm privileges
            self.privilege_agent_config = "config_agent:read"
            self.privilege_event = "event:write"
            self.privilege_sourcemap = "sourcemap:write"
            self.privileges = {
                "agentConfig": self.privilege_agent_config,
                "event": self.privilege_event,
                "sourcemap": self.privilege_sourcemap
            }
            self.privileges_all = list(self.privileges.values())
            self.privilege_any = "*"
        
            # resources
            self.resource_any = ["*"]
            self.resource_backend = ["-"]
        
            user = os.getenv("ES_USER", "apm_server_user")
            password = os.getenv("ES_PASS", "changeme")
            self.apikey_name = "apm-systemtest"
            self.apikey = APIKeyHelper(self.get_elasticsearch_url(user, password))
        
            # delete all existing api_keys with defined name of current user
            self.apikey.invalidate(self.apikey_name)
            # delete all existing application privileges to ensure they can be created for current user
            for p in self.privileges.keys():
                url = "{}/{}/{}".format(self.apikey.privileges_url, self.application, p)
                requests.delete(url)
                wait_until(lambda: requests.get(url).status_code == 404)
        
    >       super(APIKeyBaseTest, self).setUp()
    
    tests/system/test_auth.py:80: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfc4b748>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_load_docs_with_template_and_add_error – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2df998f60>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_load_docs_with_template_and_add_metricset – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfc24d30>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_load_docs_with_template_and_add_transaction – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfd765f8>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_mark_type – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfb80160>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_tags_type – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfced438>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_template – tests.system.test_integration.Test
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfa22748>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Build and Test / System and Environment Tests / test_backend_error – tests.system.test_integration.EnrichEventIntegrationTest
    Expand to view the error details

     TypeError: string indices must be integers 
    

    Expand to view the stacktrace

     tests/system/apmserver.py:256: in setUp
        self.kibana.delete_all_agent_config()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <kibana.Kibana object at 0x7fc2dfcf2358>
    
        def delete_all_agent_config(self):
            configs = self.list_agent_config()
            for config in configs:
    >           service = config["service"]
    E           TypeError: string indices must be integers
    
    tests/system/kibana.py:50: TypeError 
    

Steps errors 3

Expand to view the steps failures

Run Window tests
  • Took 11 min 24 sec . View more details on here
Run Linux tests
  • Took 14 min 5 sec . View more details on here
  • Description: ./.ci/scripts/linux-test.sh
Test Sync
  • Took 4 min 31 sec . View more details on here
  • Description: ./.ci/scripts/sync.sh

Log output

Expand to view the last 100 lines of log output

[2021-03-30T09:37:18.163Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86.zip.sha512
[2021-03-30T09:37:18.273Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86_64.zip
[2021-03-30T09:37:19.627Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86_64.zip.sha512
[2021-03-30T09:37:19.678Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-x86_64.rpm
[2021-03-30T09:37:21.293Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-x86_64.rpm.sha512
[2021-03-30T09:37:21.340Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-aarch64.rpm
[2021-03-30T09:37:22.511Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-aarch64.rpm.sha512
[2021-03-30T09:37:22.560Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-amd64.deb
[2021-03-30T09:37:23.936Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-amd64.deb.sha512
[2021-03-30T09:37:23.992Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-arm64.deb
[2021-03-30T09:37:25.231Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-arm64.deb.sha512
[2021-03-30T09:37:25.279Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz
[2021-03-30T09:37:26.823Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz.sha512
[2021-03-30T09:37:26.872Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i386.deb
[2021-03-30T09:37:28.170Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i386.deb.sha512
[2021-03-30T09:37:28.215Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i686.rpm
[2021-03-30T09:37:29.423Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i686.rpm.sha512
[2021-03-30T09:37:29.618Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz
[2021-03-30T09:37:36.379Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz.sha512
[2021-03-30T09:37:36.435Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-arm64.tar.gz
[2021-03-30T09:37:37.595Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-arm64.tar.gz.sha512
[2021-03-30T09:37:37.675Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86.tar.gz
[2021-03-30T09:37:38.932Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86.tar.gz.sha512
[2021-03-30T09:37:39.005Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86_64.tar.gz
[2021-03-30T09:37:40.366Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86_64.tar.gz.sha512
[2021-03-30T09:37:40.428Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86.zip
[2021-03-30T09:37:41.488Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86.zip.sha512
[2021-03-30T09:37:41.545Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86_64.zip
[2021-03-30T09:37:42.753Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86_64.zip.sha512
[2021-03-30T09:37:42.839Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-x86_64.rpm
[2021-03-30T09:37:44.139Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-x86_64.rpm.sha512
[2021-03-30T09:37:44.204Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-ubi8-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz
[2021-03-30T09:37:47.843Z] [INFO] Override default googleStorageUpload with some sleep
[2021-03-30T09:37:47.866Z] Sleeping for 1 min 22 sec
[2021-03-30T09:37:47.750Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-ubi8-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz.sha512
[2021-03-30T09:39:09.905Z] Warning: A secret was passed to "googleStorageUpload" using Groovy String interpolation, which is insecure.
[2021-03-30T09:39:09.907Z] 		 Affected argument(s) used the following variable(s): [JOB_GCS_BUCKET]
[2021-03-30T09:39:09.907Z] 		 See https://jenkins.io/redirect/groovy-string-interpolation for details.
[2021-03-30T09:39:09.942Z] [Google Cloud Storage Plugin] Found 54 files to upload from pattern: src/github.com/elastic/apm-server/build/distributions/**/*
[2021-03-30T09:39:10.105Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-aarch64.rpm
[2021-03-30T09:39:11.627Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-aarch64.rpm.sha512
[2021-03-30T09:39:11.724Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-amd64.deb
[2021-03-30T09:39:13.300Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-amd64.deb.sha512
[2021-03-30T09:39:13.392Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-arm64.deb
[2021-03-30T09:39:14.798Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-arm64.deb.sha512
[2021-03-30T09:39:14.860Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz
[2021-03-30T09:39:16.526Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz.sha512
[2021-03-30T09:39:16.609Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-i386.deb
[2021-03-30T09:39:18.080Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-i386.deb.sha512
[2021-03-30T09:39:18.150Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-i686.rpm
[2021-03-30T09:39:19.605Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-i686.rpm.sha512
[2021-03-30T09:39:19.666Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz
[2021-03-30T09:39:26.662Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz.sha512
[2021-03-30T09:39:26.763Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-arm64.tar.gz
[2021-03-30T09:39:28.141Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-arm64.tar.gz.sha512
[2021-03-30T09:39:28.195Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-x86.tar.gz
[2021-03-30T09:39:29.664Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-x86.tar.gz.sha512
[2021-03-30T09:39:29.737Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-x86_64.tar.gz
[2021-03-30T09:39:31.302Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-linux-x86_64.tar.gz.sha512
[2021-03-30T09:39:31.356Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86.zip
[2021-03-30T09:39:32.648Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86.zip.sha512
[2021-03-30T09:39:32.717Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86_64.zip
[2021-03-30T09:39:34.039Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-windows-x86_64.zip.sha512
[2021-03-30T09:39:34.122Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-x86_64.rpm
[2021-03-30T09:39:35.656Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-8.0.0-SNAPSHOT-x86_64.rpm.sha512
[2021-03-30T09:39:35.741Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-aarch64.rpm
[2021-03-30T09:39:36.921Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-aarch64.rpm.sha512
[2021-03-30T09:39:37.048Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-amd64.deb
[2021-03-30T09:39:38.454Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-amd64.deb.sha512
[2021-03-30T09:39:38.520Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-arm64.deb
[2021-03-30T09:39:39.783Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-arm64.deb.sha512
[2021-03-30T09:39:39.919Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz
[2021-03-30T09:39:41.314Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz.sha512
[2021-03-30T09:39:41.372Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i386.deb
[2021-03-30T09:39:42.667Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i386.deb.sha512
[2021-03-30T09:39:42.942Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i686.rpm
[2021-03-30T09:39:44.281Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-i686.rpm.sha512
[2021-03-30T09:39:44.365Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz
[2021-03-30T09:39:51.266Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz.sha512
[2021-03-30T09:39:51.319Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-arm64.tar.gz
[2021-03-30T09:39:52.507Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-arm64.tar.gz.sha512
[2021-03-30T09:39:52.565Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86.tar.gz
[2021-03-30T09:39:53.793Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86.tar.gz.sha512
[2021-03-30T09:39:53.843Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86_64.tar.gz
[2021-03-30T09:39:55.165Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-linux-x86_64.tar.gz.sha512
[2021-03-30T09:39:55.211Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86.zip
[2021-03-30T09:39:56.188Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86.zip.sha512
[2021-03-30T09:39:56.257Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86_64.zip
[2021-03-30T09:39:57.302Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-windows-x86_64.zip.sha512
[2021-03-30T09:39:57.597Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-x86_64.rpm
[2021-03-30T09:39:58.892Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-oss-8.0.0-SNAPSHOT-x86_64.rpm.sha512
[2021-03-30T09:39:58.987Z] [Google Cloud Storage Plugin] Uploading: src/github.com/elastic/apm-server/build/distributions/apm-server-ubi8-8.0.0-SNAPSHOT-linux-amd64.docker.tar.gz
[2021-03-30T09:40:03.156Z] Running on Jenkins in /var/lib/jenkins/workspace/pm-server_apm-server-mbp_PR-5033
[2021-03-30T09:40:03.222Z] [INFO] getVaultSecret: Getting secrets
[2021-03-30T09:40:03.457Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-03-30T09:40:04.295Z] + chmod 755 generate-build-data.sh
[2021-03-30T09:40:04.296Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-server/apm-server-mbp/PR-5033/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-server/apm-server-mbp/PR-5033/runs/3 FAILURE 3251956
[2021-03-30T09:40:04.846Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-server/apm-server-mbp/PR-5033/runs/3/steps/?limit=10000 -o steps-info.json
[2021-03-30T09:40:05.397Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-server/apm-server-mbp/PR-5033/runs/3/tests/?status=FAILED -o tests-errors.json
[2021-03-30T09:40:05.948Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-server/apm-server-mbp/PR-5033/runs/3/log/ -o pipeline-log.txt

const (
sourcemapContentSnippetSize = 5
// TODO: What value do we want here?
minMaxLineLength = 16
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm assuming 16 is much smaller than we want, it was just convenient for testing.

Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for having a minimum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems kind of silly if someone limits the output to 1 character, for example. But, I'm also happy to delete it.


// limitScanLines is a modified form of bufio.ScanLines. It truncates any lines
// longer than the supplied `max` value.
func limitScanLines(max int) func([]byte, bool) (int, []byte, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly copy and paste. I'm happy to remove this and just re-slice scanner.Text() above, but i figured if we're trying to avoid allocations, why not try to avoid allocations. (scanner.Text() allocates a new string)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think I understand how this would help. We're still calling scanner.Text() in Map above anyway, and slicing it shouldn't cause any more allocations?

I think I'd prefer the simpler option of slicing, but based on runes rather than bytes for consistency with similar limits elsewhere (namely in the agents, where most fields have a 1024 character/rune limit). There's some code that can be stolen for that here:

// truncate returns s truncated at n runes, and the number of runes in the resulting string (<= n).
func truncate(s string) string {
var j int
for i := range s {
if j == keywordLength {
return s[:i]
}
j++
}
return s
}

Longer term, perhaps after #5002 is implemented, I think we might want to split (and truncate) the source map content lines just once when parsing the source map, rather than every time we apply the source map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it won't decrease the number of allocations, but I guess they'd potentially be smaller (which probably isn't much of a win).

@stuartnelson3 stuartnelson3 requested a review from a team March 29, 2021 14:53
@stuartnelson3
Copy link
Contributor Author

This is a possible solution, but I'm happy to hear alternate suggestions. I like how this impl is using the api and setting Split(), but it is mostly copying bufio.SplitLines, which is less cool.

I haven't tested this manually (or written a system test). Maybe I can steal someone for 15min tomorrow after standup and we can go through how to do this (upload a sourcemap and then view it in the UI).

Comment on lines 65 to 66
// TODO: uint? uint64? Or do we not care and just use an int?
MaxLineLength uint `config:"max_line_length"`
Copy link
Member

Choose a reason for hiding this comment

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

not too fussed, but I'd probably go int since it's usually easier to work with and setting huge limits isn't sensible

Cache: &Cache{Expiration: defaultSourcemapCacheExpiration},
IndexPattern: defaultSourcemapIndexPattern,
ESConfig: elasticsearch.DefaultConfig(),
MaxLineLength: 0,
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a doc comment to the struct field?

@@ -240,6 +240,10 @@ apm-server:
# Sourcemapping is enabled by default.
#enabled: true

# Maximum allowed line length in characters. Default maximum line length
# is unlimited, indicated by `0`. Minimum allowed value is 16.
#max_line_length: 0
Copy link
Member

Choose a reason for hiding this comment

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

Both apm-server.yml and apm-server.docker.yml are generated from _meta/beat.yml. Edit that one and run make update (or just make config).

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Looks fine overall, though I'd prefer to simplify the truncation code.

I'm a little unclear on what triggered the OOM in the reported issue. Initially I thought it was about the length of lines in the source map itself, but in #4143 the author is only limiting the length of the source lines added to stack trace frames -- like you are here.

It would be good if you could try to reproduce the failure by indexing error events with very long source context lines. You might be able to simulate this by using the Go agent, passing in a custom stacktrace.ContextSetter to https://pkg.go.dev/go.elastic.co/apm#Tracer.SetContextSetter and capturing an error.


// limitScanLines is a modified form of bufio.ScanLines. It truncates any lines
// longer than the supplied `max` value.
func limitScanLines(max int) func([]byte, bool) (int, []byte, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I understand how this would help. We're still calling scanner.Text() in Map above anyway, and slicing it shouldn't cause any more allocations?

I think I'd prefer the simpler option of slicing, but based on runes rather than bytes for consistency with similar limits elsewhere (namely in the agents, where most fields have a 1024 character/rune limit). There's some code that can be stolen for that here:

// truncate returns s truncated at n runes, and the number of runes in the resulting string (<= n).
func truncate(s string) string {
var j int
for i := range s {
if j == keywordLength {
return s[:i]
}
j++
}
return s
}

Longer term, perhaps after #5002 is implemented, I think we might want to split (and truncate) the source map content lines just once when parsing the source map, rather than every time we apply the source map.

const (
sourcemapContentSnippetSize = 5
// TODO: What value do we want here?
minMaxLineLength = 16
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for having a minimum?

assert.False(t, ok)
}

func TestMapNoMatch(t *testing.T) {
m, err := sourcemap.Parse("", []byte(test.ValidSourcemap))
require.NoError(t, err)
assert.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

why changing to assert? Running the tests if the parsing failed doesn't make much sense and would probably just lead to confusing errors (hiding the original issue). Similar for other changes below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah sorry, just my OCD. I'll change them back

@stuartnelson3
Copy link
Contributor Author

closing this for now. it doesn't solve the problem, and I haven't been able to reproduce the issue.

@stuartnelson3 stuartnelson3 deleted the sourcemap-length-limit branch March 31, 2021 09:14
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.

limit sourcemap line length
4 participants