We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[META 555] Add automated span type/subtype checking against shared spec
Spec PR: https://github.com/elastic/apm/pull/443

To start, we would just ensure that all span types/subtypes appear in the spec. In the future we will work on cross-agent alignment.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `elasticapm/instrumentation/packages/asyncio/aiopg.py`
Content:
```
1 #  BSD 3-Clause License
2 #
3 #  Copyright (c) 2019, Elasticsearch BV
4 #  All rights reserved.
5 #
6 #  Redistribution and use in source and binary forms, with or without
7 #  modification, are permitted provided that the following conditions are met:
8 #
9 #  * Redistributions of source code must retain the above copyright notice, this
10 #    list of conditions and the following disclaimer.
11 #
12 #  * Redistributions in binary form must reproduce the above copyright notice,
13 #    this list of conditions and the following disclaimer in the documentation
14 #    and/or other materials provided with the distribution.
15 #
16 #  * Neither the name of the copyright holder nor the names of its
17 #    contributors may be used to endorse or promote products derived from
18 #    this software without specific prior written permission.
19 #
20 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 #  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 #  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 #  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 #  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 #  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 #  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 from elasticapm.contrib.asyncio.traces import async_capture_span
32 from elasticapm.instrumentation.packages.asyncio.base import AsyncAbstractInstrumentedModule
33 from elasticapm.instrumentation.packages.dbapi2 import extract_signature
34 
35 
36 class AioPGInstrumentation(AsyncAbstractInstrumentedModule):
37     name = "aiopg"
38 
39     instrument_list = [
40         ("aiopg.cursor", "Cursor.execute"),
41         ("aiopg.cursor", "Cursor.callproc"),
42         ("aiopg.connection", "Cursor.execute"),
43         ("aiopg.connection", "Cursor.callproc"),
44     ]
45 
46     async def call(self, module, method, wrapped, instance, args, kwargs):
47         if method == "Cursor.execute":
48             query = args[0] if len(args) else kwargs["operation"]
49             query = _bake_sql(instance.raw, query)
50             name = extract_signature(query)
51             context = {"db": {"type": "sql", "statement": query}}
52             action = "query"
53         elif method == "Cursor.callproc":
54             func = args[0] if len(args) else kwargs["procname"]
55             name = func + "()"
56             context = None
57             action = "exec"
58         else:
59             raise AssertionError("call from uninstrumented method")
60         async with async_capture_span(
61             name, leaf=True, span_type="db", span_subtype="postgres", span_action=action, extra=context
62         ):
63             return await wrapped(*args, **kwargs)
64 
65 
66 def _bake_sql(cursor, sql):
67     # if this is a Composable object, use its `as_string` method
68     # see http://initd.org/psycopg/docs/sql.html
69     if hasattr(sql, "as_string"):
70         return sql.as_string(cursor)
71     return sql
72
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/elasticapm/instrumentation/packages/asyncio/aiopg.py b/elasticapm/instrumentation/packages/asyncio/aiopg.py
--- a/elasticapm/instrumentation/packages/asyncio/aiopg.py
+++ b/elasticapm/instrumentation/packages/asyncio/aiopg.py
@@ -58,7 +58,7 @@
         else:
             raise AssertionError("call from uninstrumented method")
         async with async_capture_span(
-            name, leaf=True, span_type="db", span_subtype="postgres", span_action=action, extra=context
+            name, leaf=True, span_type="db", span_subtype="postgresql", span_action=action, extra=context
         ):
             return await wrapped(*args, **kwargs)

{"golden_diff": "diff --git a/elasticapm/instrumentation/packages/asyncio/aiopg.py b/elasticapm/instrumentation/packages/asyncio/aiopg.py\n--- a/elasticapm/instrumentation/packages/asyncio/aiopg.py\n+++ b/elasticapm/instrumentation/packages/asyncio/aiopg.py\n@@ -58,7 +58,7 @@\n         else:\n             raise AssertionError(\"call from uninstrumented method\")\n         async with async_capture_span(\n-            name, leaf=True, span_type=\"db\", span_subtype=\"postgres\", span_action=action, extra=context\n+            name, leaf=True, span_type=\"db\", span_subtype=\"postgresql\", span_action=action, extra=context\n         ):\n             return await wrapped(*args, **kwargs)\n", "issue": "[META 555] Add automated span type/subtype checking against shared spec\nSpec PR: https://github.com/elastic/apm/pull/443\r\n\r\nTo start, we would just ensure that all span types/subtypes appear in the spec. In the future we will work on cross-agent alignment.\r\n\n", "before_files": [{"content": "#  BSD 3-Clause License\n#\n#  Copyright (c) 2019, Elasticsearch BV\n#  All rights reserved.\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are met:\n#\n#  * Redistributions of source code must retain the above copyright notice, this\n#    list of conditions and the following disclaimer.\n#\n#  * Redistributions in binary form must reproduce the above copyright notice,\n#    this list of conditions and the following disclaimer in the documentation\n#    and/or other materials provided with the distribution.\n#\n#  * Neither the name of the copyright holder nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nfrom elasticapm.contrib.asyncio.traces import async_capture_span\nfrom elasticapm.instrumentation.packages.asyncio.base import AsyncAbstractInstrumentedModule\nfrom elasticapm.instrumentation.packages.dbapi2 import extract_signature\n\n\nclass AioPGInstrumentation(AsyncAbstractInstrumentedModule):\n    name = \"aiopg\"\n\n    instrument_list = [\n        (\"aiopg.cursor\", \"Cursor.execute\"),\n        (\"aiopg.cursor\", \"Cursor.callproc\"),\n        (\"aiopg.connection\", \"Cursor.execute\"),\n        (\"aiopg.connection\", \"Cursor.callproc\"),\n    ]\n\n    async def call(self, module, method, wrapped, instance, args, kwargs):\n        if method == \"Cursor.execute\":\n            query = args[0] if len(args) else kwargs[\"operation\"]\n            query = _bake_sql(instance.raw, query)\n            name = extract_signature(query)\n            context = {\"db\": {\"type\": \"sql\", \"statement\": query}}\n            action = \"query\"\n        elif method == \"Cursor.callproc\":\n            func = args[0] if len(args) else kwargs[\"procname\"]\n            name = func + \"()\"\n            context = None\n            action = \"exec\"\n        else:\n            raise AssertionError(\"call from uninstrumented method\")\n        async with async_capture_span(\n            name, leaf=True, span_type=\"db\", span_subtype=\"postgres\", span_action=action, extra=context\n        ):\n            return await wrapped(*args, **kwargs)\n\n\ndef _bake_sql(cursor, sql):\n    # if this is a Composable object, use its `as_string` method\n    # see http://initd.org/psycopg/docs/sql.html\n    if hasattr(sql, \"as_string\"):\n        return sql.as_string(cursor)\n    return sql\n", "path": "elasticapm/instrumentation/packages/asyncio/aiopg.py"}], "after_files": [{"content": "#  BSD 3-Clause License\n#\n#  Copyright (c) 2019, Elasticsearch BV\n#  All rights reserved.\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are met:\n#\n#  * Redistributions of source code must retain the above copyright notice, this\n#    list of conditions and the following disclaimer.\n#\n#  * Redistributions in binary form must reproduce the above copyright notice,\n#    this list of conditions and the following disclaimer in the documentation\n#    and/or other materials provided with the distribution.\n#\n#  * Neither the name of the copyright holder nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nfrom elasticapm.contrib.asyncio.traces import async_capture_span\nfrom elasticapm.instrumentation.packages.asyncio.base import AsyncAbstractInstrumentedModule\nfrom elasticapm.instrumentation.packages.dbapi2 import extract_signature\n\n\nclass AioPGInstrumentation(AsyncAbstractInstrumentedModule):\n    name = \"aiopg\"\n\n    instrument_list = [\n        (\"aiopg.cursor\", \"Cursor.execute\"),\n        (\"aiopg.cursor\", \"Cursor.callproc\"),\n        (\"aiopg.connection\", \"Cursor.execute\"),\n        (\"aiopg.connection\", \"Cursor.callproc\"),\n    ]\n\n    async def call(self, module, method, wrapped, instance, args, kwargs):\n        if method == \"Cursor.execute\":\n            query = args[0] if len(args) else kwargs[\"operation\"]\n            query = _bake_sql(instance.raw, query)\n            name = extract_signature(query)\n            context = {\"db\": {\"type\": \"sql\", \"statement\": query}}\n            action = \"query\"\n        elif method == \"Cursor.callproc\":\n            func = args[0] if len(args) else kwargs[\"procname\"]\n            name = func + \"()\"\n            context = None\n            action = \"exec\"\n        else:\n            raise AssertionError(\"call from uninstrumented method\")\n        async with async_capture_span(\n            name, leaf=True, span_type=\"db\", span_subtype=\"postgresql\", span_action=action, extra=context\n        ):\n            return await wrapped(*args, **kwargs)\n\n\ndef _bake_sql(cursor, sql):\n    # if this is a Composable object, use its `as_string` method\n    # see http://initd.org/psycopg/docs/sql.html\n    if hasattr(sql, \"as_string\"):\n        return sql.as_string(cursor)\n    return sql\n", "path": "elasticapm/instrumentation/packages/asyncio/aiopg.py"}]}