diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/cgroup_parsing.json b/test/Elastic.Apm.Tests/TestResources/json-specs/cgroup_parsing.json new file mode 100644 index 000000000..f28d87d4c --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/cgroup_parsing.json @@ -0,0 +1,22 @@ +{ + "testUnderscores": { + "groupLine": "1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod90d81341_92de_11e7_8cf2_507b9d4141fa.slice/crio-2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63.scope", + "containerId": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63", + "podId": "90d81341-92de-11e7-8cf2-507b9d4141fa" + }, + "testOpenshiftForm": { + "groupLine": "9:freezer:/kubepods.slice/kubepods-pod22949dce_fd8b_11ea_8ede_98f2b32c645c.slice/docker-b15a5bdedd2e7645c3be271364324321b908314e4c77857bbfd32a041148c07f.scope", + "containerId": "b15a5bdedd2e7645c3be271364324321b908314e4c77857bbfd32a041148c07f", + "podId": "22949dce-fd8b-11ea-8ede-98f2b32c645c" + }, + "testUbuntuCGroup": { + "groupLine": "1:name=systemd:/user.slice/user-1000.slice/user@1000.service/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-75bc72bd-6642-4cf5-b62c-0674e11bfc84.scope", + "containerId": null, + "podId": null + }, + "testAwsEcsCGroup": { + "groupLine": "1:name=systemd:/ecs/03752a671e744971a862edcee6195646/03752a671e744971a862edcee6195646-4015103728", + "containerId": "03752a671e744971a862edcee6195646-4015103728", + "podId": null + } +} diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/service_resource_inference.json b/test/Elastic.Apm.Tests/TestResources/json-specs/service_resource_inference.json new file mode 100644 index 000000000..e5ced98a3 --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/service_resource_inference.json @@ -0,0 +1,289 @@ +[ + { + "span": { + "exit": "true", + "type": "custom", + "subtype": "test-subtype" + }, + "expected_resource": "test-subtype", + "expected_service_target": { + "type": "test-subtype" + }, + "failure_message": "In the absence of specific context fields, subtype should used" + }, + { + "span": { + "exit": "true", + "type": "custom", + "subtype": "test-subtype", + "context": { + "service": { + "target": { + "type": "custom-service-type", + "name": "custom-service-name" + } + } + } + }, + "expected_resource": "custom-service-type/custom-service-name", + "expected_service_target": { + "type": "custom-service-type", + "name": "custom-service-name" + }, + "failure_message": "If the `service target type or name` is already set, the inference mechanism should not override it" + }, + { + "span": { + "exit": "true", + "type": "custom" + }, + "expected_resource": "custom", + "expected_service_target": { + "type": "custom" + }, + "failure_message": "In the absence of specific context fields and absence of subtype, the type should be used" + }, + { + "span": { + "exit": "false", + "type": "custom", + "subtype": "test-subtype" + }, + "expected_resource": null, + "expected_service_target": null, + "failure_message": "The output for non-exit spans should be `null`" + }, + { + "span": { + "exit": "false", + "type": "custom", + "subtype": "proprietary-db", + "context": { + "db": { + "instance": "myInstance" + } + } + }, + "expected_resource": null, + "expected_service_target": null, + "failure_message": "The output for non-exit spans should be `null` even if exit-related context data is set" + }, + { + "span": { + "exit": "true", + "type": "db", + "subtype": "mysql", + "context": { + "db": { + "instance": "myInstance" + } + } + }, + "expected_resource": "mysql/myInstance", + "expected_service_target": { + "type": "mysql", + "name": "myInstance" + }, + "failure_message": "If `context.db.instance` exists, the output should be: `${subtype}/${context.db.instance}`" + }, + { + "span": { + "exit": "true", + "type": "db", + "subtype": "mysql", + "context": { + "db": { + "type": "sql" + } + } + }, + "expected_resource": "mysql", + "expected_service_target": { + "type": "mysql" + }, + "failure_message": "If `context.db` exists without `context.db.instance`, the subtype should be used" + }, + { + "span": { + "exit": "true", + "type": "db", + "context": { + "db": { + "instance": "myInstance" + } + } + }, + "expected_resource": "db/myInstance", + "expected_service_target": { + "type": "db", + "name": "myInstance" + }, + "failure_message": "If `context.db.instance` exists and subtype is `null`, the output should be: `${type}/${context.db.instance}`" + }, + { + "span": { + "exit": "true", + "type": "db", + "subtype": "elasticsearch", + "context": { + "db": { + "type": "elasticsearch" + }, + "http": { + "url": { + "host": "my-cluster.com", + "port": 9200 + } + } + } + }, + "expected_resource": "elasticsearch", + "expected_service_target": { + "type": "elasticsearch" + }, + "failure_message": "If `context.db` exists without `context.db.instance`, the subtype should be used, even if `context.http` exists" + }, + { + "span": { + "exit": "true", + "type": "messaging", + "subtype": "msg-http-client", + "context": { + "message": { + "body": "Text message" + }, + "http": { + "url": { + "host": "my-broker.com", + "port": 8888 + } + } + } + }, + "expected_resource": "msg-http-client", + "expected_service_target": { + "type": "msg-http-client" + }, + "failure_message": "If `context.message` exists without `context.message.queue.name`, the subtype should be used, even if `context.http` exists" + }, + { + "span": { + "exit": "true", + "type": "external", + "subtype": "http", + "context": { + "http": { + "url": { + "host": "my-cluster.com", + "port": 9200 + } + } + } + }, + "expected_resource": "my-cluster.com:9200", + "expected_service_target": { + "type": "http", + "name": "my-cluster.com:9200" + }, + "failure_message": "If `context.http.url` exists, output should be `${context.http.url.host}:${context.http.url.port}" + }, + { + "span": { + "exit": "true", + "type": "external", + "subtype": "http", + "context": { + "http": { + "url": { + "host": "my-cluster.com", + "port": -1 + } + } + } + }, + "expected_resource": "my-cluster.com", + "expected_service_target": { + "type": "http", + "name": "my-cluster.com" + }, + "failure_message": "Negative `context.http.url.port` should be omitted from output" + }, + { + "span": { + "exit": "true", + "type": "external", + "subtype": "http", + "context": { + "http": { + "url": { + "host": "my-cluster.com" + } + } + } + }, + "expected_resource": "my-cluster.com", + "expected_service_target": { + "type": "http", + "name": "my-cluster.com" + }, + "failure_message": "If `context.http.url.port` does not exist, output should be `${context.http.url.host}`" + }, + { + "span": { + "exit": "true", + "type": "messaging", + "context": { + "message": { + "body": "Text message", + "queue": { + "name": "myQueue" + } + } + } + }, + "expected_resource": "messaging/myQueue", + "expected_service_target": { + "type": "messaging", + "name": "myQueue" + }, + "failure_message": "If `context.message` exists, and subtype is `null`, output should be `${type}/${context.message.queue.name}" + }, + { + "span": { + "exit": "true", + "type": "messaging", + "subtype": "kafka", + "context": { + "message": { + "body": "Text message", + "queue": { + "name": "myQueue" + } + } + } + }, + "expected_resource": "kafka/myQueue", + "expected_service_target": { + "type": "kafka", + "name": "myQueue" + }, + "failure_message": "If `context.message` exists, output should be `${subtype}/${context.message.queue.name}" + }, + { + "span": { + "exit": "true", + "type": "messaging", + "subtype": "kafka", + "context": { + "message": { + "body": "Text message" + } + } + }, + "expected_resource": "kafka", + "expected_service_target": { + "type": "kafka" + }, + "failure_message": "If `context.message` exists without `context.message.queue.name`, output should be `${subtype}`" + } +] diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/span_types.json b/test/Elastic.Apm.Tests/TestResources/json-specs/span_types.json new file mode 100644 index 000000000..aa6e47f56 --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/span_types.json @@ -0,0 +1,338 @@ +{ + "__description": { + "": "root element for type identified by ''", + ".__description": "description for '' (optional)", + ".__used_by": "list of agents that use '' to help document alignment (optional)", + ".allow_null_subtype": "true to allow null subtype, false by default if omitted", + ".allow_unlisted_subtype": "true to allow unlisted subtypes, false by default if omitted", + ".subtypes": "root element for sub-types of type '', if omitted or empty subtype must be null, unless 'allow_unlisted_subtype' is set to true", + ".subtypes.": "sub-type element for ", + ".subtypes..__description": "description of subtype (optional)", + ".subtypes..__used_by": "list of agents that use to help document alignment (optional)" + }, + "app": { + "__description": "Spans within application (usually not calling an external system)", + "allow_null_subtype": true, + "subtypes": { + "inferred": { + "__description": "Sampling profiler inferred spans", + "__used_by": [ + "java" + ] + }, + "internal": { + "__description": "Application generic internal span for controller/handler/processing delegation", + "__used_by": [ + ] + }, + "controller": { + "__description": "Deprecated: use app.internal instead", + "__used_by": [ + "ruby" + ] + }, + "graphql": { + "__description": "Deprecated: use app.internal instead", + "__used_by": [ + "ruby" + ] + }, + "mailer": { + "__description": "Deprecated: use app.internal instead", + "__used_by": [ + "ruby" + ] + }, + "resource": { + "__description": "Deprecated: use app.internal instead", + "__used_by": [ + "ruby" + ] + }, + "handler": { + "__description": "Deprecated: use app.internal instead", + "__used_by": [ + "java" + ] + } + } + }, + "custom": { + "__description": "API custom instrumentation", + "__used_by": [ + "java", + "ruby" + ], + "allow_null_subtype": true + }, + "db": { + "__description": "database span", + "subtypes": { + "cassandra": { + "__description": "Cassandra", + "__used_by": [ + "java" + ] + }, + "cosmosdb": { + "__description": "Azure CosmosDB" + }, + "db2": { + "__description": "IBM DB2", + "__used_by": [ + "java" + ] + }, + "derby": { + "__description": "Apache Derby", + "__used_by": [ + "java" + ] + }, + "dynamodb": { + "__description": "AWS DynamoDB", + "__used_by": [ + "ruby" + ] + }, + "elasticsearch": { + "__description": "Elasticsearch", + "__used_by": [ + "java", + "ruby" + ] + }, + "graphql": { + "__description": "GraphQL", + "__used_by": [ + "nodejs" + ] + }, + "h2": { + "__description": "H2", + "__used_by": [ + "java" + ] + }, + "hsqldb": { + "__description": "HSQLDB", + "__used_by": [ + "java" + ] + }, + "ingres": { + "__description": "Ingres" + }, + "mariadb": { + "__description": "MariaDB", + "__used_by": [ + "java", + "ruby" + ] + }, + "memcached": { + "__description": "Memcached", + "__used_by": [ + "nodejs" + ] + }, + "mongodb": { + "__description": "MongoDB", + "__used_by": [ + "java", + "ruby" + ] + }, + "mssql": { + "__description": "Microsoft SQL Server", + "__used_by": [ + "nodejs", + "java" + ] + }, + "mysql": { + "__description": "MySQL", + "__used_by": [ + "java", + "ruby" + ] + }, + "oracle": { + "__description": "Oracle Database", + "__used_by": [ + "java" + ] + }, + "postgresql": { + "__description": "PostgreSQL", + "__used_by": [ + "ruby" + ] + }, + "redis": { + "__description": "Redis", + "__used_by": [ + "java", + "ruby" + ] + }, + "sqlite": { + "__description": "SQLite", + "__used_by": [ + "ruby" + ] + }, + "sqlite3": { + "__description": "Deprecated: use db/sqlite", + "__used_by": [ + "ruby" + ] + }, + "sqlserver": { + "__description": "Deprecated: use db/mssql", + "__used_by": [ + "java" + ] + }, + "unknown": { + "__description": "Unknown database", + "__used_by": [ + "java", + "ruby" + ] + } + } + }, + "external": { + "__description": "Request to external service, usually in request/response pattern", + "subtypes": { + "dubbo": { + "__description": "Apache Dubbo", + "__used_by": [ + "java" + ] + }, + "grpc": { + "__description": "gRPC", + "__used_by": [ + "ruby", + "java" + ] + }, + "http": { + "__description": "HTTP client", + "__used_by": [ + "ruby", + "java" + ] + }, + "ldap": { + "__description": "LDAP client", + "__used_by": [ + "java" + ] + } + } + }, + "json": { + "__description": "Deprecated: use app.internal instead", + "subtypes": { + "parse": { + "__description": "JSON parsing" + }, + "generate": { + "__description": "JSON generation" + } + }, + "__used_by": [ + "ruby" + ] + }, + "messaging": { + "__description": "Messaging", + "subtypes": { + "azurequeue": { + "__description": "Azure Queue" + }, + "azureservicebus": { + "__description": "Azure Service Bus" + }, + "jms": { + "__description": "Java Messaging Service", + "__used_by": [ + "java" + ] + }, + "kafka": { + "__description": "Apache Kafka", + "__used_by": [ + "java" + ] + }, + "rabbitmq": { + "__description": "RabbitMQ", + "__used_by": [ + "java" + ] + }, + "sns": { + "__description": "AWS Simple Notification Service", + "__used_by": [ + "ruby" + ] + }, + "sqs": { + "__description": "AWS Simple Queue Service", + "__used_by": [ + "ruby" + ] + } + } + }, + "process": { + "__description": "External process", + "__used_by": [ + "java" + ] + }, + "storage": { + "subtypes": { + "azureblob": { + "__description": "Azure Blob Storage" + }, + "azurefile": { + "__description": "Azure Files" + }, + "azuretable": { + "__description": "Azure Storage Table", + "__used_by": [ + "ruby" + ] + }, + "s3": { + "__description": "AWS S3", + "__used_by": [ + "ruby" + ] + } + } + }, + "template": { + "__description": "Template engines (no sub-type for now as really platform-specific)", + "__used_by": [ + "java", + "ruby" + ], + "allow_unlisted_subtype": true + }, + "websocket": { + "__description": "Websockets", + "subtypes": { + "send": { + "__used_by": [ + "nodejs" + ] + } + } + } +} diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/sql_signature_examples.json b/test/Elastic.Apm.Tests/TestResources/json-specs/sql_signature_examples.json new file mode 100644 index 000000000..564fbbf81 --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/sql_signature_examples.json @@ -0,0 +1,146 @@ +[ + { + "input": "", + "output": "" + }, + { + "input": " ", + "output": "" + }, + { + "input": "SELECT * FROM foo.bar", + "output": "SELECT FROM foo.bar" + }, + { + "input": "SELECT * FROM foo.bar.baz", + "output": "SELECT FROM foo.bar.baz" + }, + { + "input": "SELECT * FROM `foo.bar`", + "output": "SELECT FROM foo.bar" + }, + { + "input": "SELECT * FROM \"foo.bar\"", + "output": "SELECT FROM foo.bar" + }, + { + "input": "SELECT * FROM [foo.bar]", + "output": "SELECT FROM foo.bar" + }, + { + "input": "SELECT (x, y) FROM foo,bar,baz", + "output": "SELECT FROM foo" + }, + { + "input": "SELECT * FROM foo JOIN bar", + "output": "SELECT FROM foo" + }, + { + "input": "SELECT * FROM dollar$bill", + "output": "SELECT FROM dollar$bill" + }, + { + "input": "SELECT id FROM \"myta\n-æøåble\" WHERE id = 2323", + "output": "SELECT FROM myta\n-æøåble" + }, + { + "input": "SELECT * FROM foo-- abc\n./*def*/bar", + "output": "SELECT FROM foo.bar" + }, + { + "comment": "We capture the first table of the outermost select statement", + "input": "SELECT *,(SELECT COUNT(*) FROM table2 WHERE table2.field1 = table1.id) AS count FROM table1 WHERE table1.field1 = 'value'", + "output": "SELECT FROM table1" + }, + { + "comment": "If the outermost select operates on derived tables, then we just return 'SELECT' (i.e. the fallback)", + "input": "SELECT * FROM (SELECT foo FROM bar) AS foo_bar", + "output": "SELECT" + }, + { + "input": "DELETE FROM foo.bar WHERE baz=1", + "output": "DELETE FROM foo.bar" + }, + { + "input": "UPDATE IGNORE foo.bar SET bar=1 WHERE baz=2", + "output": "UPDATE foo.bar" + }, + { + "input": "UPDATE ONLY foo AS bar SET baz=1", + "output": "UPDATE foo" + }, + { + "input": "INSERT INTO foo.bar (col) VALUES(?)", + "output": "INSERT INTO foo.bar" + }, + { + "input": "INSERT LOW_PRIORITY IGNORE INTO foo.bar (col) VALUES(?)", + "output": "INSERT INTO foo.bar" + }, + { + "input": "CALL foo(bar, 123)", + "output": "CALL foo" + }, + { + "comment": "For DDL we only capture the first token", + "input": "ALTER TABLE foo ADD ()", + "output": "ALTER" + }, + { + "input": "CREATE TABLE foo ...", + "output": "CREATE" + }, + { + "input": "DROP TABLE foo", + "output": "DROP" + }, + { + "input": "SAVEPOINT x_asd1234", + "output": "SAVEPOINT" + }, + { + "input": "BEGIN", + "output": "BEGIN" + }, + { + "input": "COMMIT", + "output": "COMMIT" + }, + { + "input": "ROLLBACK", + "output": "ROLLBACK" + }, + { + "comment": "For broken statements we only capture the first token", + "input": "SELECT * FROM (SELECT EOF", + "output": "SELECT" + }, + { + "input": "SELECT 'neverending literal FROM (SELECT * FROM ...", + "output": "SELECT" + }, + { + "input": "INSERT COIN TO PLAY", + "output": "INSERT" + }, + { + "input": "INSERT $2 INTO", + "output": "INSERT" + }, + { + "input": "UPDATE 99", + "output": "UPDATE" + }, + { + "input": "DELETE 99", + "output": "DELETE" + }, + { + "input": "DELETE FROM", + "output": "DELETE" + }, + { + "input": "CALL", + "output": "CALL" + } +] diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/sql_token_examples.json b/test/Elastic.Apm.Tests/TestResources/json-specs/sql_token_examples.json new file mode 100644 index 000000000..b443df7d1 --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/sql_token_examples.json @@ -0,0 +1,244 @@ +[ + { + "name": "whitespace-only", + "comment": "whitespace between tokens is ignored", + "input": " " + }, + { + "name": "keywords", + "comment": "keywords each have their own kind, and are scanned case-insensitively", + "input": "INSERT or rEpLaCe", + "tokens": [ + { + "kind": "INSERT", + "text": "INSERT" + }, + { + "kind": "OR", + "text": "or" + }, + { + "kind": "REPLACE", + "text": "rEpLaCe" + } + ] + }, + { + "name": "qualified-table", + "input": "schema.Abc_123", + "tokens": [ + { + "kind": "IDENT", + "text": "schema" + }, + { + "kind": "PERIOD", + "text": "." + }, + { + "kind": "IDENT", + "text": "Abc_123" + } + ] + }, + { + "name": "dollar-variable", + "comment": "dollar variables mustn't confuse dollar quoting", + "input": "$123", + "tokens": [ + { + "kind": "OTHER", + "text": "$123" + } + ] + }, + { + "name": "identifiers", + "input": "_foo foo$", + "tokens": [ + { + "kind": "IDENT", + "text": "_foo" + }, + { + "kind": "IDENT", + "text": "foo$" + } + ] + }, + { + "name": "quoted-identifiers", + "input": "`SELECT` \"SELECT \"\"\" [SELECT '']", + "tokens": [ + { + "kind": "IDENT", + "text": "SELECT" + }, + { + "kind": "IDENT", + "text": "SELECT \"\"" + }, + { + "kind": "IDENT", + "text": "SELECT ''" + } + ] + }, + { + "name": "punctuation", + "input": "().", + "tokens": [ + { + "kind": "LPAREN", + "text": "(" + }, + { + "kind": "RPAREN", + "text": ")" + }, + { + "kind": "PERIOD", + "text": "." + } + ] + }, + { + "name": "comments", + "input": "/* /*nested*/ */ -- SELECT /*", + "tokens": [ + { + "kind": "COMMENT", + "text": "/* /*nested*/ */" + }, + { + "kind": "COMMENT", + "text": "-- SELECT /*" + } + ] + }, + { + "name": "CQL line comment", + "input": "/* /*nested*/ */ // SELECT /*", + "tokens": [ + { + "kind": "COMMENT", + "text": "/* /*nested*/ */" + }, + { + "kind": "COMMENT", + "text": "// SELECT /*" + } + ] + }, + { + "name": "string-literal", + "input": "'abc '' def\\''", + "tokens": [ + { + "kind": "STRING", + "text": "'abc '' def\\''" + } + ] + }, + { + "name": "dollar-quoted-string-literal", + "input": "$$f$o$o$$ $$ $$ $foo$'`$$$$\"$foo$ $foo $bar", + "tokens": [ + { + "kind": "STRING", + "text": "$$f$o$o$$" + }, + { + "kind": "STRING", + "text": "$$ $$" + }, + { + "kind": "STRING", + "text": "$foo$'`$$$$\"$foo$" + }, + { + "kind": "OTHER", + "text": "$foo" + }, + { + "kind": "OTHER", + "text": "$bar" + } + ] + }, + { + "name": "unterminated-dollar-quoted-string-literal", + "comment": "Unterminated dollar-quoted string rewinds back to the first whitespace, under the assumption that the input is valid and we've interpreted it wrongly", + "input": "$foo$ banana $", + "tokens": [ + { + "kind": "OTHER", + "text": "$foo$" + }, + { + "kind": "IDENT", + "text": "banana" + }, + { + "kind": "OTHER", + "text": "$" + } + ] + }, + { + "name": "numeric-literals", + "input": "123 123.456 123E45 123e+45 123e-45 1.2.3", + "tokens": [ + { + "kind": "NUMBER", + "text": "123" + }, + { + "kind": "NUMBER", + "text": "123.456" + }, + { + "kind": "NUMBER", + "text": "123E45" + }, + { + "kind": "NUMBER", + "text": "123e+45" + }, + { + "kind": "NUMBER", + "text": "123e-45" + }, + { + "kind": "NUMBER", + "text": "1.2" + }, + { + "kind": "PERIOD", + "text": "." + }, + { + "kind": "NUMBER", + "text": "3" + } + ] + }, + { + "name": "unicode", + "input": "选择 FROM foo", + "tokens": [ + { + "kind": "IDENT", + "text": "选择" + }, + { + "kind": "FROM", + "text": "FROM" + }, + { + "kind": "IDENT", + "text": "foo" + } + ] + } +] diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/w3c_distributed_tracing.json b/test/Elastic.Apm.Tests/TestResources/json-specs/w3c_distributed_tracing.json new file mode 100644 index 000000000..30a3b0404 --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/w3c_distributed_tracing.json @@ -0,0 +1,92 @@ +// +// from https://github.com/w3c/distributed-tracing/blob/main/test/test_data.json +// +// NOTE: This file is manually copied from the above link and +// there is currently NO automation keeping it in sync with the upstream version. +// +// Latest commit 98f210e on Sep 24, 2019 +// +[ + {"headers": [["traceparent", "00-00000000000000000000000000000000-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [], "is_traceparent_valid": false}, + {"headers": [], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789011-1234567890123456-01"], ["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [], "is_traceparent_valid": false}, + {"headers": [], "is_traceparent_valid": false}, + {"headers": [["TraceParent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["TrAcEpArEnT", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["TRACEPARENT", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01 "]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01\t"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01 \t"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-0000000000000000-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-.234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-123456789012345.-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-12345678901234567-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-123456789012345-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-.0"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-0."]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-001"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-1"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-00000000000000000000000000000000-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-.2345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-1234567890123456789012345678901.-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-123456789012345678901234567890123-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-1234567890123456789012345678901-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01."]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-01-what-the-future-will-be-like"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "cc-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "cc-12345678901234567890123456789012-1234567890123456-01-what-the-future-will-be-like"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "cc-12345678901234567890123456789012-1234567890123456-01.what-the-future-will-be-like"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "ff-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", ".0-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "0.-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "000-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "0000-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "0-12345678901234567890123456789012-1234567890123456-01"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "abcdefghijklmnopqrstuvwxyz0123456789_-*/= !\"#$%&'()*+-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "abcdefghijklmnopqrstuvwxyz0123456789_-*/@a-z0-9_-*/= !\"#$%&'()*+-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1,foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1,foo=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "foo=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", ""]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", ""]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", ""], ["tracestate", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"]], "is_traceparent_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["TraceState", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["TrAcEsTaTe", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["TRACESTATE", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1,bar=2"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["tracestate", "foo=1"]], "is_traceparent_valid": false}, + {"headers": [["tracestate", "foo=1,bar=2"]], "is_traceparent_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo =1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "FOO=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo.bar=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo@=1,bar=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "@foo=1,bar=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo@@bar=1,bar=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo@bar@baz=1,bar=2"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt@vvvvvvvvvvvvvv=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt@v=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"], ["tracestate", "t@vvvvvvvvvvvvvvv=1"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "bar01=01,bar02=02,bar03=03,bar04=04,bar05=05,bar06=06,bar07=07,bar08=08,bar09=09,bar10=10"], ["tracestate", "bar11=11,bar12=12,bar13=13,bar14=14,bar15=15,bar16=16,bar17=17,bar18=18,bar19=19,bar20=20"], ["tracestate", "bar21=21,bar22=22,bar23=23,bar24=24,bar25=25,bar26=26,bar27=27,bar28=28,bar29=29,bar30=30"], ["tracestate", "bar31=31,bar32=32"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "bar01=01,bar02=02,bar03=03,bar04=04,bar05=05,bar06=06,bar07=07,bar08=08,bar09=09,bar10=10"], ["tracestate", "bar11=11,bar12=12,bar13=13,bar14=14,bar15=15,bar16=16,bar17=17,bar18=18,bar19=19,bar20=20"], ["tracestate", "bar21=21,bar22=22,bar23=23,bar24=24,bar25=25,bar26=26,bar27=27,bar28=28,bar29=29,bar30=30"], ["tracestate", "bar31=31,bar32=32,bar33=33"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1,bar=2"], ["tracestate", "rojo=1,congo=2"], ["tracestate", "baz=3"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1 \t , \t bar=2, \t baz=3"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1\t \t,\t \tbar=2,\t \tbaz=3"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1 "]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1\t"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=1 \t"]], "is_traceparent_valid": true, "is_tracestate_valid": true}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=bar=baz"]], "is_traceparent_valid": true, "is_tracestate_valid": false}, + {"headers": [["traceparent", "00-12345678901234567890123456789012-1234567890123456-00"], ["tracestate", "foo=,bar=3"]], "is_traceparent_valid": true, "is_tracestate_valid": false} +] diff --git a/test/Elastic.Apm.Tests/TestResources/json-specs/wildcard_matcher_tests.json b/test/Elastic.Apm.Tests/TestResources/json-specs/wildcard_matcher_tests.json new file mode 100644 index 000000000..2b071470a --- /dev/null +++ b/test/Elastic.Apm.Tests/TestResources/json-specs/wildcard_matcher_tests.json @@ -0,0 +1,194 @@ +{ + "testMatchesStartsWith": { + "foo*": { + "foo": true, + "foobar": true, + "bar": false, + "barfoo": false, + "rfoo": false + } + }, + "testWildcardInTheMiddle": { + "/foo/*/baz": { + "/foo/bar/baz": true, + "/foo/bar": false + } + }, + "testCompoundWildcardMatcher": { + "*foo*foo*": { + "foofoo": true, + "foo/bar/foo": true, + "/foo/bar/foo/bar": true, + "foo": false + } + }, + "testCompoundWildcardMatcher3": { + "*foo*oo*": { + "foooo": true, + "foofoo": true, + "foo/bar/foo": true, + "/foo/bar/foo/bar": true, + "foo": false, + "fooo": false + } + }, + "testCompoundWildcardMatcher2": { + "*foo*bar*": { + "foobar": true, + "foo/bar/foo/baz": true, + "/foo/bar/baz": true, + "bar/foo": false, + "barfoo": false + } + }, + "testCompoundWildcardMatcher4": { + "*foo*far*": { + "foofar": true, + "foo/far/foo/baz": true, + "/foo/far/baz": true, + "/far/foo": false, + "farfoo": false + } + }, + "testMatchBetween": { + "*foo*foo*": { + "foofoo": true, + "foo/foo/foo/baz": true, + "/foo/foo/baz": true, + "/foo/foo": true, + "foobar": false + } + }, + "testComplexExpressions": { + "/foo/*/baz*": { + "/foo/a/bar/b/baz": true + }, + "/foo/*/bar/*/baz": { + "/foo/a/bar/b/baz": true + } + }, + "testInfixEmptyMatcher": { + "**": { + "": true, + "foo": true + } + }, + "testMatchesEndsWith": { + "*foo": { + "foo": true, + "foobar": false, + "bar": false, + "barfoo": true, + "foor": false + } + }, + "testMatchesEquals": { + "foo": { + "foo": true, + "foobar": false, + "bar": false, + "barfoo": false + } + }, + "testMatchesInfix": { + "*foo*": { + "foo": true, + "foobar": true, + "bar": false, + "barfoo": true, + "barfoobaz": true + } + }, + "testMatchesNoWildcard": { + "foo": { + "foo": true, + "foobar": false + } + }, + "testMatchesStartsWith_ignoreCase": { + "foo*": { + "foo": true, + "foobar": true, + "bar": false, + "barfoo": false + } + }, + "testInfixEmptyMatcher_ignoreCase": { + "**": { + "": true, + "foo": true + } + }, + "testMatchesEndsWith_ignoreCase": { + "*foo": { + "fOo": true, + "foobar": false, + "bar": false, + "baRFoo": true + } + }, + "testMatchesEquals_ignoreCase": { + "foo": { + "fOo": true, + "foOBar": false, + "BAR": false, + "barfoo": false + } + }, + "testMatchesInfix_ignoreCase": { + "*foo*": { + "FOO": true, + "foOBar": true, + "BAR": false, + "baRFOo": true, + "BARFOOBAZ": true + } + }, + "testMatchesInfix_caseSensitive": { + "(?-i)*foo*": { + "foo": true, + "FOO": false + } + }, + "testMatchesNoWildcard_ignoreCase": { + "foo": { + "FOO": true, + "foobar": false + } + }, + "testNeedleLongerThanHaystack": { + "*foo": { + "baz": false + }, + "*foob": { + "baz": false + }, + "*fooba": { + "baz": false + }, + "*foobar": { + "baz": false + }, + "foo*": { + "baz": false + }, + "foob*": { + "baz": false + }, + "fooba*": { + "baz": false + }, + "foobar*": { + "baz": false + }, + "*foobar*": { + "baz": false + } + }, + "testSingleCharacterWildcardNotSupported": { + "fo?": { + "foo": false, + "fo?": true + } + } +}