├── CODE_OF_CONDUCT.md ├── dev_docs ├── images │ ├── github-create-tag.png │ └── github-find-commit.png └── OVERVIEW.md ├── .gitignore ├── model ├── proto │ ├── buf.yaml │ ├── trace.proto │ ├── code.proto │ ├── ip.proto │ ├── session.proto │ ├── useragent.proto │ ├── destination.proto │ ├── headers.proto │ ├── datastream.proto │ ├── user.proto │ ├── client.proto │ ├── observer.proto │ ├── agent.proto │ ├── keyvalue.proto │ ├── os.proto │ ├── kubernetes.proto │ ├── container.proto │ ├── source.proto │ ├── device.proto │ ├── url.proto │ ├── message.proto │ ├── faas.proto │ ├── labels.proto │ ├── host.proto │ ├── log.proto │ ├── experience.proto │ ├── process.proto │ ├── network.proto │ ├── system.proto │ ├── event.proto │ ├── cloud.proto │ ├── http.proto │ ├── service.proto │ ├── error.proto │ ├── stacktrace.proto │ └── metricset.proto ├── modeljson │ ├── internal │ │ ├── timestamp.go │ │ ├── trace.go │ │ ├── parent.go │ │ ├── session.go │ │ ├── useragent.go │ │ ├── child.go │ │ ├── user.go │ │ ├── client.go │ │ ├── observer.go │ │ ├── os.go │ │ ├── agent.go │ │ ├── destination.go │ │ ├── source.go │ │ ├── host.go │ │ ├── url.go │ │ ├── ip.go │ │ ├── spanlink.go │ │ ├── device.go │ │ ├── container.go │ │ ├── faas.go │ │ ├── kubernetes.go │ │ ├── keyvalue.go │ │ ├── httpheader.go │ │ ├── log.go │ │ ├── message.go │ │ ├── event.go │ │ ├── network.go │ │ ├── process.go │ │ ├── labels.go │ │ └── system.go │ ├── context.go │ ├── user.pb.json.go │ ├── client.pb.json.go │ ├── os.pb.json.go │ ├── observer.pb.json.go │ ├── agent.pb.json.go │ ├── container.pb.json.go │ ├── source.pb.json.go │ ├── url.pb.json.go │ ├── kubernetes.pb.json.go │ ├── device.pb.json.go │ ├── labels.go │ ├── destination.pb.json.go │ ├── faas.pb.json.go │ ├── message.pb.json.go │ ├── log.pb.json.go │ ├── experience.pb.json.go │ ├── network.pb.json.go │ ├── process.pb.json.go │ ├── system.pb.json.go │ ├── host.pb.json.go │ └── event.pb.json.go ├── modelprocessor │ ├── doc.go │ ├── chained.go │ ├── eventreceived.go │ ├── config_test.go │ ├── errormessage.go │ ├── environment.go │ └── eventreceived_test.go └── modelpb │ └── timestamp.go ├── CODEOWNERS ├── input ├── elasticapm │ └── internal │ │ ├── modeldecoder │ │ ├── test_approved_model │ │ │ ├── context_empty.approved.json │ │ │ ├── context_input_nil.approved.json │ │ │ ├── context_user_id_integer.approved.json │ │ │ ├── context_experimental is not true.approved.json │ │ │ ├── context_url_port_string.approved.json │ │ │ ├── context_no_url_protocol.approved.json │ │ │ ├── context_client_ip_from_socket.approved.json │ │ │ ├── context_request_body_string.approved.json │ │ │ ├── context_client_ip_from_socket_invalid_headers.approved.json │ │ │ ├── context_client_ip_from_forwarded_header.approved.json │ │ │ └── context_client_ip_header_case_insensitive.approved.json │ │ ├── rumv3 │ │ │ └── testdata │ │ │ │ ├── metadata.ndjson │ │ │ │ └── rum_errors.ndjson │ │ ├── v2 │ │ │ └── testdata │ │ │ │ ├── invalid-event-type.ndjson │ │ │ │ ├── minimal-service.ndjson │ │ │ │ ├── invalid-metadata-2.ndjson │ │ │ │ ├── invalid-metadata.ndjson │ │ │ │ ├── metadata-null-values.ndjson │ │ │ │ ├── invalid-json-event.ndjson │ │ │ │ ├── span-links.ndjson │ │ │ │ ├── invalid-event.ndjson │ │ │ │ ├── optional-timestamps.ndjson │ │ │ │ ├── minimal.ndjson │ │ │ │ ├── transactions_spans_rum_2.ndjson │ │ │ │ ├── transactions_spans_rum.ndjson │ │ │ │ ├── metadata.ndjson │ │ │ │ ├── otel-bridge.ndjson │ │ │ │ └── errors_rum.ndjson │ │ ├── generator │ │ │ ├── bool.go │ │ │ ├── httpheader.go │ │ │ ├── jsonnumber.go │ │ │ ├── integer.go │ │ │ ├── nullable.go │ │ │ ├── nint.go │ │ │ └── propertytypename_string.go │ │ ├── input.go │ │ ├── modeldecodertest │ │ │ └── strbuilder.go │ │ └── modeldecoderutil │ │ │ ├── exception.go │ │ │ └── keyvaluepb.go │ │ └── decoder │ │ ├── decoder_test.go │ │ ├── decoder.go │ │ └── limited_reader_test.go ├── jaeger │ └── test_approved │ │ ├── transaction_jaeger_no_attrs.approved.json │ │ ├── transaction_jaeger_custom.approved.json │ │ ├── transaction_jaeger_type_component.approved.json │ │ ├── transaction_jaeger_data_stream.approved.json │ │ ├── metadata_jaeger-version.approved.json │ │ ├── metadata_jaeger-no-language.approved.json │ │ ├── span_jaeger_custom.approved.json │ │ ├── metadata_jaeger_minimal.approved.json │ │ ├── transaction_jaeger_type_messaging.approved.json │ │ ├── span_jaeger_subtype_component.approved.json │ │ ├── span_jaeger_data_stream.approved.json │ │ ├── transaction_jaeger_type_request_result.approved.json │ │ ├── metadata_jaeger.approved.json │ │ ├── transaction_jaeger_type_request.approved.json │ │ ├── span_jaeger_messaging.approved.json │ │ └── span_jaeger_https_default_port.approved.json ├── otlp │ ├── trace_semaphore.go │ └── timestamps.go └── semaphore.go ├── tools ├── generate-modelpb.sh └── install-protobuf.sh ├── README.md ├── .github ├── dependabot.yml └── workflows │ ├── add-to-project.yaml │ ├── ci.yml │ └── label-elastic-pull-requests.yml ├── Makefile └── codec ├── json.go └── vtproto.go /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 303 See Other 2 | 3 | Location: https://www.elastic.co/community/codeofconduct 4 | -------------------------------------------------------------------------------- /dev_docs/images/github-create-tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-data/main/dev_docs/images/github-create-tag.png -------------------------------------------------------------------------------- /dev_docs/images/github-find-commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-data/main/dev_docs/images/github-find-commit.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vim 2 | *.swp 3 | # IntelliJ module files (.idea folder, *.iml module files): 4 | .idea 5 | *.iml 6 | # project build 7 | tools/build 8 | -------------------------------------------------------------------------------- /model/proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | lint: 3 | use: 4 | - STANDARD 5 | except: 6 | - PACKAGE_DIRECTORY_MATCH 7 | breaking: 8 | use: 9 | - WIRE 10 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default owner 2 | * @elastic/obs-ds-intake-services 3 | 4 | # Sub-directories/files ownership 5 | /.github/workflows @elastic/obs-ds-intake-services @elastic/observablt-ci 6 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_empty.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": null, 5 | "Labels": null, 6 | "Message": null, 7 | "Page": null, 8 | "URL": null 9 | } 10 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_input_nil.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": null, 5 | "Labels": null, 6 | "Message": null, 7 | "Page": null, 8 | "URL": null 9 | } 10 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_user_id_integer.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": null, 5 | "Labels": null, 6 | "Message": null, 7 | "Page": null, 8 | "URL": null 9 | } 10 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_experimental is not true.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": null, 5 | "Labels": null, 6 | "Message": null, 7 | "Page": null, 8 | "URL": null 9 | } 10 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/rumv3/testdata/metadata.ndjson: -------------------------------------------------------------------------------- 1 | {"m": {"se": {"n": "apm-a-rum-test-e2e-general-usecase","ve": "0.0.1","en": "prod","a": {"n": "js-base","ve": "4.8.1"},"ru": {"n": "v8","ve": "8.0"},"la": {"n": "javascript","ve": "6"},"fw": {"n": "angular","ve": "2"}},"u": {"id": 123,"em": "user@email.com","un": "John Doe"},"l": {"testTagKey": "testTagValue"}}} -------------------------------------------------------------------------------- /tools/generate-modelpb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") 4 | 5 | PATH="${TOOLS_DIR}/build/bin:${PATH}" protoc \ 6 | --proto_path=./model/proto/ \ 7 | --go_out=. \ 8 | --go_opt=module=github.com/elastic/apm-data \ 9 | --go-vtproto_out=. \ 10 | --go-vtproto_opt=features=marshal+unmarshal+size+clone,module=github.com/elastic/apm-data \ 11 | ./model/proto/*.proto 12 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/invalid-event-type.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": null, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "1234_service-12a3", "language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": null, "framework": null,"version": null, "runtime": null}}} 2 | {"tennis-court": {"name": "Centre Court, Wimbledon"}} 3 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/minimal-service.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": { "service": {"name": "1234_service-12a3", "language": {"name": "ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}}}} 2 | { "error": {"id": "abcdef0123456789", "timestamp": 1533827045999000,"log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}} 3 | { "metricset": { "samples": { "go.memstats.heap.sys.bytes": { "value": 61235 } }, "timestamp": 1496170422281000 }} 4 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/invalid-metadata-2.ndjson: -------------------------------------------------------------------------------- 1 | {"not": "metadata"} 2 | {"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "key": "abc" }, "timestamp": 1496170422281000 }} 3 | 4 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/invalid-metadata.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": null}} 2 | {"metricset": { "samples": { "byte_counter": { "value": 1 }, "short_counter": { "value": 227 }, "integer_gauge": { "value": 42767 }, "long_gauge": { "value": 3147483648 }, "float_gauge": { "value": 9.16 }, "double_gauge": { "value": 3.141592653589793 }, "dotted.float.gauge": { "value": 6.12 }, "negative.d.o.t.t.e.d": { "value": -1022 } }, "tags": { "code": "200", "some": "abc" }, "timestamp": 1496170422281000 }} 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![ci](https://github.com/elastic/apm-data/actions/workflows/ci.yml/badge.svg)](https://github.com/elastic/apm-data/actions/workflows/ci.yml) 2 | 3 | # apm-data 4 | 5 | apm-data holds definitions and code for manipulating Elastic APM data. 6 | 7 | ### Code Generation 8 | 9 | Whenever updating protobuf files, you need to manually run the generation of 10 | the related code, as well as licenses update. 11 | 12 | ``` 13 | make all 14 | ``` 15 | 16 | ## License 17 | 18 | This software is licensed under the [Apache 2 license](https://github.com/elastic/apm-data/blob/main/LICENSE). 19 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/metadata-null-values.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": null, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "1234_service-12a3", "language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": null, "framework": { "version": null, "name": null },"version": null, "runtime": null}}} 2 | { "error": {"id": "abcdef0123456789", "timestamp": 1533827045999000,"log": {"level": "custom log level","message": "Cannot read property 'baz' of undefined"}}} 3 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/invalid-json-event.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": null, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "1234_service-12a3", "language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": null, "framework": null,"version": null, "runtime": null}}} 2 | { "invalid-json" } 3 | {"span": {"trace_id": "fdedef0123456789abcdef9876543210", "parent_id": "abcdef0123456789","id": "abcdef01234567", "transaction_id": "01af25874dec69dd", "name": "GET /api/types", "type": "request","start": 0, "duration": 141.581 }} 4 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/span-links.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": { "service": {"name": "1234_service-12a3", "agent": {"version": "3.14.0", "name": "elastic-node"}}}} 2 | {"span": {"id": "0123456a89012345", "trace_id": "0123456789abcdef0123456789abcdef", "parent_id": "ab23456a89012345", "name": "GET /api/types", "type": "request", "start": 1.845, "duration": 3.5642981, "links": [{"span_id": "linked_span_1", "trace_id": "linked_trace_1"}]}} 3 | {"transaction": {"trace_id": "01234567890123456789abcdefabcdef", "id": "abcdef1478523690", "type": "request", "duration": 32.592981, "span_count": {"started": 0}, "links": [{"span_id": "linked_span_2", "trace_id": "linked_trace_2"}, {"span_id": "linked_span_3", "trace_id": "linked_trace_3"}]}} 4 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/invalid-event.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": null, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "1234_service-12a3", "language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": null, "framework": null,"version": null, "runtime": null}}} 2 | { "transaction": { "id": 12345, "trace_id": "0123456789abcdef0123456789abcdef", "parent_id": "abcdefabcdef01234567", "type": "request", "duration": 32.592981, "span_count": { "started": 21 } } } 3 | {"span": {"trace_id": "fdedef0123456789abcdef9876543210", "parent_id": "abcdef0123456789","id": "abcdef01234567", "transaction_id": "01af25874dec69dd", "name": "GET /api/types", "type": "request","start": 0, "duration": 141.581 }} 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Go dependencies 4 | - package-ecosystem: "gomod" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | groups: 9 | otel: 10 | patterns: 11 | - "go.opentelemetry.io/*" 12 | - "github.com/jaegertracing/jaeger-idl" 13 | - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger" 14 | golang.org/x/: 15 | patterns: 16 | - "golang.org/x/*" 17 | go-agent: 18 | patterns: 19 | - "go.elastic.co/apm*" 20 | # GitHub actions 21 | - package-ecosystem: "github-actions" 22 | directory: "/" 23 | schedule: 24 | interval: "weekly" 25 | day: "sunday" 26 | time: "22:00" 27 | groups: 28 | github-actions: 29 | patterns: 30 | - "*" 31 | -------------------------------------------------------------------------------- /.github/workflows/add-to-project.yaml: -------------------------------------------------------------------------------- 1 | name: Add new issues to the project board 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - transferred 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | add-to-project: 14 | name: Add issue to project 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Get token 18 | id: get_token 19 | uses: actions/create-github-app-token@v2 20 | with: 21 | app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }} 22 | private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }} 23 | permission-organization-projects: write 24 | permission-issues: read 25 | 26 | - uses: actions/add-to-project@v1.0.2 27 | with: 28 | project-url: https://github.com/orgs/elastic/projects/1286 29 | github-token: ${{ steps.get_token.outputs.token }} -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_url_port_string.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": null, 10 | "Method": "get", 11 | "Socket": { 12 | "Encrypted": null, 13 | "RemoteAddress": null 14 | } 15 | }, 16 | "Response": null, 17 | "Version": null 18 | }, 19 | "Labels": null, 20 | "Message": null, 21 | "Page": null, 22 | "URL": { 23 | "Domain": null, 24 | "Fragment": null, 25 | "Full": null, 26 | "Original": null, 27 | "Path": null, 28 | "Port": 8080, 29 | "Query": null, 30 | "Scheme": null 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_no_url_protocol.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": null, 10 | "Method": "get", 11 | "Socket": { 12 | "Encrypted": null, 13 | "RemoteAddress": null 14 | } 15 | }, 16 | "Response": null, 17 | "Version": null 18 | }, 19 | "Labels": null, 20 | "Message": null, 21 | "Page": null, 22 | "URL": { 23 | "Domain": null, 24 | "Fragment": null, 25 | "Full": null, 26 | "Original": "127.0.0.1", 27 | "Path": null, 28 | "Port": null, 29 | "Query": null, 30 | "Scheme": null 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_client_ip_from_socket.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": null, 10 | "Method": "post", 11 | "Socket": { 12 | "Encrypted": false, 13 | "RemoteAddress": "10.1.23.5" 14 | } 15 | }, 16 | "Response": null, 17 | "Version": null 18 | }, 19 | "Labels": null, 20 | "Message": null, 21 | "Page": null, 22 | "URL": { 23 | "Domain": null, 24 | "Fragment": null, 25 | "Full": null, 26 | "Original": null, 27 | "Path": null, 28 | "Port": null, 29 | "Query": null, 30 | "Scheme": null 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_request_body_string.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": "user-request", 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": null, 10 | "Method": "get", 11 | "Socket": { 12 | "Encrypted": null, 13 | "RemoteAddress": null 14 | } 15 | }, 16 | "Response": null, 17 | "Version": null 18 | }, 19 | "Labels": null, 20 | "Message": null, 21 | "Page": null, 22 | "URL": { 23 | "Domain": null, 24 | "Fragment": null, 25 | "Full": null, 26 | "Original": null, 27 | "Path": null, 28 | "Port": null, 29 | "Query": null, 30 | "Scheme": null 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /model/modeljson/internal/timestamp.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Timestamp struct { 21 | US int `json:"us"` 22 | } 23 | -------------------------------------------------------------------------------- /model/modeljson/internal/trace.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Trace struct { 21 | ID string `json:"id,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /model/modeljson/internal/parent.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Parent struct { 21 | ID string `json:"id,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/rumv3/testdata/rum_errors.ndjson: -------------------------------------------------------------------------------- 1 | {"m":{"se":{"n":"apm-a-rum-test-e2e-general-usecase","ve":"0.0.1","a":{"n":"js-base","ve":"4.8.1"},"la":{"n":"javascript"}},"l":{"testTagKey":"testTagValue"}}} 2 | {"e":{"id":"3661352868c17c78b773d2f1beae6d41","cl":"test/e2e/general-usecase/app.e2e-bundle.min.js?token=secret","ex":{"mg":"Uncaught Error: timeout test e with a [REDACTED]","st":[{"ap":"http://localhost:8000/test/e2e/general-usecase/app.e2e-bundle.min.js?token=secret","f":"test/e2e/general-usecase/app.e2e-bundle.min.js?token=secret","fn":"generateError","li":7662,"co":9},{"ap":"http://localhost:8000/test/e2e/general-usecase/app.e2e-bundle.min.js?token=secret","f":"test/e2e/general-usecase/app.e2e-bundle.min.js?token=secret","fn":"","li":7666,"co":3}],"t":"Error"},"c":{"p":{"rf":"http://localhost:8000/test/e2e/","url":"http://localhost:8000/test/e2e/general-usecase/"},"u":{"id":"uId","un":"un","em":"em"},"cu":{"testContext":"testContext"},"g":{"testTagKey":"testTagValue"}}}} 3 | -------------------------------------------------------------------------------- /model/modeljson/internal/session.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Session struct { 21 | ID string `json:"id"` 22 | Sequence uint64 `json:"sequence,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_no_attrs.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "duration": 79000000000, 11 | "outcome": "failure" 12 | }, 13 | "host": { 14 | "hostname": "host-abc" 15 | }, 16 | "service": { 17 | "language": { 18 | "name": "unknown" 19 | }, 20 | "name": "unknown" 21 | }, 22 | "timestamp": { 23 | "us": 1576500418000768 24 | }, 25 | "transaction": { 26 | "representative_count": 1, 27 | "result": "Error", 28 | "sampled": true, 29 | "type": "unknown" 30 | } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /model/modelprocessor/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | // Package modelprocessor is meant to be used to enrich modelpb.Batch implementing 19 | // the modelpb.BatchProcessor interface. 20 | package modelprocessor 21 | -------------------------------------------------------------------------------- /model/modeljson/internal/useragent.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type UserAgent struct { 21 | Original string `json:"original,omitempty"` 22 | Name string `json:"name,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_client_ip_from_socket_invalid_headers.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": { 10 | "X-Forwarded-For": [ 11 | "192.13.14:8097" 12 | ] 13 | }, 14 | "Method": "post", 15 | "Socket": { 16 | "Encrypted": false, 17 | "RemoteAddress": "10.1.23.5" 18 | } 19 | }, 20 | "Response": null, 21 | "Version": null 22 | }, 23 | "Labels": null, 24 | "Message": null, 25 | "Page": null, 26 | "URL": { 27 | "Domain": null, 28 | "Fragment": null, 29 | "Full": null, 30 | "Original": null, 31 | "Path": null, 32 | "Port": null, 33 | "Query": null, 34 | "Scheme": null 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | lint: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v6 16 | - uses: actions/setup-go@v6 17 | with: 18 | go-version-file: go.mod 19 | cache: true 20 | - run: make all 21 | - uses: dominikh/staticcheck-action@024238d2898c874f26d723e7d0ff4308c35589a2 # v1.4.0 22 | with: 23 | version: "2025.1" 24 | install-go: false 25 | - name: Verify repo is up-to-date 26 | run: | 27 | if [ -n "$(git status --porcelain)" ]; then 28 | echo 'Updates required:' 29 | git diff 30 | exit 1 31 | fi 32 | 33 | run-tests: 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: actions/checkout@v6 37 | - uses: actions/setup-go@v6 38 | with: 39 | go-version-file: go.mod 40 | cache: true 41 | - name: Run tests 42 | run: make test 43 | -------------------------------------------------------------------------------- /model/proto/trace.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Trace { 25 | string id = 1; 26 | } 27 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_custom.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "host": { 13 | "hostname": "host-abc" 14 | }, 15 | "labels": { 16 | "a_b": "foo" 17 | }, 18 | "service": { 19 | "language": { 20 | "name": "unknown" 21 | }, 22 | "name": "unknown" 23 | }, 24 | "timestamp": { 25 | "us": 1576500418000768 26 | }, 27 | "transaction": { 28 | "representative_count": 1, 29 | "sampled": true, 30 | "result": "Success", 31 | "type": "unknown" 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /model/proto/code.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Code { 25 | string stacktrace = 1; 26 | } 27 | -------------------------------------------------------------------------------- /model/proto/ip.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message IP { 25 | fixed32 v4 = 1; 26 | bytes v6 = 2; 27 | } 28 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_type_component.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "host": { 13 | "hostname": "host-abc" 14 | }, 15 | "labels": { 16 | "component": "amqp" 17 | }, 18 | "service": { 19 | "language": { 20 | "name": "unknown" 21 | }, 22 | "name": "unknown" 23 | }, 24 | "timestamp": { 25 | "us": 1576500418000768 26 | }, 27 | "transaction": { 28 | "representative_count": 1, 29 | "sampled": true, 30 | "result": "Success", 31 | "type": "unknown" 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/optional-timestamps.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"user": {"id": "123", "email": "s@test.com", "username": "john"}, "process": {"ppid": 6789, "pid": 1234,"argv": ["node", "server.js"], "title": "node"}, "system": {"platform": "darwin", "hostname": "prod1.example.com", "architecture": "x64"}, "service": {"name": "backendspans", "language": {"version": "8", "name": "ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node"}, "environment": "staging", "framework": {"version": "1.2.3", "name": "Express"}, "version": "5.1.3", "runtime": {"version": "8.0.0", "name": "node"}}}} 2 | {"transaction": {"name": "tx1", "id": "1111222233334444", "trace_id": "abcdefabcdef01234567890123456789", "duration": 12, "type": "request", "span_count": { "started": 14 }}} 3 | {"span": {"name": "sp1","trace_id": "abcdefabcdef01234567890123456789", "duration": 20, "start": 10, "type": "db", "id": "0147258369abcdef", "transaction_id": "fedcba0123456789", "parent_id": "012345654321123"}} 4 | {"metricset": {"samples": {"my-metric": {"value": 99}}, "timestamp": 1514804400000000}} 5 | -------------------------------------------------------------------------------- /model/modeljson/internal/child.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | // Child holds information about the children of a trace event. 21 | type Child struct { 22 | // ID holds IDs of child events. 23 | ID []string `json:"id,omitempty"` 24 | } 25 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/minimal.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": { "service": {"name": "1234_service-12a3", "agent": {"version": "3.14.0", "name": "elastic-node"}}}} 2 | {"error": {"id": "abcdef0123456789", "log": {"message": "error log message"}}} 3 | {"error": {"id": "abcdef0123456790", "exception": {"message": "error exception message"}}} 4 | {"error": {"id": "abcdef0123456791", "exception": {"type": "error exception type"}}} 5 | {"span": {"id": "0123456a89012345", "trace_id": "0123456789abcdef0123456789abcdef", "parent_id": "ab23456a89012345", "name": "GET /api/types", "type": "request", "start": 1.845, "duration": 3.5642981}} 6 | {"span": {"id": "0123456a89012345", "trace_id": "0123456789abcdef0123456789abcdef", "parent_id": "ab23456a89012345", "name": "GET /api/types", "type": "request", "timestamp": 1535655207154000, "duration": 3.5642981}} 7 | {"transaction": {"trace_id": "01234567890123456789abcdefabcdef", "id": "abcdef1478523690", "type": "request", "duration": 32.592981, "span_count": {"started": 0}}} 8 | {"metricset": {"samples":{"a":{"value":3.2}}, "timestamp": 1496170422281000}} 9 | -------------------------------------------------------------------------------- /model/proto/session.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Session { 25 | string id = 1; 26 | uint64 sequence = 2; 27 | } 28 | -------------------------------------------------------------------------------- /model/proto/useragent.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message UserAgent { 25 | string original = 1; 26 | string name = 2; 27 | } 28 | -------------------------------------------------------------------------------- /model/proto/destination.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Destination { 25 | string address = 1; 26 | uint32 port = 2; 27 | } 28 | -------------------------------------------------------------------------------- /model/proto/headers.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message HTTPHeader { 25 | string key = 1; 26 | repeated string value = 2; 27 | } 28 | -------------------------------------------------------------------------------- /dev_docs/OVERVIEW.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | ## Directories 4 | 5 | - `input/` 6 | - Struct definitions of input models, e.g. Intake v2, RUM v3, OTel 7 | - Decoding and translation logic from these input models to the internal model `APMEvent` 8 | - `model/proto` 9 | - Protobuf definitions of the internal model `APMEvent` 10 | - `model/modelpb` 11 | - Struct definitions of the internal model `APMEvent` 12 | - Automatically generated from the protobuf definitions 13 | - `model/internal/modeljson` 14 | - JSON serialization logic for indexing into Elasticsearch 15 | 16 | ## Data Flow (APM Server) 17 | 18 | 1. As an event is sent from an agent to APM server, it is deserialized to an input model (e.g. Intake v2, RUM v3, OTel). 19 | 2. The input model will then be decoded and translated to the internal model `APMEvent`. 20 | 3. The `APMEvent` is used throughout APM server for all processing and aggregation. 21 | 4. The internal model `APMEvent` is converted to modeljson. 22 | 4. At last, modeljson will be serialized into JSON and indexed into Elasticsearch. 23 | 24 | (All of the above is done in batches.) 25 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_data_stream.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "data_stream": { 10 | "dataset": "1", 11 | "namespace": "2" 12 | }, 13 | "event": { 14 | "outcome": "success" 15 | }, 16 | "host": { 17 | "hostname": "host-abc" 18 | }, 19 | "service": { 20 | "language": { 21 | "name": "unknown" 22 | }, 23 | "name": "unknown" 24 | }, 25 | "timestamp": { 26 | "us": 1576500418000768 27 | }, 28 | "transaction": { 29 | "representative_count": 1, 30 | "result": "Success", 31 | "sampled": true, 32 | "type": "unknown" 33 | } 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /model/modeljson/internal/user.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type User struct { 21 | Domain string `json:"domain,omitempty"` 22 | ID string `json:"id,omitempty"` 23 | Email string `json:"email,omitempty"` 24 | Name string `json:"name,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /model/proto/datastream.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message DataStream { 25 | string type = 1; 26 | string dataset = 2; 27 | string namespace = 3; 28 | } 29 | -------------------------------------------------------------------------------- /model/proto/user.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message User { 25 | string domain = 1; 26 | string id = 2; 27 | string email = 3; 28 | string name = 4; 29 | } 30 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_client_ip_from_forwarded_header.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": { 10 | "Forwarded": [ 11 | "for=192.13.14.5" 12 | ], 13 | "X-Forwarded-For": [ 14 | "178.3.11.17" 15 | ] 16 | }, 17 | "Method": "post", 18 | "Socket": { 19 | "Encrypted": false, 20 | "RemoteAddress": "10.1.23.5" 21 | } 22 | }, 23 | "Response": null, 24 | "Version": null 25 | }, 26 | "Labels": null, 27 | "Message": null, 28 | "Page": null, 29 | "URL": { 30 | "Domain": null, 31 | "Fragment": null, 32 | "Full": null, 33 | "Original": null, 34 | "Path": null, 35 | "Port": null, 36 | "Query": null, 37 | "Scheme": null 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/test_approved_model/context_client_ip_header_case_insensitive.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "Custom": null, 3 | "Experimental": null, 4 | "Http": { 5 | "Request": { 6 | "Body": null, 7 | "Cookies": null, 8 | "Env": null, 9 | "Headers": { 10 | "X-Forwarded-For": [ 11 | "178.3.11.17" 12 | ], 13 | "X-Real-Ip": [ 14 | "192.13.14.5" 15 | ] 16 | }, 17 | "Method": "post", 18 | "Socket": { 19 | "Encrypted": false, 20 | "RemoteAddress": "10.1.23.5" 21 | } 22 | }, 23 | "Response": null, 24 | "Version": null 25 | }, 26 | "Labels": null, 27 | "Message": null, 28 | "Page": null, 29 | "URL": { 30 | "Domain": null, 31 | "Fragment": null, 32 | "Full": null, 33 | "Original": null, 34 | "Path": null, 35 | "Port": null, 36 | "Query": null, 37 | "Scheme": null 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /model/modeljson/internal/client.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | // Client holds information about the client of a request. 21 | type Client struct { 22 | IP string `json:"ip,omitempty"` 23 | Domain string `json:"domain,omitempty"` 24 | Port int `json:"port,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /model/modeljson/internal/observer.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Observer struct { 21 | Hostname string `json:"hostname,omitempty"` 22 | Name string `json:"name,omitempty"` 23 | Type string `json:"type,omitempty"` 24 | Version string `json:"version,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /model/proto/client.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "ip.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message Client { 27 | IP ip = 1; 28 | string domain = 2; 29 | uint32 port = 3; 30 | } 31 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/metadata_jaeger-version.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger/PHP", 7 | "version": "3.4.12" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "service": { 13 | "language": { 14 | "name": "PHP" 15 | }, 16 | "name": "unknown" 17 | }, 18 | "span": { 19 | "id": "0000000041414646" 20 | }, 21 | "timestamp": { 22 | "us": 1576500418000768 23 | }, 24 | "trace": { 25 | "id": "00000000000000000000000046467830" 26 | }, 27 | "transaction": { 28 | "id": "0000000041414646", 29 | "representative_count": 1, 30 | "sampled": true, 31 | "result": "Success", 32 | "type": "unknown" 33 | } 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/bool.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | func generateJSONPropertyBool(info *fieldInfo, parent *property, child *property) error { 21 | child.Type.add(TypeNameBool) 22 | parent.Properties[jsonSchemaName(info.field)] = child 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/metadata_jaeger-no-language.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "3.4.12" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "service": { 13 | "language": { 14 | "name": "unknown" 15 | }, 16 | "name": "unknown" 17 | }, 18 | "span": { 19 | "id": "0000000041414646" 20 | }, 21 | "timestamp": { 22 | "us": 1576500418000768 23 | }, 24 | "trace": { 25 | "id": "00000000000000000000000046467830" 26 | }, 27 | "transaction": { 28 | "id": "0000000041414646", 29 | "representative_count": 1, 30 | "sampled": true, 31 | "result": "Success", 32 | "type": "unknown" 33 | } 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /model/proto/observer.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Observer { 25 | string hostname = 1; 26 | string name = 2; 27 | string type = 3; 28 | string version = 4; 29 | } 30 | -------------------------------------------------------------------------------- /model/proto/agent.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Agent { 25 | string name = 1; 26 | string version = 2; 27 | string ephemeral_id = 3; 28 | string activation_method = 4; 29 | } 30 | -------------------------------------------------------------------------------- /model/proto/keyvalue.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "google/protobuf/struct.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message KeyValue { 27 | string key = 1; 28 | google.protobuf.Value value = 2; 29 | } 30 | -------------------------------------------------------------------------------- /model/proto/os.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message OS { 25 | string name = 1; 26 | string version = 2; 27 | string platform = 3; 28 | string full = 4; 29 | string type = 5; 30 | } 31 | -------------------------------------------------------------------------------- /model/proto/kubernetes.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Kubernetes { 25 | string namespace = 1; 26 | string node_name = 2; 27 | string pod_name = 3; 28 | string pod_uid = 4; 29 | } 30 | -------------------------------------------------------------------------------- /model/modeljson/internal/os.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type OS struct { 21 | Name string `json:"name,omitempty"` 22 | Version string `json:"version,omitempty"` 23 | Platform string `json:"platform,omitempty"` 24 | Full string `json:"full,omitempty"` 25 | Type string `json:"type,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/input.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeldecoder 19 | 20 | import ( 21 | "github.com/elastic/apm-data/model/modelpb" 22 | ) 23 | 24 | // Input holds the input required for decoding an event. 25 | type Input struct { 26 | // Base holds the base for decoding events. 27 | Base *modelpb.APMEvent 28 | } 29 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/transactions_spans_rum_2.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata":{"service":{"name":"apm-agent-js","version":"1.0.0","agent":{"name":"rum-js","version":"0.0.0"}}}} 2 | {"transaction":{"id":"611f4fa950f04631","type":"page-load","name":"transaction","duration":643,"context":{"page":{"referer":"http://localhost:8000/test/e2e/","url":"http://localhost:8000/test/e2e/general-usecase/"}},"trace_id":"611f4fa950f04631aaaaaaaaaaaaaaaa","span_count":{"started":1}}} 3 | {"span":{"timestamp":1512735530291000, "name":"transaction","type":"transaction","start":0,"duration":643,"stacktrace":[{"abs_path":"http://subdomain1.localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"test/e2e/general-usecase/bundle.js.map","function":"","lineno":1,"colno":18},{"abs_path":"http://subdomain2.localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"","lineno":1,"colno":18}],"context":{"http":{"url":"http://localhost:8000/test/e2e/general-usecase/span"}},"transaction_id":"611f4fa950f04631","parent_id":"611f4fa950f04631","trace_id":"611f4fa950f04631aaaaaaaaaaaaaaaa","id":"aaaaaaaaaaaaaaaa"}} 4 | -------------------------------------------------------------------------------- /model/proto/container.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Container { 25 | string id = 1; 26 | string name = 2; 27 | string runtime = 3; 28 | string image_name = 4; 29 | string image_tag = 5; 30 | } 31 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/span_jaeger_custom.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "duration": 79000000000, 11 | "outcome": "success" 12 | }, 13 | "host": { 14 | "hostname": "host-abc" 15 | }, 16 | "parent": { 17 | "id": "0000000058585858" 18 | }, 19 | "service": { 20 | "language": { 21 | "name": "unknown" 22 | }, 23 | "name": "unknown" 24 | }, 25 | "span": { 26 | "id": "0000000041414646", 27 | "representative_count": 1, 28 | "type": "unknown" 29 | }, 30 | "timestamp": { 31 | "us": 1576500418000768 32 | }, 33 | "trace": { 34 | "id": "00000000000000000000000046467830" 35 | } 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /model/proto/source.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "ip.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message Source { 27 | IP ip = 1; 28 | NAT nat = 2; 29 | string domain = 3; 30 | uint32 port = 4; 31 | } 32 | 33 | message NAT { 34 | IP ip = 1; 35 | } 36 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/transactions_spans_rum.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata":{"service":{"name":"apm-agent-js","version":"1.0.0","agent":{"name":"rum-js","version":"0.0.0"}},"network":{"connection":{"type":"5G"}}}} 2 | {"transaction":{"id":"611f4fa950f04631","type":"page-load","duration":643,"context":{"page":{"referer":"http://localhost:8000/test/e2e/","url":"http://localhost:8000/test/e2e/general-usecase/"}},"trace_id":"611f4fa950f04631aaaaaaaaaaaaaaaa","span_count":{"started":1},"experience":{"cls":1,"fid":2.0,"tbt":3.4,"ignored":5,"also":"ignored"}}} 3 | {"span":{"name":"transaction","type":"transaction","start":0,"duration":643,"stacktrace":[{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"test/e2e/general-usecase/bundle.js.map","function":"","lineno":1,"colno":18},{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"","lineno":1,"colno":18}],"context":{"http":{"url":"http://localhost:8000/test/e2e/general-usecase/span"}},"transaction_id":"611f4fa950f04631","parent_id":"611f4fa950f04631","trace_id":"611f4fa950f04631aaaaaaaaaaaaaaaa","id":"aaaaaaaaaaaaaaaa"}} 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := all 2 | all: generate-modelpb generate gomodtidy update-licenses fieldalignment fmt protolint 3 | 4 | test: 5 | go test -v -race ./... 6 | 7 | fmt: 8 | go run golang.org/x/tools/cmd/goimports@v0.31.0 -w . 9 | 10 | protolint: 11 | docker run --volume "$(PWD):/workspace" --workdir /workspace bufbuild/buf lint model/proto 12 | docker run --volume "$(PWD):/workspace" --workdir /workspace bufbuild/buf breaking model/proto --against https://github.com/elastic/apm-data.git#branch=main,subdir=model/proto 13 | 14 | gomodtidy: 15 | go mod tidy -v 16 | 17 | generate_code: 18 | go generate ./... 19 | 20 | generate: generate_code update-licenses 21 | 22 | fieldalignment: 23 | go run golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@v0.31.0 -test=false $(shell go list ./... | grep -v modeldecoder/generator | grep -v test | grep -v model/modelpb) 24 | 25 | update-licenses: 26 | go run github.com/elastic/go-licenser@v0.4.2 -ext .go . 27 | go run github.com/elastic/go-licenser@v0.4.2 -ext .proto . 28 | 29 | install-protobuf: 30 | ./tools/install-protobuf.sh 31 | 32 | generate-modelpb: install-protobuf 33 | ./tools/generate-modelpb.sh 34 | @$(MAKE) update-licenses fmt 35 | -------------------------------------------------------------------------------- /model/proto/device.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Device { 25 | string id = 1; 26 | DeviceModel model = 2; 27 | string manufacturer = 3; 28 | } 29 | 30 | message DeviceModel { 31 | string name = 1; 32 | string identifier = 2; 33 | } 34 | -------------------------------------------------------------------------------- /model/modeljson/internal/agent.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | // Agent describes an Elastic APM agent. 21 | type Agent struct { 22 | Name string `json:"name,omitempty"` 23 | Version string `json:"version,omitempty"` 24 | EphemeralID string `json:"ephemeral_id,omitempty"` 25 | ActivationMethod string `json:"activation_method,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/metadata_jaeger_minimal.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "data_stream.dataset": "apm", 10 | "data_stream.type": "traces", 11 | "event": { 12 | "outcome": "success" 13 | }, 14 | "service": { 15 | "language": { 16 | "name": "unknown" 17 | }, 18 | "name": "unknown" 19 | }, 20 | "span": { 21 | "id": "41414646" 22 | }, 23 | "timestamp": { 24 | "us": 1576500418000768 25 | }, 26 | "trace": { 27 | "id": "46467830" 28 | }, 29 | "transaction": { 30 | "duration": { 31 | "us": 0 32 | }, 33 | "id": "41414646", 34 | "result": "Success", 35 | "sampled": true, 36 | "type": "custom" 37 | } 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /model/proto/url.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message URL { 25 | string original = 1; 26 | string scheme = 2; 27 | string full = 3; 28 | string domain = 4; 29 | string path = 5; 30 | string query = 6; 31 | string fragment = 7; 32 | uint32 port = 8; 33 | } 34 | -------------------------------------------------------------------------------- /model/proto/message.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "headers.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message Message { 27 | string body = 1; 28 | repeated HTTPHeader headers = 2; 29 | optional uint64 age_millis = 3; 30 | string queue_name = 4; 31 | string routing_key = 5; 32 | } 33 | -------------------------------------------------------------------------------- /model/modeljson/context.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import "github.com/elastic/apm-data/model/modelpb" 21 | 22 | // updateFields transforms in, returning a copy with sanitized keys, 23 | // suitable for storing as "custom" in transaction and error documents. 24 | func updateFields(in []*modelpb.KeyValue) { 25 | for _, kv := range in { 26 | kv.Key = sanitizeLabelKey(kv.Key) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /model/proto/faas.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Faas { 25 | string id = 1; 26 | optional bool cold_start = 2; 27 | string execution = 3; 28 | string trigger_type = 4; 29 | string trigger_request_id = 5; 30 | string name = 6; 31 | string version = 7; 32 | } 33 | -------------------------------------------------------------------------------- /input/otlp/trace_semaphore.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package otlp 19 | 20 | import ( 21 | "context" 22 | 23 | "go.opentelemetry.io/otel/trace" 24 | 25 | "github.com/elastic/apm-data/input" 26 | ) 27 | 28 | func semAcquire(ctx context.Context, tracer trace.Tracer, sem input.Semaphore, i int64) error { 29 | ctx, sp := tracer.Start(ctx, "Semaphore.Acquire") 30 | defer sp.End() 31 | 32 | return sem.Acquire(ctx, i) 33 | } 34 | -------------------------------------------------------------------------------- /model/modeljson/internal/destination.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Destination struct { 21 | Address string `json:"address,omitempty"` 22 | // TODO(axw) add a "convert" ingest processor to pipelines, 23 | // copying destination.address to destination.ip if it's a 24 | // valid IP, and remove this field. 25 | IP string `json:"ip,omitempty"` 26 | Port int `json:"port,omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /model/modeljson/internal/source.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Source struct { 21 | IP IP `json:"ip,omitempty"` 22 | NAT NAT `json:"nat,omitempty"` 23 | Domain string `json:"domain,omitempty"` 24 | Port int `json:"port,omitempty"` 25 | } 26 | 27 | type NAT struct { 28 | IP IP `json:"ip,omitempty"` 29 | } 30 | 31 | func (n NAT) isZero() bool { 32 | return n == NAT{} 33 | } 34 | -------------------------------------------------------------------------------- /model/modeljson/user.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func UserModelJSON(u *modelpb.User, out *modeljson.User) { 26 | *out = modeljson.User{ 27 | Domain: u.Domain, 28 | ID: u.Id, 29 | Email: u.Email, 30 | Name: u.Name, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /model/proto/labels.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message LabelValue { 25 | string value = 1; 26 | repeated string values = 2; 27 | bool global = 3; 28 | } 29 | 30 | message NumericLabelValue { 31 | repeated double values = 1; 32 | double value = 2; 33 | bool global = 3; 34 | } 35 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_type_messaging.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "host": { 13 | "hostname": "host-abc" 14 | }, 15 | "parent": { 16 | "id": "0000000061626364" 17 | }, 18 | "service": { 19 | "language": { 20 | "name": "unknown" 21 | }, 22 | "name": "unknown" 23 | }, 24 | "timestamp": { 25 | "us": 1576500418000768 26 | }, 27 | "transaction": { 28 | "message": { 29 | "queue": { 30 | "name": "queue-abc" 31 | } 32 | }, 33 | "representative_count": 1, 34 | "result": "Success", 35 | "sampled": true, 36 | "type": "messaging" 37 | } 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /model/modeljson/client.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func ClientModelJSON(c *modelpb.Client, out *modeljson.Client) { 26 | *out = modeljson.Client{ 27 | Domain: c.Domain, 28 | Port: int(c.Port), 29 | } 30 | out.IP = modelpb.IP2String(c.Ip) 31 | } 32 | -------------------------------------------------------------------------------- /model/proto/host.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "os.proto"; 23 | import "ip.proto"; 24 | 25 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 26 | 27 | message Host { 28 | OS os = 1; 29 | string hostname = 2; 30 | string name = 3; 31 | string id = 4; 32 | string architecture = 5; 33 | string type = 6; 34 | repeated IP ip = 7; 35 | } 36 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/metadata.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata":{"service":{"name":"1234_service-12a3","node":{"configured_name":"node-123"},"version":"5.1.3","environment":"staging","language":{"name":"ecmascript","version":"8"},"runtime":{"name":"node","version":"8.0.0"},"framework":{"name":"Express","version":"1.2.3"},"agent":{"name":"elastic-node","version":"3.14.0","ephemeral_id":"e71be9ac-93b0-44b9-a997-5638f6ccfc36"}},"user":{"domain":"ldap://abc","id":"123user","username":"bar","email":"bar@user.com"},"system":{"hostname":"prod1.example.com","configured_hostname":"prod1.example.com","detected_hostname":"prod1.example.com","architecture":"x64","ip":"127.0.0.1","platform":"darwin","container":{"id":"container-id"},"kubernetes":{"namespace":"namespace1","pod":{"uid":"pod-uid","name":"pod-name"},"node":{"name":"node-name"}}},"process":{"pid":1234,"ppid":6789,"title":"node","argv":["node","server.js"]},"labels":{"tag0":null,"tag1":"one","tag2":2},"cloud":{"account":{"id":"account_id","name":"account_name"},"availability_zone":"cloud_availability_zone","instance":{"id":"instance_id","name":"instance_name"},"machine":{"type":"machine_type"},"project":{"id":"project_id","name":"project_name"},"provider":"cloud_provider","region":"cloud_region","service":{"name":"lambda"}}}} 2 | -------------------------------------------------------------------------------- /model/modeljson/os.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func OSModelJSON(o *modelpb.OS, out *modeljson.OS) { 26 | *out = modeljson.OS{ 27 | Name: o.Name, 28 | Version: o.Version, 29 | Platform: o.Platform, 30 | Full: o.Full, 31 | Type: o.Type, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /model/modeljson/observer.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func ObserverModelJSON(o *modelpb.Observer, out *modeljson.Observer) { 26 | *out = modeljson.Observer{ 27 | Hostname: o.Hostname, 28 | Name: o.Name, 29 | Type: o.Type, 30 | Version: o.Version, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/span_jaeger_subtype_component.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "duration": 79000000000, 11 | "outcome": "success" 12 | }, 13 | "host": { 14 | "hostname": "host-abc" 15 | }, 16 | "labels": { 17 | "component": "whatever" 18 | }, 19 | "parent": { 20 | "id": "0000000058585858" 21 | }, 22 | "service": { 23 | "language": { 24 | "name": "unknown" 25 | }, 26 | "name": "unknown" 27 | }, 28 | "span": { 29 | "id": "0000000041414646", 30 | "representative_count": 1, 31 | "type": "unknown" 32 | }, 33 | "timestamp": { 34 | "us": 1576500418000768 35 | }, 36 | "trace": { 37 | "id": "00000000000000000000000046467830" 38 | } 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /model/modelpb/timestamp.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelpb 19 | 20 | import "time" 21 | 22 | // FromTime converts a time.Time to uint64 nanoseconds since Unix epoch. 23 | func FromTime(t time.Time) uint64 { 24 | return uint64(t.UnixNano()) 25 | } 26 | 27 | // ToTime converts uint64 nanoseconds since Unix epoch to a time.Time. 28 | func ToTime(v uint64) time.Time { 29 | return time.Unix(int64(v/uint64(time.Second)), int64(v%uint64(time.Second))).UTC() 30 | } 31 | -------------------------------------------------------------------------------- /model/modeljson/internal/host.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Host struct { 21 | OS *OS `json:"os,omitempty"` 22 | Hostname string `json:"hostname,omitempty"` 23 | Name string `json:"name,omitempty"` 24 | ID string `json:"id,omitempty"` 25 | Architecture string `json:"architecture,omitempty"` 26 | Type string `json:"type,omitempty"` 27 | IP []string `json:"ip,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /model/proto/log.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Log { 25 | string level = 1; 26 | string logger = 2; 27 | LogOrigin origin = 3; 28 | } 29 | 30 | message LogOrigin { 31 | string function_name = 1; 32 | LogOriginFile file = 2; 33 | } 34 | 35 | message LogOriginFile { 36 | string name = 1; 37 | uint32 line = 2; 38 | } 39 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/span_jaeger_data_stream.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "data_stream": { 10 | "dataset": "1", 11 | "namespace": "2" 12 | }, 13 | "event": { 14 | "duration": 79000000000, 15 | "outcome": "success" 16 | }, 17 | "host": { 18 | "hostname": "host-abc" 19 | }, 20 | "parent": { 21 | "id": "0000000058585858" 22 | }, 23 | "service": { 24 | "language": { 25 | "name": "unknown" 26 | }, 27 | "name": "unknown" 28 | }, 29 | "span": { 30 | "id": "0000000041414646", 31 | "representative_count": 1, 32 | "type": "unknown" 33 | }, 34 | "timestamp": { 35 | "us": 1576500418000768 36 | }, 37 | "trace": { 38 | "id": "00000000000000000000000046467830" 39 | } 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /model/modeljson/internal/url.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type URL struct { 21 | Original string `json:"original,omitempty"` 22 | Scheme string `json:"scheme,omitempty"` 23 | Full string `json:"full,omitempty"` 24 | Domain string `json:"domain,omitempty"` 25 | Path string `json:"path,omitempty"` 26 | Query string `json:"query,omitempty"` 27 | Fragment string `json:"fragment,omitempty"` 28 | Port int `json:"port,omitempty"` 29 | } 30 | -------------------------------------------------------------------------------- /tools/install-protobuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PLATFORM=$(go env GOOS) 4 | PROTOBUF_VERSION="28.3" 5 | DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download" 6 | 7 | if [ "${PLATFORM}" = "darwin" ]; then 8 | PROTOBUF_URL="${DOWNLOAD_URL}/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-osx-x86_64.zip" 9 | elif [ "${PLATFORM}" = "linux" ]; then 10 | PROTOBUF_URL="${DOWNLOAD_URL}/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" 11 | elif [ "${PLATFORM}" = "windows" ]; then 12 | PROTOBUF_URL="${DOWNLOAD_URL}/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-win64.zip" 13 | else 14 | echo "Unsupported platform: ${PLATFORM}" 15 | exit 1 16 | fi 17 | 18 | TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") 19 | BUILD_DIR="${TOOLS_DIR}/build" 20 | PROTOBUF_ZIP="/tmp/protobuf.zip" 21 | 22 | curl -L "${PROTOBUF_URL}" -o "${PROTOBUF_ZIP}" 23 | 24 | if ! unzip -o "${PROTOBUF_ZIP}" -d "${BUILD_DIR}"; then 25 | echo "failed to extract protobuf" 26 | exit 1 27 | fi 28 | 29 | if ! PATH="${BUILD_DIR}/bin" protoc --version; then 30 | echo "failed to verify protobuf installation" 31 | exit 1 32 | fi 33 | 34 | GOBIN="${BUILD_DIR}/bin" go install "google.golang.org/protobuf/cmd/protoc-gen-go" 35 | GOBIN="${BUILD_DIR}/bin" go install "github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto" 36 | -------------------------------------------------------------------------------- /model/modeljson/agent.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func AgentModelJSON(a *modelpb.Agent, out *modeljson.Agent) { 26 | *out = modeljson.Agent{ 27 | Name: a.Name, 28 | Version: a.Version, 29 | EphemeralID: a.EphemeralId, 30 | ActivationMethod: a.ActivationMethod, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /model/proto/experience.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message UserExperience { 25 | double cumulative_layout_shift = 1; 26 | double first_input_delay = 2; 27 | double total_blocking_time = 3; 28 | LongtaskMetrics long_task = 4; 29 | } 30 | 31 | message LongtaskMetrics { 32 | uint64 count = 1; 33 | double sum = 2; 34 | double max = 3; 35 | } 36 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/modeldecodertest/strbuilder.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeldecodertest 19 | 20 | import "strings" 21 | 22 | // BuildString creates a string conisisting of nRunes runes 23 | func BuildString(nRunes int) string { 24 | return BuildStringWith(nRunes, '⌘') 25 | } 26 | 27 | // BuildStringWith creates a string conisisting of nRunes of the given rune 28 | func BuildStringWith(nRunes int, r rune) string { 29 | return strings.Repeat(string(r), nRunes) 30 | } 31 | -------------------------------------------------------------------------------- /model/modeljson/internal/ip.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | "net/netip" 22 | 23 | "go.elastic.co/fastjson" 24 | ) 25 | 26 | type IP netip.Addr 27 | 28 | func (i *IP) isZero() bool { 29 | return !((*netip.Addr)(i)).IsValid() 30 | } 31 | 32 | func (i *IP) MarshalFastJSON(w *fastjson.Writer) error { 33 | var space [32]byte 34 | addr := (*netip.Addr)(i) 35 | w.RawByte('"') 36 | w.RawBytes(addr.AppendTo(space[:0])) 37 | w.RawByte('"') 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /model/proto/process.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Process { 25 | uint32 ppid = 1; 26 | ProcessThread thread = 2; 27 | string title = 3; 28 | string command_line = 4; 29 | string executable = 5; 30 | repeated string argv = 6; 31 | uint32 pid = 7; 32 | } 33 | 34 | message ProcessThread { 35 | string name = 1; 36 | uint32 id = 2; 37 | } 38 | -------------------------------------------------------------------------------- /model/proto/network.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Network { 25 | NetworkConnection connection = 1; 26 | NetworkCarrier carrier = 2; 27 | } 28 | 29 | message NetworkConnection { 30 | string type = 1; 31 | string subtype = 2; 32 | } 33 | 34 | message NetworkCarrier { 35 | string name = 1; 36 | string mcc = 2; 37 | string mnc = 3; 38 | string icc = 4; 39 | } 40 | -------------------------------------------------------------------------------- /model/modeljson/internal/spanlink.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type SpanLink struct { 21 | Trace SpanLinkTrace `json:"trace,omitempty"` 22 | Span SpanLinkSpan `json:"span,omitempty"` 23 | } 24 | 25 | type SpanLinkTrace struct { 26 | ID string `json:"id"` 27 | } 28 | 29 | func (t SpanLinkTrace) isZero() bool { 30 | return t.ID == "" 31 | } 32 | 33 | type SpanLinkSpan struct { 34 | ID string `json:"id"` 35 | } 36 | 37 | func (s SpanLinkSpan) isZero() bool { 38 | return s.ID == "" 39 | } 40 | -------------------------------------------------------------------------------- /model/modeljson/container.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func ContainerModelJSON(c *modelpb.Container, out *modeljson.Container) { 26 | *out = modeljson.Container{ 27 | ID: c.Id, 28 | Name: c.Name, 29 | Runtime: c.Runtime, 30 | Image: modeljson.ContainerImage{ 31 | Name: c.ImageName, 32 | Tag: c.ImageTag, 33 | }, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /model/modeljson/internal/device.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Device struct { 21 | ID string `json:"id,omitempty"` 22 | Model DeviceModel `json:"model,omitempty"` 23 | Manufacturer string `json:"manufacturer,omitempty"` 24 | } 25 | 26 | type DeviceModel struct { 27 | Name string `json:"name,omitempty"` 28 | Identifier string `json:"identifier,omitempty"` 29 | } 30 | 31 | func (m *DeviceModel) isZero() bool { 32 | return m.Name == "" && m.Identifier == "" 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/label-elastic-pull-requests.yml: -------------------------------------------------------------------------------- 1 | name: "label-elastic-pull-requests" 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | safe-to-test: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Get token 15 | id: get_token 16 | uses: actions/create-github-app-token@v2 17 | with: 18 | app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }} 19 | private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }} 20 | permission-members: read 21 | permission-pull-requests: write 22 | - name: Check team membership for user 23 | uses: elastic/get-user-teams-membership@1.1.0 24 | id: checkUserMember 25 | with: 26 | username: ${{ github.actor }} 27 | team: 'apm' 28 | GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} 29 | - name: Add safe-to-test label 30 | uses: actions/github-script@v8 31 | if: steps.checkUserMember.outputs.isTeamMember == 'true' 32 | with: 33 | github-token: ${{ steps.get_token.outputs.token }} 34 | script: | 35 | github.rest.issues.addLabels({ 36 | issue_number: context.issue.number, 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | labels: ["safe-to-test"] 40 | }) 41 | -------------------------------------------------------------------------------- /model/modeljson/source.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func SourceModelJSON(s *modelpb.Source, out *modeljson.Source) { 26 | *out = modeljson.Source{ 27 | Domain: s.Domain, 28 | Port: int(s.Port), 29 | } 30 | out.IP = modeljson.IP(modelpb.IP2Addr(s.Ip)) 31 | if s.Nat != nil { 32 | out.NAT.IP = modeljson.IP(modelpb.IP2Addr(s.Nat.Ip)) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /model/modeljson/url.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func URLModelJSON(u *modelpb.URL, out *modeljson.URL) { 26 | *out = modeljson.URL{ 27 | Original: u.Original, 28 | Scheme: u.Scheme, 29 | Full: u.Full, 30 | Domain: u.Domain, 31 | Path: u.Path, 32 | Query: u.Query, 33 | Fragment: u.Fragment, 34 | Port: int(u.Port), 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/modeldecoderutil/exception.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeldecoderutil 19 | 20 | import ( 21 | "encoding/json" 22 | "strconv" 23 | ) 24 | 25 | // ExceptionCodeString formats the exception code v as a string. 26 | func ExceptionCodeString(v interface{}) string { 27 | switch v := v.(type) { 28 | case int: 29 | return strconv.Itoa(v) 30 | case float64: 31 | return strconv.Itoa(int(v)) 32 | case string: 33 | return v 34 | case json.Number: 35 | return v.String() 36 | } 37 | return "" 38 | } 39 | -------------------------------------------------------------------------------- /codec/json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | // Package json provides a JSON codec with an encoder/decoder. 19 | package codec 20 | 21 | import ( 22 | "encoding/json" 23 | ) 24 | 25 | // JSON wraps the standard json library. 26 | type JSON struct{} 27 | 28 | // Encode encodes a type into the JSON byte slice representation. 29 | func (j JSON) Encode(in any) ([]byte, error) { return json.Marshal(in) } 30 | 31 | // Decode decodes a JSON-encoded byte slice into its type. 32 | func (j JSON) Decode(in []byte, out any) error { 33 | return json.Unmarshal(in, out) 34 | } 35 | -------------------------------------------------------------------------------- /model/modeljson/internal/container.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Container struct { 21 | ID string `json:"id,omitempty"` 22 | Name string `json:"name,omitempty"` 23 | Runtime string `json:"runtime,omitempty"` 24 | Image ContainerImage `json:"image,omitempty"` 25 | } 26 | 27 | type ContainerImage struct { 28 | Name string `json:"name,omitempty"` 29 | Tag string `json:"tag,omitempty"` 30 | } 31 | 32 | func (c *ContainerImage) isZero() bool { 33 | return c.Name == "" && c.Tag == "" 34 | } 35 | -------------------------------------------------------------------------------- /model/modeljson/kubernetes.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func KubernetesModelJSON(k *modelpb.Kubernetes, out *modeljson.Kubernetes) { 26 | *out = modeljson.Kubernetes{ 27 | Namespace: k.Namespace, 28 | Node: modeljson.KubernetesNode{ 29 | Name: k.NodeName, 30 | }, 31 | Pod: modeljson.KubernetesPod{ 32 | Name: k.PodName, 33 | UID: k.PodUid, 34 | }, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /model/proto/system.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message System { 25 | SystemProcess process = 1; 26 | SystemFilesystem filesystem = 2; 27 | } 28 | 29 | message SystemProcess { 30 | SystemProcessCPU cpu = 1; 31 | string state = 2; 32 | string cmdline = 3; 33 | } 34 | 35 | message SystemProcessCPU { 36 | string start_time = 1; 37 | } 38 | 39 | message SystemFilesystem { 40 | string mount_point = 1; 41 | } 42 | -------------------------------------------------------------------------------- /model/modeljson/device.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func DeviceModelJSON(d *modelpb.Device, out *modeljson.Device) { 26 | *out = modeljson.Device{ 27 | ID: d.Id, 28 | Manufacturer: d.Manufacturer, 29 | } 30 | if d.Model != nil { 31 | out.Model = modeljson.DeviceModel{ 32 | Name: d.Model.Name, 33 | Identifier: d.Model.Identifier, 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /model/modeljson/labels.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import "strings" 21 | 22 | // Label keys are sanitized, replacing the reserved characters '.', '*' and '"' 23 | // with '_'. Null-valued labels are omitted. 24 | 25 | func sanitizeLabelKey(k string) string { 26 | if strings.ContainsAny(k, ".*\"") { 27 | return strings.Map(replaceReservedLabelKeyRune, k) 28 | } 29 | return k 30 | } 31 | 32 | func replaceReservedLabelKeyRune(r rune) rune { 33 | switch r { 34 | case '.', '*', '"': 35 | return '_' 36 | } 37 | return r 38 | } 39 | -------------------------------------------------------------------------------- /model/modeljson/destination.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | "net/netip" 22 | 23 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 24 | "github.com/elastic/apm-data/model/modelpb" 25 | ) 26 | 27 | func DestinationModelJSON(d *modelpb.Destination, out *modeljson.Destination) { 28 | *out = modeljson.Destination{ 29 | Address: d.Address, 30 | Port: int(d.Port), 31 | } 32 | if d.Address != "" { 33 | if _, err := netip.ParseAddr(d.Address); err == nil { 34 | out.IP = d.Address 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /model/modeljson/faas.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func FaasModelJSON(f *modelpb.Faas, out *modeljson.FAAS) { 26 | *out = modeljson.FAAS{ 27 | ID: f.Id, 28 | Name: f.Name, 29 | Version: f.Version, 30 | Execution: f.Execution, 31 | Coldstart: f.ColdStart, 32 | Trigger: modeljson.FAASTrigger{ 33 | Type: f.TriggerType, 34 | RequestID: f.TriggerRequestId, 35 | }, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /model/modeljson/message.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func MessageModelJSON(m *modelpb.Message, out *modeljson.Message) { 26 | *out = modeljson.Message{ 27 | Body: m.Body, 28 | Age: modeljson.MessageAge{Millis: m.AgeMillis}, 29 | Queue: modeljson.MessageQueue{Name: m.QueueName}, 30 | RoutingKey: m.RoutingKey, 31 | } 32 | if n := len(m.Headers); n > 0 { 33 | out.Headers = m.Headers 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_type_request_result.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "outcome": "success" 11 | }, 12 | "host": { 13 | "hostname": "host-abc" 14 | }, 15 | "http": { 16 | "response": { 17 | "status_code": 200 18 | } 19 | }, 20 | "parent": { 21 | "id": "0000000061626364" 22 | }, 23 | "service": { 24 | "language": { 25 | "name": "unknown" 26 | }, 27 | "name": "unknown" 28 | }, 29 | "timestamp": { 30 | "us": 1576500418000768 31 | }, 32 | "transaction": { 33 | "representative_count": 1, 34 | "result": "HTTP 2xx", 35 | "sampled": true, 36 | "type": "request" 37 | }, 38 | "url": { 39 | "domain": "host-abc", 40 | "full": "localhost:8080", 41 | "original": "localhost:8080", 42 | "scheme": "localhost" 43 | } 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /model/modelprocessor/chained.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/elastic/apm-data/model/modelpb" 24 | ) 25 | 26 | // Chained is a chained modelpb.BatchProcessor, calling each of 27 | // the processors in the slice in series. 28 | type Chained []modelpb.BatchProcessor 29 | 30 | // ProcessBatch calls each of the processors in c in series. 31 | func (c Chained) ProcessBatch(ctx context.Context, batch *modelpb.Batch) error { 32 | for _, p := range c { 33 | if err := p.ProcessBatch(ctx, batch); err != nil { 34 | return err 35 | } 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/metadata_jaeger.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "ephemeral_id": "xxf0", 7 | "name": "Jaeger/C++", 8 | "version": "3.2.1" 9 | }, 10 | "event": { 11 | "outcome": "success" 12 | }, 13 | "host": { 14 | "hostname": "host-foo", 15 | "ip": [ 16 | "17.0.10.123" 17 | ] 18 | }, 19 | "labels": { 20 | "foo": "bar", 21 | "peer_port": "80" 22 | }, 23 | "service": { 24 | "language": { 25 | "name": "C++" 26 | }, 27 | "name": "foo" 28 | }, 29 | "span": { 30 | "id": "0000000041414646" 31 | }, 32 | "timestamp": { 33 | "us": 1576500418000768 34 | }, 35 | "trace": { 36 | "id": "00000000000000000000000046467830" 37 | }, 38 | "transaction": { 39 | "id": "0000000041414646", 40 | "representative_count": 1, 41 | "sampled": true, 42 | "result": "Success", 43 | "type": "unknown" 44 | } 45 | } 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /input/otlp/timestamps.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package otlp 19 | 20 | import ( 21 | "time" 22 | 23 | "go.opentelemetry.io/collector/pdata/pcommon" 24 | ) 25 | 26 | // exportTimestamp extracts the `telemetry.sdk.elastic_export_timestamp` 27 | // resource attribute as a timestamp, and returns a boolean indicating 28 | // whether the attribute was found. 29 | func exportTimestamp(resource pcommon.Resource) (time.Time, bool) { 30 | attr, ok := resource.Attributes().Get("telemetry.sdk.elastic_export_timestamp") 31 | if !ok { 32 | return time.Time{}, false 33 | } 34 | nsec := attr.Int() 35 | return time.Unix(0, nsec), nsec > 0 36 | } 37 | -------------------------------------------------------------------------------- /model/proto/event.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "metricset.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message Event { 27 | string outcome = 1; 28 | string action = 2; 29 | string dataset = 3; 30 | 31 | string kind = 4; 32 | string category = 5; 33 | string type = 6; 34 | 35 | SummaryMetric success_count = 7; 36 | 37 | // nanoseconds 38 | uint64 duration = 8; 39 | 40 | uint64 severity = 9; 41 | 42 | // nanoseconds since epoch 43 | uint64 received = 10; 44 | 45 | string module = 11; 46 | } 47 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/modeldecoderutil/keyvaluepb.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeldecoderutil 19 | 20 | import ( 21 | "github.com/elastic/apm-data/model/modelpb" 22 | "google.golang.org/protobuf/types/known/structpb" 23 | ) 24 | 25 | func ToKv(m map[string]any) []*modelpb.KeyValue { 26 | m = normalizeMap(m) 27 | if len(m) == 0 { 28 | return nil 29 | } 30 | 31 | out := make([]*modelpb.KeyValue, len(m)) 32 | 33 | i := 0 34 | for k, v := range m { 35 | value, _ := structpb.NewValue(v) 36 | out[i] = &modelpb.KeyValue{ 37 | Key: k, 38 | Value: value, 39 | } 40 | i++ 41 | } 42 | 43 | return out 44 | } 45 | -------------------------------------------------------------------------------- /model/modeljson/internal/faas.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type FAAS struct { 21 | ID string `json:"id,omitempty"` 22 | Name string `json:"name,omitempty"` 23 | Version string `json:"version,omitempty"` 24 | Execution string `json:"execution,omitempty"` 25 | Coldstart *bool `json:"coldstart,omitempty"` 26 | Trigger FAASTrigger `json:"trigger,omitempty"` 27 | } 28 | 29 | type FAASTrigger struct { 30 | Type string `json:"type,omitempty"` 31 | RequestID string `json:"request_id,omitempty"` 32 | } 33 | 34 | func (t *FAASTrigger) isZero() bool { 35 | return t.Type == "" && t.RequestID == "" 36 | } 37 | -------------------------------------------------------------------------------- /model/modeljson/log.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func LogModelJSON(l *modelpb.Log, out *modeljson.Log) { 26 | *out = modeljson.Log{ 27 | Level: l.Level, 28 | Logger: l.Logger, 29 | } 30 | if l.Origin != nil { 31 | out.Origin = modeljson.LogOrigin{ 32 | Function: l.Origin.FunctionName, 33 | } 34 | if l.Origin.File != nil { 35 | out.Origin.File = modeljson.LogOriginFile{ 36 | Name: l.Origin.File.Name, 37 | Line: int(l.Origin.File.Line), 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/httpheader.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | func generateJSONPropertyHTTPHeader(info *fieldInfo, parent *property, child *property) error { 21 | child.Type.add(TypeNameObject) 22 | child.PatternProperties = make(map[string]*property) 23 | child.PatternProperties[patternHTTPHeaders] = &property{ 24 | Type: &propertyType{names: []propertyTypeName{TypeNameArray, TypeNameString}}, 25 | Items: &property{Type: &propertyType{names: []propertyTypeName{TypeNameString}, required: true}}} 26 | child.AdditionalProperties = new(bool) 27 | parent.Properties[jsonSchemaName(info.field)] = child 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /model/modeljson/internal/kubernetes.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Kubernetes struct { 21 | Namespace string `json:"namespace,omitempty"` 22 | Node KubernetesNode `json:"node,omitempty"` 23 | Pod KubernetesPod `json:"pod,omitempty"` 24 | } 25 | 26 | type KubernetesNode struct { 27 | Name string `json:"name,omitempty"` 28 | } 29 | 30 | func (n *KubernetesNode) isZero() bool { 31 | return n.Name == "" 32 | } 33 | 34 | type KubernetesPod struct { 35 | Name string `json:"name,omitempty"` 36 | UID string `json:"uid,omitempty"` 37 | } 38 | 39 | func (p *KubernetesPod) isZero() bool { 40 | return p.Name == "" && p.UID == "" 41 | } 42 | -------------------------------------------------------------------------------- /model/modeljson/internal/keyvalue.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | "github.com/elastic/apm-data/model/modelpb" 22 | "go.elastic.co/fastjson" 23 | ) 24 | 25 | type KeyValueSlice []*modelpb.KeyValue 26 | 27 | func (s *KeyValueSlice) MarshalFastJSON(w *fastjson.Writer) error { 28 | var firstErr error 29 | w.RawByte('{') 30 | { 31 | for i, kv := range *s { 32 | if i != 0 { 33 | w.RawByte(',') 34 | } 35 | w.String(kv.Key) 36 | w.RawByte(':') 37 | if err := fastjson.Marshal(w, kv.Value.AsInterface()); err != nil && firstErr == nil { 38 | firstErr = err 39 | } 40 | } 41 | } 42 | w.RawByte('}') 43 | return firstErr 44 | } 45 | -------------------------------------------------------------------------------- /model/modeljson/internal/httpheader.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | "github.com/elastic/apm-data/model/modelpb" 22 | "go.elastic.co/fastjson" 23 | ) 24 | 25 | type HTTPHeaders []*modelpb.HTTPHeader 26 | 27 | func (s *HTTPHeaders) MarshalFastJSON(w *fastjson.Writer) error { 28 | w.RawByte('{') 29 | { 30 | for i, kv := range *s { 31 | if i != 0 { 32 | w.RawByte(',') 33 | } 34 | w.String(kv.Key) 35 | w.RawByte(':') 36 | w.RawByte('[') 37 | for i, v := range kv.Value { 38 | if i != 0 { 39 | w.RawByte(',') 40 | } 41 | w.String(v) 42 | } 43 | w.RawByte(']') 44 | } 45 | } 46 | w.RawByte('}') 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /model/modeljson/internal/log.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Log struct { 21 | Level string `json:"level,omitempty"` 22 | Logger string `json:"logger,omitempty"` 23 | Origin LogOrigin `json:"origin,omitempty"` 24 | } 25 | 26 | type LogOrigin struct { 27 | Function string `json:"function"` 28 | File LogOriginFile `json:"file"` 29 | } 30 | 31 | func (o *LogOrigin) isZero() bool { 32 | return o.Function == "" && o.File.isZero() 33 | } 34 | 35 | type LogOriginFile struct { 36 | Name string `json:"name,omitempty"` 37 | Line int `json:"line,omitempty"` 38 | } 39 | 40 | func (f *LogOriginFile) isZero() bool { 41 | return f.Name == "" && f.Line == 0 42 | } 43 | -------------------------------------------------------------------------------- /model/modeljson/experience.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func UserExperienceModelJSON(u *modelpb.UserExperience, out *modeljson.UserExperience) { 26 | *out = modeljson.UserExperience{ 27 | CumulativeLayoutShift: u.CumulativeLayoutShift, 28 | FirstInputDelay: u.FirstInputDelay, 29 | TotalBlockingTime: u.TotalBlockingTime, 30 | } 31 | if u.LongTask != nil { 32 | out.Longtask = modeljson.LongtaskMetrics{ 33 | Count: int(u.LongTask.Count), 34 | Sum: u.LongTask.Sum, 35 | Max: u.LongTask.Max, 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /model/modeljson/network.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func NetworkModelJSON(n *modelpb.Network, out *modeljson.Network) { 26 | *out = modeljson.Network{} 27 | if n.Connection != nil { 28 | out.Connection = modeljson.NetworkConnection{ 29 | Type: n.Connection.Type, 30 | Subtype: n.Connection.Subtype, 31 | } 32 | } 33 | if n.Carrier != nil { 34 | out.Carrier = modeljson.NetworkCarrier{ 35 | Name: n.Carrier.Name, 36 | MCC: n.Carrier.Mcc, 37 | MNC: n.Carrier.Mnc, 38 | ICC: n.Carrier.Icc, 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /model/modeljson/process.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func ProcessModelJSON(p *modelpb.Process, out *modeljson.Process) { 26 | *out = modeljson.Process{ 27 | Pid: int(p.Pid), 28 | Title: p.Title, 29 | CommandLine: p.CommandLine, 30 | Executable: p.Executable, 31 | Args: p.Argv, 32 | Parent: modeljson.ProcessParent{ 33 | Pid: p.Ppid, 34 | }, 35 | } 36 | if p.Thread != nil { 37 | out.Thread = modeljson.ProcessThread{ 38 | Name: p.Thread.Name, 39 | ID: int(p.Thread.Id), 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /model/modeljson/internal/message.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Message struct { 21 | Body string `json:"body,omitempty"` 22 | Age MessageAge `json:"age,omitempty"` 23 | Queue MessageQueue `json:"queue,omitempty"` 24 | RoutingKey string `json:"routing_key,omitempty"` 25 | Headers HTTPHeaders `json:"headers,omitempty"` 26 | } 27 | 28 | type MessageAge struct { 29 | Millis *uint64 `json:"ms,omitempty"` 30 | } 31 | 32 | func (a MessageAge) isZero() bool { 33 | return a.Millis == nil 34 | } 35 | 36 | type MessageQueue struct { 37 | Name string `json:"name,omitempty"` 38 | } 39 | 40 | func (q MessageQueue) isZero() bool { 41 | return q.Name == "" 42 | } 43 | -------------------------------------------------------------------------------- /model/modelprocessor/eventreceived.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/elastic/apm-data/model/modelpb" 24 | ) 25 | 26 | // RemoveEventReceived is a processor that removes event.received 27 | // field as it should not be indexed. 28 | type RemoveEventReceived struct{} 29 | 30 | // ProcessBatch removes event.received field for events. 31 | func (RemoveEventReceived) ProcessBatch(ctx context.Context, b *modelpb.Batch) error { 32 | for i := range *b { 33 | removeEventReceived((*b)[i]) 34 | } 35 | return nil 36 | } 37 | 38 | func removeEventReceived(event *modelpb.APMEvent) { 39 | if event.Event != nil { 40 | event.Event.Received = 0 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /model/proto/cloud.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Cloud { 25 | CloudOrigin origin = 1; 26 | string account_id = 2; 27 | string account_name = 3; 28 | string availability_zone = 4; 29 | string instance_id = 5; 30 | string instance_name = 6; 31 | string machine_type = 7; 32 | string project_id = 8; 33 | string project_name = 9; 34 | string provider = 10; 35 | string region = 11; 36 | string service_name = 12; 37 | } 38 | 39 | message CloudOrigin { 40 | string account_id = 1; 41 | string provider = 2; 42 | string region = 3; 43 | string service_name = 4; 44 | } 45 | -------------------------------------------------------------------------------- /input/semaphore.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package input 19 | 20 | import "context" 21 | 22 | // Semaphore is used by inputs to limit the number of concurrent requests 23 | type Semaphore interface { 24 | // Acquire acquires the semaphore with a weight of n, blocking until 25 | // resources are available or ctx is done. On success, returns nil. On 26 | // failure, returns ctx.Err() and leaves the semaphore unchanged. 27 | Acquire(context.Context, int64) error 28 | // TryAcquire acquires the semaphore with a weight of n without blocking. On 29 | // success, returns true. On failure, returns false and leaves the semaphore 30 | // unchanged. 31 | TryAcquire(int64) bool 32 | // Release releases the semaphore with a weight of n. 33 | Release(int64) 34 | } 35 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/jsonnumber.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | import "encoding/json" 21 | 22 | func generateJSONPropertyJSONNumber(info *fieldInfo, parent *property, child *property) error { 23 | child.Type.add(TypeNameNumber) 24 | parent.Properties[jsonSchemaName(info.field)] = child 25 | return setPropertyRulesInteger(info, child) 26 | } 27 | 28 | func setPropertyRulesNumber(info *fieldInfo, p *property) error { 29 | for tagName, tagValue := range info.tags { 30 | switch tagName { 31 | case tagMax: 32 | p.Max = json.Number(tagValue) 33 | delete(info.tags, tagName) 34 | case tagMin: 35 | p.Min = json.Number(tagValue) 36 | delete(info.tags, tagName) 37 | } 38 | } 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /model/modeljson/internal/event.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Event struct { 21 | Outcome string `json:"outcome,omitempty"` 22 | Action string `json:"action,omitempty"` 23 | Dataset string `json:"dataset,omitempty"` 24 | Kind string `json:"kind,omitempty"` 25 | Category string `json:"category,omitempty"` 26 | Module string `json:"module,omitempty"` 27 | Received Time `json:"received,omitempty"` 28 | Type string `json:"type,omitempty"` 29 | SuccessCount SummaryMetric `json:"success_count,omitempty"` 30 | Duration uint64 `json:"duration,omitempty"` 31 | Severity uint64 `json:"severity,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/integer.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | import ( 21 | "encoding/json" 22 | ) 23 | 24 | func generateJSONPropertyInteger(info *fieldInfo, parent *property, child *property) error { 25 | child.Type.add(TypeNameInteger) 26 | parent.Properties[jsonSchemaName(info.field)] = child 27 | return setPropertyRulesInteger(info, child) 28 | } 29 | 30 | func setPropertyRulesInteger(info *fieldInfo, p *property) error { 31 | for tagName, tagValue := range info.tags { 32 | switch tagName { 33 | case tagMax: 34 | p.Max = json.Number(tagValue) 35 | delete(info.tags, tagName) 36 | case tagMin: 37 | p.Min = json.Number(tagValue) 38 | delete(info.tags, tagName) 39 | } 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/transaction_jaeger_type_request.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "event": { 10 | "outcome": "failure" 11 | }, 12 | "host": { 13 | "hostname": "host-abc" 14 | }, 15 | "http": { 16 | "response": { 17 | "status_code": 500 18 | } 19 | }, 20 | "labels": { 21 | "http_protocol": "HTTP" 22 | }, 23 | "parent": { 24 | "id": "0000000061626364" 25 | }, 26 | "service": { 27 | "language": { 28 | "name": "unknown" 29 | }, 30 | "name": "unknown" 31 | }, 32 | "timestamp": { 33 | "us": 1576500418000768 34 | }, 35 | "transaction": { 36 | "representative_count": 1, 37 | "result": "HTTP 5xx", 38 | "sampled": true, 39 | "type": "request" 40 | }, 41 | "url": { 42 | "domain": "foo.bar.com", 43 | "full": "http://foo.bar.com?a=12", 44 | "original": "http://foo.bar.com?a=12", 45 | "query": "a=12", 46 | "scheme": "http" 47 | } 48 | } 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /model/modeljson/system.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func SystemModelJSON(s *modelpb.System, out *modeljson.System) { 26 | *out = modeljson.System{} 27 | if s.Process != nil { 28 | out.Process = modeljson.SystemProcess{ 29 | State: s.Process.State, 30 | Cmdline: s.Process.Cmdline, 31 | } 32 | if s.Process.Cpu != nil { 33 | out.Process.CPU = modeljson.SystemProcessCPU{ 34 | StartTime: s.Process.Cpu.StartTime, 35 | } 36 | } 37 | } 38 | if s.Filesystem != nil { 39 | out.Filesystem = modeljson.SystemFilesystem{ 40 | MountPoint: s.Filesystem.MountPoint, 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /model/modeljson/host.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func HostModelJSON(h *modelpb.Host, out *modeljson.Host) { 26 | *out = modeljson.Host{ 27 | Hostname: h.Hostname, 28 | Name: h.Name, 29 | ID: h.Id, 30 | Architecture: h.Architecture, 31 | Type: h.Type, 32 | } 33 | 34 | if n := len(h.Ip); n != 0 { 35 | ips := make([]string, 0, n) 36 | for _, ip := range h.Ip { 37 | ips = append(ips, modelpb.IP2String(ip)) 38 | } 39 | out.IP = ips 40 | } 41 | 42 | if h.Os != nil { 43 | var os modeljson.OS 44 | OSModelJSON(h.Os, &os) 45 | out.OS = &os 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /input/elasticapm/internal/decoder/decoder_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package decoder_test 19 | 20 | import ( 21 | "encoding/json" 22 | "strings" 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | 27 | "github.com/elastic/apm-data/input/elasticapm/internal/decoder" 28 | ) 29 | 30 | func TestDecodeJSONData(t *testing.T) { 31 | d := decoder.NewJSONDecoder(strings.NewReader( 32 | `{"id":"85925e55b43f4342","system": {"hostname":"prod1.example.com"},"number":123}`, 33 | )) 34 | var decoded map[string]interface{} 35 | err := d.Decode(&decoded) 36 | assert.Nil(t, err) 37 | assert.Equal(t, map[string]interface{}{ 38 | "id": "85925e55b43f4342", 39 | "system": map[string]interface{}{"hostname": "prod1.example.com"}, 40 | "number": json.Number("123"), 41 | }, decoded) 42 | } 43 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/nullable.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | import ( 21 | "fmt" 22 | ) 23 | 24 | var ( 25 | typPath = "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder/nullable" 26 | 27 | nullableTypeBool = fmt.Sprintf("%s.Bool", typPath) 28 | nullableTypeFloat64 = fmt.Sprintf("%s.Float64", typPath) 29 | nullableTypeHTTPHeader = fmt.Sprintf("%s.HTTPHeader", typPath) 30 | nullableTypeInt = fmt.Sprintf("%s.Int", typPath) 31 | nullableTypeInt64 = fmt.Sprintf("%s.Int64", typPath) 32 | nullableTypeInterface = fmt.Sprintf("%s.Interface", typPath) 33 | nullableTypeString = fmt.Sprintf("%s.String", typPath) 34 | nullableTypeTimeMicrosUnix = fmt.Sprintf("%s.TimeMicrosUnix", typPath) 35 | ) 36 | -------------------------------------------------------------------------------- /model/modeljson/internal/network.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Network struct { 21 | Connection NetworkConnection `json:"connection,omitempty"` 22 | Carrier NetworkCarrier `json:"carrier,omitempty"` 23 | } 24 | 25 | type NetworkConnection struct { 26 | Type string `json:"type,omitempty"` 27 | Subtype string `json:"subtype,omitempty"` 28 | } 29 | 30 | func (c *NetworkConnection) isZero() bool { 31 | return c.Type == "" && c.Subtype == "" 32 | } 33 | 34 | type NetworkCarrier struct { 35 | Name string `json:"name,omitempty"` 36 | MCC string `json:"mcc,omitempty"` 37 | MNC string `json:"mnc,omitempty"` 38 | ICC string `json:"icc,omitempty"` 39 | } 40 | 41 | func (c *NetworkCarrier) isZero() bool { 42 | return c.Name == "" && c.MCC == "" && c.MNC == "" && c.ICC == "" 43 | } 44 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/span_jaeger_messaging.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "destination": { 10 | "address": "mq", 11 | "port": 1234 12 | }, 13 | "event": { 14 | "duration": 79000000000, 15 | "outcome": "success" 16 | }, 17 | "host": { 18 | "hostname": "host-abc" 19 | }, 20 | "parent": { 21 | "id": "0000000058585858" 22 | }, 23 | "service": { 24 | "language": { 25 | "name": "unknown" 26 | }, 27 | "name": "unknown", 28 | "target": { 29 | "name": "queue-abc", 30 | "type": "messaging" 31 | } 32 | }, 33 | "span": { 34 | "id": "0000000041414646", 35 | "message": { 36 | "queue": { 37 | "name": "queue-abc" 38 | } 39 | }, 40 | "name": "Message receive", 41 | "representative_count": 1, 42 | "type": "messaging" 43 | }, 44 | "timestamp": { 45 | "us": 1576500418000768 46 | }, 47 | "trace": { 48 | "id": "00000000000000000000000046467830" 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /model/modeljson/event.pb.json.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | modeljson "github.com/elastic/apm-data/model/modeljson/internal" 22 | "github.com/elastic/apm-data/model/modelpb" 23 | ) 24 | 25 | func EventModelJSON(e *modelpb.Event, out *modeljson.Event) { 26 | *out = modeljson.Event{ 27 | Outcome: e.Outcome, 28 | Action: e.Action, 29 | Dataset: e.Dataset, 30 | Kind: e.Kind, 31 | Category: e.Category, 32 | Module: e.Module, 33 | Type: e.Type, 34 | Duration: e.Duration, 35 | Severity: e.Severity, 36 | } 37 | if e.SuccessCount != nil { 38 | out.SuccessCount = modeljson.SummaryMetric{ 39 | Count: e.SuccessCount.Count, 40 | Sum: e.SuccessCount.Sum, 41 | } 42 | } 43 | if e.Received != 0 { 44 | out.Received = modeljson.Time(modelpb.ToTime(e.Received)) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /model/modeljson/internal/process.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type Process struct { 21 | Title string `json:"title,omitempty"` 22 | CommandLine string `json:"command_line,omitempty"` 23 | Executable string `json:"executable,omitempty"` 24 | Args []string `json:"args,omitempty"` 25 | Thread ProcessThread `json:"thread,omitempty"` 26 | Parent ProcessParent `json:"parent,omitempty"` 27 | Pid int `json:"pid,omitempty"` 28 | } 29 | 30 | type ProcessParent struct { 31 | Pid uint32 `json:"pid,omitempty"` 32 | } 33 | 34 | func (p ProcessParent) isZero() bool { 35 | return p == ProcessParent{} 36 | } 37 | 38 | type ProcessThread struct { 39 | Name string `json:"name,omitempty"` 40 | ID int `json:"id,omitempty"` 41 | } 42 | 43 | func (t ProcessThread) isZero() bool { 44 | return t == ProcessThread{} 45 | } 46 | -------------------------------------------------------------------------------- /input/elasticapm/internal/decoder/decoder.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package decoder 19 | 20 | import ( 21 | "io" 22 | 23 | jsoniter "github.com/json-iterator/go" 24 | ) 25 | 26 | // TODO(simitt): look into config options for performance tuning 27 | // ConfigCompatibleWithStandardLibrary + UseNumber 28 | var json = jsoniter.Config{ 29 | EscapeHTML: true, 30 | SortMapKeys: true, 31 | ValidateJsonRawMessage: true, 32 | UseNumber: true, 33 | }.Froze() 34 | 35 | type Decoder interface { 36 | Decode(v interface{}) error 37 | } 38 | 39 | type JSONDecoder struct { 40 | *jsoniter.Decoder 41 | reader io.Reader 42 | } 43 | 44 | // NewJSONDecoder returns a *json.Decoder where numbers are unmarshaled 45 | // as a Number instead of a float64 into an interface{} 46 | func NewJSONDecoder(r io.Reader) JSONDecoder { 47 | d := json.NewDecoder(r) 48 | return JSONDecoder{Decoder: d, reader: r} 49 | } 50 | -------------------------------------------------------------------------------- /model/modeljson/internal/labels.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | import ( 21 | "go.elastic.co/fastjson" 22 | ) 23 | 24 | type Label struct { 25 | Value string 26 | Values []string 27 | } 28 | 29 | func (v *Label) MarshalFastJSON(w *fastjson.Writer) error { 30 | if v.Values != nil { 31 | w.RawByte('[') 32 | for i, value := range v.Values { 33 | if i > 0 { 34 | w.RawByte(',') 35 | } 36 | w.String(value) 37 | } 38 | w.RawByte(']') 39 | } else { 40 | w.String(v.Value) 41 | } 42 | return nil 43 | } 44 | 45 | type NumericLabel struct { 46 | Values []float64 47 | Value float64 48 | } 49 | 50 | func (v *NumericLabel) MarshalFastJSON(w *fastjson.Writer) error { 51 | if v.Values != nil { 52 | w.RawByte('[') 53 | for i, value := range v.Values { 54 | if i > 0 { 55 | w.RawByte(',') 56 | } 57 | w.Float64(value) 58 | } 59 | w.RawByte(']') 60 | } else { 61 | w.Float64(v.Value) 62 | } 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /model/modeljson/internal/system.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modeljson 19 | 20 | type System struct { 21 | Process SystemProcess `json:"process,omitempty"` 22 | Filesystem SystemFilesystem `json:"filesystem,omitempty"` 23 | } 24 | 25 | type SystemProcess struct { 26 | CPU SystemProcessCPU `json:"cpu,omitempty"` 27 | State string `json:"state,omitempty"` 28 | Cmdline string `json:"cmdline,omitempty"` 29 | } 30 | 31 | func (p *SystemProcess) isZero() bool { 32 | return p.CPU.isZero() && p.State == "" && p.Cmdline == "" 33 | } 34 | 35 | type SystemProcessCPU struct { 36 | StartTime string `json:"start_time,omitempty"` 37 | } 38 | 39 | func (p *SystemProcessCPU) isZero() bool { 40 | return p == nil || p.StartTime == "" 41 | } 42 | 43 | type SystemFilesystem struct { 44 | MountPoint string `json:"mount_point,omitempty"` 45 | } 46 | 47 | func (f *SystemFilesystem) isZero() bool { 48 | return f == nil || f.MountPoint == "" 49 | } 50 | -------------------------------------------------------------------------------- /model/modelprocessor/config_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | "go.opentelemetry.io/otel" 25 | "go.opentelemetry.io/otel/sdk/trace" 26 | ) 27 | 28 | func TestConfigOptions(t *testing.T) { 29 | tp := trace.NewTracerProvider() 30 | 31 | for _, tt := range []struct { 32 | name string 33 | opts []ConfigOption 34 | expectedConfig config 35 | }{ 36 | { 37 | name: "with no option", 38 | expectedConfig: config{ 39 | tracerProvider: otel.GetTracerProvider(), 40 | }, 41 | }, 42 | { 43 | name: "a custom tracer provider", 44 | opts: []ConfigOption{ 45 | WithTracerProvider(tp), 46 | }, 47 | expectedConfig: config{ 48 | tracerProvider: tp, 49 | }, 50 | }, 51 | } { 52 | t.Run(tt.name, func(t *testing.T) { 53 | cfg := newConfig(tt.opts...) 54 | assert.Equal(t, tt.expectedConfig, cfg) 55 | }) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /model/proto/http.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "google/protobuf/struct.proto"; 23 | import "headers.proto"; 24 | import "keyvalue.proto"; 25 | 26 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 27 | 28 | message HTTP { 29 | HTTPRequest request = 1; 30 | HTTPResponse response = 2; 31 | string version = 3; 32 | } 33 | 34 | message HTTPRequest { 35 | google.protobuf.Value body = 1; 36 | repeated HTTPHeader headers = 2; 37 | repeated KeyValue env = 3; 38 | repeated KeyValue cookies = 4; 39 | string id = 5; 40 | string method = 6; 41 | string referrer = 7; 42 | } 43 | 44 | message HTTPResponse { 45 | repeated HTTPHeader headers = 1; 46 | optional bool finished = 2; 47 | optional bool headers_sent = 3; 48 | optional uint64 transfer_size = 4; 49 | optional uint64 encoded_body_size = 5; 50 | optional uint64 decoded_body_size = 6; 51 | uint32 status_code = 7; 52 | } 53 | -------------------------------------------------------------------------------- /model/modelprocessor/errormessage.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/elastic/apm-data/model/modelpb" 24 | ) 25 | 26 | // SetErrorMessage is a modelpb.BatchProcessor that sets the APMEvent.Message 27 | // field for error events. 28 | type SetErrorMessage struct{} 29 | 30 | // ProcessBatch sets the message for errors. 31 | func (s SetErrorMessage) ProcessBatch(ctx context.Context, b *modelpb.Batch) error { 32 | for i := range *b { 33 | event := (*b)[i] 34 | if event.Error != nil { 35 | if event.GetMessage() == "" { 36 | event.Message = s.setErrorMessage(event) 37 | } 38 | } 39 | } 40 | return nil 41 | } 42 | 43 | func (s SetErrorMessage) setErrorMessage(event *modelpb.APMEvent) string { 44 | if msg := event.GetError().GetLog().GetMessage(); msg != "" { 45 | return msg 46 | } 47 | if msg := event.GetError().GetException().GetMessage(); msg != "" { 48 | return msg 49 | } 50 | return "" 51 | } 52 | -------------------------------------------------------------------------------- /model/proto/service.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Service { 25 | ServiceOrigin origin = 1; 26 | ServiceTarget target = 2; 27 | Language language = 3; 28 | Runtime runtime = 4; 29 | Framework framework = 5; 30 | string name = 6; 31 | string version = 7; 32 | string environment = 8; 33 | ServiceNode node = 9; 34 | } 35 | 36 | message ServiceOrigin { 37 | string id = 1; 38 | string name = 2; 39 | string version = 3; 40 | } 41 | 42 | message ServiceTarget { 43 | string name = 1; 44 | string type = 2; 45 | } 46 | 47 | message Language { 48 | string name = 1; 49 | string version = 2; 50 | } 51 | 52 | message Runtime { 53 | string name = 1; 54 | string version = 2; 55 | } 56 | 57 | message Framework { 58 | string name = 1; 59 | string version = 2; 60 | } 61 | 62 | message ServiceNode { 63 | string name = 1; 64 | } 65 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/nint.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package generator 19 | 20 | import ( 21 | "fmt" 22 | "io" 23 | ) 24 | 25 | func generateNullableIntValidation(w io.Writer, fields []structField, f structField, _ bool) error { 26 | rules, err := validationRules(f.tag) 27 | if err != nil { 28 | return fmt.Errorf("nullableInt: %w", err) 29 | } 30 | for _, rule := range rules { 31 | switch rule.name { 32 | case tagMin, tagMax: 33 | nintRuleMinMax(w, f, rule) 34 | case tagRequired: 35 | ruleNullableRequired(w, f) 36 | default: 37 | return fmt.Errorf("nullableInt: %w", errUnhandledTagRule(rule)) 38 | } 39 | } 40 | return nil 41 | } 42 | 43 | func nintRuleMinMax(w io.Writer, f structField, rule validationRule) { 44 | fmt.Fprintf(w, ` 45 | if val.%s.IsSet() && val.%s.Val %s %s { 46 | return fmt.Errorf("'%s': validation rule '%s(%s)' violated") 47 | } 48 | `[1:], f.Name(), f.Name(), ruleMinMaxOperator(rule.name), rule.value, jsonName(f), rule.name, rule.value) 49 | } 50 | -------------------------------------------------------------------------------- /model/proto/error.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "stacktrace.proto"; 23 | import "keyvalue.proto"; 24 | 25 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 26 | 27 | message Error { 28 | repeated KeyValue custom = 1; 29 | Exception exception = 2; 30 | ErrorLog log = 3; 31 | string id = 4; 32 | string grouping_key = 5; 33 | string culprit = 6; 34 | string stack_trace = 7; 35 | string message = 8; 36 | string type = 9; 37 | } 38 | 39 | message Exception { 40 | string message = 1; 41 | string module = 2; 42 | string code = 3; 43 | repeated KeyValue attributes = 4; 44 | repeated StacktraceFrame stacktrace = 5; 45 | string type = 6; 46 | optional bool handled = 7; 47 | repeated Exception cause = 8; 48 | } 49 | 50 | message ErrorLog { 51 | string message = 1; 52 | string level = 2; 53 | string param_message = 3; 54 | string logger_name = 4; 55 | repeated StacktraceFrame stacktrace = 5; 56 | } 57 | -------------------------------------------------------------------------------- /model/modelprocessor/environment.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/elastic/apm-data/model/modelpb" 24 | ) 25 | 26 | // SetDefaultServiceEnvironment is a transform.Processor that sets a default 27 | // service.environment value for events without one already set. 28 | type SetDefaultServiceEnvironment struct { 29 | // DefaultServiceEnvironment is the default service.environment value 30 | // to set for events without one already set. 31 | DefaultServiceEnvironment string 32 | } 33 | 34 | // ProcessBatch sets a default service.value for events without one already set. 35 | func (s *SetDefaultServiceEnvironment) ProcessBatch(ctx context.Context, b *modelpb.Batch) error { 36 | for i := range *b { 37 | event := (*b)[i] 38 | if event.Service == nil { 39 | event.Service = &modelpb.Service{} 40 | } 41 | if event.Service.Environment == "" { 42 | event.Service.Environment = s.DefaultServiceEnvironment 43 | } 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /model/proto/stacktrace.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | import "keyvalue.proto"; 23 | 24 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 25 | 26 | message StacktraceFrame { 27 | repeated KeyValue vars = 1; 28 | optional uint32 lineno = 2; 29 | optional uint32 colno = 3; 30 | string filename = 4; 31 | string classname = 5; 32 | string context_line = 6; 33 | string module = 7; 34 | string function = 8; 35 | string abs_path = 9; 36 | string sourcemap_error = 10; 37 | Original original = 11; 38 | repeated string pre_context = 12; 39 | repeated string post_context = 13; 40 | bool library_frame = 14; 41 | bool sourcemap_updated = 15; 42 | bool exclude_from_grouping = 16; 43 | } 44 | 45 | message Original { 46 | string abs_path = 1; 47 | string filename = 2; 48 | string classname = 3; 49 | optional uint32 lineno = 4; 50 | optional uint32 colno = 5; 51 | string function = 6; 52 | bool library_frame = 7; 53 | } 54 | -------------------------------------------------------------------------------- /model/modelprocessor/eventreceived_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package modelprocessor_test 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/elastic/apm-data/model/modelpb" 24 | "github.com/elastic/apm-data/model/modelprocessor" 25 | ) 26 | 27 | func TestRemoveEventReceived(t *testing.T) { 28 | processor := modelprocessor.RemoveEventReceived{} 29 | 30 | for _, tc := range []struct { 31 | name string 32 | input *modelpb.APMEvent 33 | expected *modelpb.APMEvent 34 | }{ 35 | { 36 | name: "with event", 37 | input: &modelpb.APMEvent{ 38 | Event: &modelpb.Event{ 39 | Received: 1000, 40 | }, 41 | }, 42 | expected: &modelpb.APMEvent{ 43 | Event: &modelpb.Event{ 44 | Received: 0, 45 | }, 46 | }, 47 | }, 48 | { 49 | name: "without event", 50 | input: &modelpb.APMEvent{}, 51 | expected: &modelpb.APMEvent{}, 52 | }, 53 | } { 54 | t.Run(tc.name, func(t *testing.T) { 55 | testProcessBatch(t, processor, tc.input, tc.expected) 56 | }) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /codec/vtproto.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package codec 19 | 20 | import "fmt" 21 | 22 | // vtprotoMessage expects a struct to have MarshalVT() and UnmarshalVT() methods 23 | // that coverts data between byte slices and the desired format 24 | type vtprotoMessage interface { 25 | MarshalVT() ([]byte, error) 26 | UnmarshalVT([]byte) error 27 | } 28 | 29 | // VTProto is a composite of Encoder and Decoder 30 | type VTProto struct{} 31 | 32 | // Encode encodes vtprotoMessage type into byte slice 33 | func (v VTProto) Encode(in any) ([]byte, error) { 34 | vt, ok := in.(vtprotoMessage) 35 | if !ok { 36 | return nil, fmt.Errorf("failed to encode, message is %T (missing vtprotobuf helpers)", in) 37 | } 38 | return vt.MarshalVT() 39 | } 40 | 41 | // Decode decodes a byte slice into vtprotoMessage type. 42 | func (v VTProto) Decode(in []byte, out any) error { 43 | vt, ok := out.(vtprotoMessage) 44 | if !ok { 45 | return fmt.Errorf("failed to decode, message is %T (missing vtprotobuf helpers)", out) 46 | } 47 | return vt.UnmarshalVT(in) 48 | } 49 | -------------------------------------------------------------------------------- /model/proto/metricset.proto: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | syntax = "proto3"; 19 | 20 | package elastic.apm.v1; 21 | 22 | option go_package = "github.com/elastic/apm-data/model/modelpb"; 23 | 24 | message Metricset { 25 | string name = 1; 26 | string interval = 2; 27 | repeated MetricsetSample samples = 3; 28 | uint64 doc_count = 4; 29 | } 30 | 31 | enum MetricType { 32 | METRIC_TYPE_UNSPECIFIED = 0; 33 | METRIC_TYPE_GAUGE = 1; 34 | METRIC_TYPE_COUNTER = 2; 35 | METRIC_TYPE_HISTOGRAM = 3; 36 | METRIC_TYPE_SUMMARY = 4; 37 | } 38 | 39 | message MetricsetSample { 40 | MetricType type = 1; 41 | string name = 2; 42 | string unit = 3; 43 | Histogram histogram = 4; 44 | SummaryMetric summary = 5; 45 | double value = 6; 46 | } 47 | 48 | message Histogram { 49 | repeated double values = 1; 50 | repeated uint64 counts = 2; 51 | } 52 | 53 | message SummaryMetric { 54 | uint64 count = 1; 55 | double sum = 2; 56 | } 57 | 58 | message AggregatedDuration { 59 | uint64 count = 1; 60 | 61 | // nanoseconds 62 | uint64 sum = 2; 63 | } 64 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/generator/propertytypename_string.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | // Code generated by "stringer -linecomment -type propertyTypeName"; DO NOT EDIT. 19 | 20 | package generator 21 | 22 | import "strconv" 23 | 24 | func _() { 25 | // An "invalid array index" compiler error signifies that the constant values have changed. 26 | // Re-run the stringer command to generate them again. 27 | var x [1]struct{} 28 | _ = x[TypeNameObject-0] 29 | _ = x[TypeNameString-1] 30 | _ = x[TypeNameBool-2] 31 | _ = x[TypeNameInteger-3] 32 | _ = x[TypeNameNumber-4] 33 | _ = x[TypeNameArray-5] 34 | } 35 | 36 | const _propertyTypeName_name = "objectstringbooleanintegernumberarray" 37 | 38 | var _propertyTypeName_index = [...]uint8{0, 6, 12, 19, 26, 32, 37} 39 | 40 | func (i propertyTypeName) String() string { 41 | if i >= propertyTypeName(len(_propertyTypeName_index)-1) { 42 | return "propertyTypeName(" + strconv.FormatInt(int64(i), 10) + ")" 43 | } 44 | return _propertyTypeName_name[_propertyTypeName_index[i]:_propertyTypeName_index[i+1]] 45 | } 46 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/otel-bridge.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata": {"service": {"name": "chatty-service","node": {"configured_name": "chatty-node"},"version": "5.1.3","environment": "staging","language": {"name": "ecmascript","version": "8"},"runtime": {"name": "node","version": "8.0.0"},"framework": {"name": "Express","version": "1.2.3"},"agent": {"name": "elastic-node","version": "3.14.0"}},"user": {"id": "123user", "username": "bar", "email": "bar@user.com"}, "labels": {"tag0": null, "tag1": "one", "tag2": 2}, "process": {"pid": 1234,"ppid": 6789,"title": "node","argv": ["node","server.js"]},"system": {"hostname": "prod1.example.com","architecture": "x64","platform": "darwin", "container": {"id": "container-id"}, "kubernetes": {"namespace": "namespace1", "pod": {"uid": "pod-uid", "name": "pod-name"}, "node": {"name": "node-name"}}},"cloud":{"account":{"id":"account_id","name":"account_name"},"availability_zone":"cloud_availability_zone","instance":{"id":"instance_id","name":"instance_name"},"machine":{"type":"machine_type"},"project":{"id":"project_id","name":"project_name"},"provider":"cloud_provider","region":"cloud_region","service":{"name":"lambda"}}}} 2 | {"transaction":{"id":"ddf109a4c4aa5f2b6e984548ca57774c","trace_id":"646df3b8b5279e982cc12a2f1ac004f3","name":"tx_name","type":"tx_type","duration":32.592981,"outcome":"success","result":"success","timestamp":1496170407154000,"span_count":{"started":20,"dropped":3},"otel":{"span_kind":"CONSUMER","attributes":{"messaging.destination":"queue_name","int_array":[1,2],"string_array":["a","b"]}}}} 3 | {"span":{"id":"ddf109a4c4aa5f2b6e984548ca57774d","parent_id":"ddf109a4c4aa5f2b6e984548ca57774c","trace_id":"646df3b8b5279e982cc12a2f1ac004f3","name":"span_name","type":"span_type","duration":32.592981,"outcome":"success","timestamp":1496170407154000,"otel":{"span_kind":"CLIENT","attributes":{"http.status_code":200,"http.method":"GET","double_value":123.456}}}} 4 | -------------------------------------------------------------------------------- /input/elasticapm/internal/modeldecoder/v2/testdata/errors_rum.ndjson: -------------------------------------------------------------------------------- 1 | {"metadata":{"service":{"name":"apm-agent-js","version":"1.0.1","agent":{"name":"rum-js","version":"0.0.0"}}}} 2 | {"error":{"id":"aba2688e033848ce9c4e4005f1caa534","timestamp":1512735530291000,"culprit":"test/e2e/general-usecase/bundle.js.map","log":{"message":"Uncaught Error: log timeout test error","stacktrace":[{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"","lineno":1,"colno":18}]},"exception":{"message":"Uncaught Error: timeout test error","stacktrace":[{"abs_path":"http://localhost:8000/test/../test/e2e/general-usecase/bundle.js.map","filename":"test/e2e/general-usecase/bundle.js.map","function":"","library_frame":true,"lineno":1,"colno":18},{"abs_path":"http://localhost:8000/test/./e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"invokeTask","library_frame":false,"lineno":1,"colno":181},{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"runTask","lineno":1,"colno":15},{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"invoke","lineno":1,"colno":199},{"abs_path":"http://localhost:8000/test/e2e/general-usecase/bundle.js.map","filename":"~/test/e2e/general-usecase/bundle.js.map","function":"timer","lineno":1,"colno":33}],"type":"Error"},"context":{"environment":{"browserWidth":150,"browserHeight":726,"screenWidth":1280,"screenHeight":800,"language":"en-US","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36","platform":"MacIntel"},"page":{"referer":"http://localhost:8000/test/e2e/","url":"http://localhost:8000/test/e2e/general-usecase/"}}}} 3 | -------------------------------------------------------------------------------- /input/elasticapm/internal/decoder/limited_reader_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package decoder 19 | 20 | import ( 21 | "strings" 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | "github.com/stretchr/testify/require" 26 | ) 27 | 28 | func TestLimitedReaderRead(t *testing.T) { 29 | test := func(t *testing.T, buflen, expectedLen int) { 30 | r := &LimitedReader{R: strings.NewReader("abc"), N: 3} 31 | out := make([]byte, buflen) 32 | n, err := r.Read(out) 33 | require.NoError(t, err) 34 | assert.Equal(t, expectedLen, n) 35 | assert.Equal(t, "abc"[:n], string(out[:n])) 36 | assert.Equal(t, int64(3-n), r.N) 37 | } 38 | test(t, 1, 1) 39 | test(t, 2, 2) 40 | test(t, 3, 3) 41 | test(t, 4, 3) 42 | } 43 | 44 | func TestLimitedReaderLimited(t *testing.T) { 45 | r := &LimitedReader{R: strings.NewReader("abcd"), N: 3} 46 | out := make([]byte, 4) 47 | n, err := r.Read(out) 48 | require.Error(t, err) 49 | require.EqualError(t, err, "too large") 50 | assert.Equal(t, 3, n) 51 | assert.Equal(t, "abc", string(out[:n])) 52 | assert.Equal(t, int64(-1), r.N) 53 | } 54 | -------------------------------------------------------------------------------- /input/jaeger/test_approved/span_jaeger_https_default_port.approved.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "@timestamp": "2019-12-16T12:46:58.000Z", 5 | "agent": { 6 | "name": "Jaeger", 7 | "version": "unknown" 8 | }, 9 | "destination": { 10 | "address": "foo.bar.com", 11 | "port": 443 12 | }, 13 | "event": { 14 | "duration": 79000000000, 15 | "outcome": "success" 16 | }, 17 | "host": { 18 | "hostname": "host-abc" 19 | }, 20 | "parent": { 21 | "id": "0000000058585858" 22 | }, 23 | "service": { 24 | "language": { 25 | "name": "unknown" 26 | }, 27 | "name": "unknown", 28 | "target": { 29 | "name": "foo.bar.com:443", 30 | "type": "http" 31 | } 32 | }, 33 | "span": { 34 | "destination": { 35 | "service": { 36 | "name": "https://foo.bar.com", 37 | "resource": "foo.bar.com:443", 38 | "type": "external" 39 | } 40 | }, 41 | "id": "0000000041414646", 42 | "name": "HTTPS GET", 43 | "representative_count": 1, 44 | "subtype": "http", 45 | "type": "external" 46 | }, 47 | "timestamp": { 48 | "us": 1576500418000768 49 | }, 50 | "trace": { 51 | "id": "00000000000000000000000046467830" 52 | }, 53 | "url": { 54 | "original": "https://foo.bar.com:443?a=12" 55 | } 56 | } 57 | ] 58 | } 59 | --------------------------------------------------------------------------------