├── .ci └── updatecli │ └── values.d │ ├── apm-data-spec.yml │ ├── apm-gherkin.yml │ ├── apm-json-specs.yml │ ├── scm.yml │ └── update-compose.yml ├── .dockerignore ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ ├── Feature_request.md │ └── Question.md ├── dependabot.yml ├── labeler-config.yml └── workflows │ ├── README.md │ ├── addToAPMProject.yml │ ├── ci-docs.yml │ ├── ci.yml │ ├── docs-build.yml │ ├── docs-cleanup.yml │ ├── github-commands-comment.yml │ ├── labeler.yml │ ├── microbenchmark.yml │ └── updatecli.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── apmconfig ├── doc.go └── watcher.go ├── apmtest ├── configwatcher.go ├── debug.go ├── discard.go ├── env.go ├── httpsuite.go ├── recorder.go ├── recorder_test.go ├── recordlogger.go ├── testlogger.go └── withtransaction.go ├── breakdown.go ├── breakdown_internal_test.go ├── breakdown_test.go ├── builtin_metrics.go ├── capturebody.go ├── capturebody_test.go ├── config.go ├── config_test.go ├── context.go ├── context_test.go ├── doc.go ├── docs ├── docset.yml ├── reference │ ├── api-documentation.md │ ├── builtin-modules.md │ ├── configuration.md │ ├── contributing.md │ ├── custom-instrumentation-propagation.md │ ├── custom-instrumentation.md │ ├── images │ │ └── dynamic-config.svg │ ├── index.md │ ├── log-correlation.md │ ├── logs.md │ ├── metrics.md │ ├── opentelemetry-api.md │ ├── opentracing-api.md │ ├── set-up-apm-go-agent.md │ ├── supported-technologies.md │ ├── toc.yml │ └── upgrading.md └── release-notes │ ├── deprecations.md │ ├── index.md │ ├── known-issues.md │ └── toc.yml ├── env_test.go ├── error.go ├── error_syscall.go ├── error_test.go ├── error_unix.go ├── error_windows.go ├── example_context_test.go ├── example_test.go ├── example_tracecontext_test.go ├── features ├── api_key.feature ├── azure_app_service_metadata.feature ├── outcome.feature └── user_agent.feature ├── fmt.go ├── fmt_test.go ├── fnv.go ├── fnv_test.go ├── go.mod ├── go.sum ├── gocontext.go ├── gocontext_test.go ├── internal ├── apmcloudutil │ ├── aws.go │ ├── aws_test.go │ ├── azure.go │ ├── azure_test.go │ ├── gcp.go │ ├── gcp_test.go │ ├── provider.go │ └── provider_test.go ├── apmgodog │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── suitecontext_test.go │ └── testmain_test.go ├── apmhostutil │ ├── container.go │ ├── container_linux.go │ ├── container_linux_test.go │ ├── container_nonlinux.go │ └── container_test.go ├── apmhttputil │ ├── forwarded.go │ ├── forwarded_test.go │ ├── remoteaddr.go │ ├── remoteaddr_test.go │ ├── url.go │ └── url_test.go ├── apmlog │ ├── logger.go │ └── logger_test.go ├── apmschema │ ├── go.mod │ ├── go.sum │ ├── jsonschema │ │ ├── error.json │ │ ├── log.json │ │ ├── metadata.json │ │ ├── metricset.json │ │ ├── span.json │ │ └── transaction.json │ ├── schema.go │ ├── update.sh │ └── validation_test.go ├── apmstrings │ ├── truncate.go │ └── truncate_test.go ├── apmversion │ └── version.go ├── configutil │ ├── duration.go │ ├── env.go │ ├── env_test.go │ ├── list.go │ ├── size.go │ └── wildcards.go ├── iochan │ ├── doc.go │ ├── reader.go │ └── reader_test.go ├── ringbuffer │ ├── buffer.go │ ├── buffer_test.go │ └── doc.go ├── testdata │ └── json-specs │ │ ├── cgroup_parsing.json │ │ ├── service_resource_inference.json │ │ ├── span_types.json │ │ ├── sql_signature_examples.json │ │ ├── sql_token_examples.json │ │ ├── w3c_distributed_tracing.json │ │ └── wildcard_matcher_tests.json ├── tracecontexttest │ ├── Dockerfile │ ├── Dockerfile-harness │ ├── go.mod │ ├── go.sum │ └── main.go └── wildcard │ ├── doc.go │ ├── matcher.go │ ├── matcher_test.go │ └── matchers.go ├── logger.go ├── metrics.go ├── metrics_test.go ├── model ├── doc.go ├── generate.sh ├── maps.go ├── marshal.go ├── marshal_benchmark_test.go ├── marshal_fastjson.go ├── marshal_test.go └── model.go ├── modelwriter.go ├── module ├── apmawssdkgo │ ├── doc.go │ ├── dynamodb.go │ ├── go.mod │ ├── go.sum │ ├── s3.go │ ├── session.go │ ├── session_test.go │ ├── sns.go │ ├── sns_test.go │ ├── sqs.go │ └── sqs_test.go ├── apmazure │ ├── blob.go │ ├── blob_test.go │ ├── doc.go │ ├── file.go │ ├── file_test.go │ ├── go.mod │ ├── go.sum │ ├── queue.go │ ├── queue_test.go │ └── storage.go ├── apmbeego │ ├── doc.go │ ├── example_test.go │ ├── filter.go │ ├── filter_test.go │ ├── go.mod │ ├── go.sum │ └── orm_test.go ├── apmchi │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmchiv5 │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmecho │ ├── doc.go │ ├── example_test.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmechov4 │ ├── doc.go │ ├── example_test.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmelasticsearch │ ├── client.go │ ├── client_example_test.go │ ├── client_test.go │ ├── clustername.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── internal │ │ └── integration │ │ │ ├── doc.go │ │ │ ├── elastic_integration_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── olivere_integration_test.go │ └── requestname.go ├── apmfasthttp │ ├── closer.go │ ├── context.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── recovery.go │ ├── server.go │ ├── server_test.go │ ├── types.go │ └── utils.go ├── apmfiber │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmgin │ ├── bench_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmgocql │ ├── apmgocql_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── observer.go │ ├── signature.go │ └── signature_test.go ├── apmgokit │ ├── README.md │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── grpc_test.go │ └── http_test.go ├── apmgometrics │ ├── gatherer.go │ ├── gatherer_test.go │ ├── go.mod │ └── go.sum ├── apmgopg │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── hook.go │ └── hook_test.go ├── apmgopgv10 │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── hook.go │ └── hook_test.go ├── apmgoredis │ ├── client.go │ ├── client_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ └── integration_test.go ├── apmgoredisv8 │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── hook.go │ └── hook_test.go ├── apmgorilla │ ├── context.go │ ├── context_test.go │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmgorm │ ├── apmgorm_test.go │ ├── context.go │ ├── dialects │ │ ├── mysql │ │ │ └── init.go │ │ ├── postgres │ │ │ └── init.go │ │ └── sqlite │ │ │ └── init.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ └── open.go ├── apmgormv2 │ ├── README.md │ ├── apmgorm_test.go │ ├── doc.go │ ├── driver │ │ ├── mysql │ │ │ └── init.go │ │ ├── postgres │ │ │ └── init.go │ │ ├── sqlite │ │ │ └── init.go │ │ └── sqlserver │ │ │ └── init.go │ ├── go.mod │ └── go.sum ├── apmgrpc │ ├── client.go │ ├── client_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── ignorer.go │ ├── ignorer_test.go │ ├── internal │ │ └── testservice │ │ │ ├── testservice.pb.go │ │ │ ├── testservice.proto │ │ │ └── testservice_grpc.pb.go │ ├── packages.go │ ├── server.go │ └── server_test.go ├── apmhttp │ ├── client.go │ ├── client_bench_test.go │ ├── client_example_test.go │ ├── client_test.go │ ├── clienttrace.go │ ├── context.go │ ├── context_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── handler.go │ ├── handler_bench_test.go │ ├── handler_http2_test.go │ ├── handler_test.go │ ├── ignorer.go │ ├── ignorer_test.go │ ├── recovery.go │ ├── requestname.go │ ├── traceheaders.go │ └── traceheaders_test.go ├── apmhttprouter │ ├── go.mod │ ├── go.sum │ ├── handler.go │ ├── handler_test.go │ ├── router.go │ └── router_test.go ├── apmlambda │ ├── doc.go │ ├── example.go │ ├── go.mod │ ├── go.sum │ └── lambda.go ├── apmlogrus │ ├── example_test.go │ ├── fields.go │ ├── fields_test.go │ ├── go.mod │ ├── go.sum │ ├── hook.go │ └── hook_test.go ├── apmmongo │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── monitor.go │ ├── monitor_benchmark_test.go │ ├── monitor_integration_test.go │ └── monitor_test.go ├── apmnegroni │ ├── go.mod │ ├── go.sum │ ├── middleware.go │ └── middleware_test.go ├── apmot │ ├── context.go │ ├── doc.go │ ├── example_test.go │ ├── go.mod │ ├── go.sum │ ├── harness_test.go │ ├── log.go │ ├── span.go │ ├── tracer.go │ ├── tracer_test.go │ └── wrapper.go ├── apmotel │ ├── doc.go │ ├── example_test.go │ ├── gatherer.go │ ├── gatherer_config.go │ ├── gatherer_config_test.go │ ├── gatherer_test.go │ ├── go.mod │ ├── go.sum │ ├── span.go │ ├── span_test.go │ ├── tracer.go │ ├── tracer_provider.go │ ├── tracer_provider_config.go │ ├── tracer_provider_config_test.go │ ├── tracer_provider_test.go │ ├── tracer_test.go │ ├── wrapper.go │ └── wrapper_test.go ├── apmpgx │ ├── doc.go │ ├── e2e_test.go │ ├── go.mod │ ├── go.sum │ ├── tracer.go │ └── tracer_test.go ├── apmpgxv5 │ ├── batch_tracer.go │ ├── batch_tracer_test.go │ ├── connect_tracer.go │ ├── connect_tracer_test.go │ ├── copy_tracer.go │ ├── copy_tracer_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── query_tracer.go │ ├── query_tracer_test.go │ ├── span.go │ └── tracer.go ├── apmprometheus │ ├── gatherer.go │ ├── gatherer_test.go │ ├── go.mod │ └── go.sum ├── apmredigo │ ├── conn.go │ ├── conn_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ └── integration_test.go ├── apmrestful │ ├── doc.go │ ├── filter.go │ ├── filter_example_test.go │ ├── filter_test.go │ ├── go.mod │ ├── go.sum │ ├── route.go │ └── route_test.go ├── apmrestfulv3 │ ├── doc.go │ ├── filter.go │ ├── filter_example_test.go │ ├── filter_test.go │ ├── go.mod │ ├── go.sum │ ├── route.go │ └── route_test.go ├── apmslog │ ├── example_test.go │ ├── go.mod │ ├── go.sum │ ├── handler.go │ └── handler_test.go ├── apmsql │ ├── README.md │ ├── apmsql_bench_test.go │ ├── apmsql_test.go │ ├── conn.go │ ├── doc.go │ ├── driver.go │ ├── dsn.go │ ├── go.mod │ ├── go.sum │ ├── gofuzz_signature.go │ ├── internal │ │ └── pgutil │ │ │ ├── doc.go │ │ │ ├── parser.go │ │ │ └── parser_test.go │ ├── mysql │ │ ├── doc.go │ │ ├── init.go │ │ ├── mysql_test.go │ │ ├── parser.go │ │ └── parser_test.go │ ├── pgxv4 │ │ ├── doc.go │ │ ├── init.go │ │ └── pq_test.go │ ├── pq │ │ ├── doc.go │ │ ├── init.go │ │ ├── parser.go │ │ └── pq_test.go │ ├── signature.go │ ├── signature_test.go │ ├── sqlite3 │ │ ├── doc.go │ │ ├── init.go │ │ ├── parser.go │ │ └── parser_test.go │ ├── sqlserver │ │ ├── doc.go │ │ ├── init.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ └── sqlserver_test.go │ ├── stmt.go │ └── utils.go ├── apmzap │ ├── core.go │ ├── core_test.go │ ├── fields.go │ ├── fields_test.go │ ├── go.mod │ └── go.sum └── apmzerolog │ ├── context.go │ ├── context_test.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── stack.go │ ├── stack_test.go │ ├── writer.go │ └── writer_test.go ├── profiling.go ├── profiling_test.go ├── sampler.go ├── sampler_test.go ├── sanitizer.go ├── sanitizer_test.go ├── scripts ├── Dockerfile-sqlserver ├── Dockerfile-testing ├── check_goimports.sh ├── check_vanity.sh ├── ci │ ├── bench.sh │ ├── build.sh │ ├── ci.go.mod │ ├── ci.go.sum │ ├── docker-test.sh │ ├── package.sh │ ├── setenv.sh │ ├── test.sh │ └── windows │ │ └── build-test.bat ├── docker-compose-testing ├── docker-compose-testing.yml ├── docker_sqlserver_entrypoint.sh ├── gendockerfile.go ├── generate-testservice.sh ├── generate.go ├── genmod │ ├── go.mod │ ├── go.sum │ └── main.go ├── goimports.sh ├── install-protobuf.sh ├── moduledirs.sh ├── tagversion.sh └── test_coverage.sh ├── span.go ├── span_compressed.go ├── span_test.go ├── spancontext.go ├── spancontext_test.go ├── sqlutil ├── doc.go ├── drivername.go ├── scanner.go ├── scanner_test.go └── token.go ├── stacktrace.go ├── stacktrace ├── doc.go ├── errors.go ├── frame.go ├── generate_library.bash ├── library.go ├── library_test.go ├── stacktrace.go ├── stacktrace_test.go └── testdata │ └── foo.go ├── testmain_test.go ├── tools ├── go.mod ├── go.sum └── tools.go ├── tracecontext.go ├── tracecontext_test.go ├── tracer.go ├── tracer_stats.go ├── tracer_test.go ├── transaction.go ├── transaction_test.go ├── transport ├── api.go ├── crypto.go ├── crypto_test.go ├── discard.go ├── doc.go ├── http.go ├── http_test.go ├── testdata │ ├── cert.pem │ └── key.pem ├── transporttest │ ├── doc.go │ ├── err.go │ └── recorder.go └── util_test.go ├── updatecli-compose.yaml ├── utils.go ├── utils_linux.go ├── utils_linux_test.go ├── utils_other.go ├── utils_test.go ├── version.go └── version_test.go /.ci/updatecli/values.d/apm-data-spec.yml: -------------------------------------------------------------------------------- 1 | apm_schema_specs_path: internal/apmschema/jsonschema 2 | -------------------------------------------------------------------------------- /.ci/updatecli/values.d/apm-gherkin.yml: -------------------------------------------------------------------------------- 1 | apm_gherkin_specs_path: features -------------------------------------------------------------------------------- /.ci/updatecli/values.d/apm-json-specs.yml: -------------------------------------------------------------------------------- 1 | apm_json_specs_path: internal/testdata/json-specs 2 | -------------------------------------------------------------------------------- /.ci/updatecli/values.d/scm.yml: -------------------------------------------------------------------------------- 1 | scm: 2 | enabled: true 3 | owner: elastic 4 | repository: apm-agent-go 5 | branch: main 6 | commitusingapi: true 7 | # begin update-compose policy values 8 | user: obltmachine 9 | email: obltmachine@users.noreply.github.com 10 | # end update-compose policy values 11 | -------------------------------------------------------------------------------- /.ci/updatecli/values.d/update-compose.yml: -------------------------------------------------------------------------------- 1 | spec: 2 | files: 3 | - "updatecli-compose.yaml" 4 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | scripts/docker* 2 | scripts/Docker* 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @elastic/apm-agent-go 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Use this config '...' 13 | 2. Then call '....' 14 | 3. Then do '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Please use the discuss forum (https://discuss.elastic.co/c/apm) to ask questions 4 | 5 | --- 6 | 7 | Please use the [discuss forum](https://discuss.elastic.co/c/apm) to ask questions. 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | # GitHub actions 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | reviewers: 8 | - "elastic/observablt-ci" 9 | schedule: 10 | interval: "weekly" 11 | day: "sunday" 12 | time: "22:00" 13 | groups: 14 | github-actions: 15 | patterns: 16 | - "*" 17 | -------------------------------------------------------------------------------- /.github/labeler-config.yml: -------------------------------------------------------------------------------- 1 | # add 'agent-go' label to all new issues 2 | agent-go: 3 | - '.*' 4 | -------------------------------------------------------------------------------- /.github/workflows/ci-docs.yml: -------------------------------------------------------------------------------- 1 | # This workflow sets the test / all status check to success in case it's a docs only PR and test.yml is not triggered 2 | # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks 3 | name: ci # The name must be the same as in ci.yml 4 | 5 | on: 6 | pull_request: 7 | paths-ignore: # This expression needs to match the paths ignored on ci.yml. 8 | - '**' 9 | - '!**/*.md' 10 | - '!**/*.asciidoc' 11 | 12 | permissions: 13 | contents: read 14 | 15 | ## Concurrency only allowed in the main branch. 16 | ## So old builds running for old commits within the same Pull Request are cancelled 17 | concurrency: 18 | group: ${{ github.workflow }}-${{ github.ref }} 19 | cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} 20 | 21 | jobs: 22 | # dummy steps that allow to bypass those mandatory checks for tests 23 | ci: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - run: 'echo "Not required for docs"' 27 | -------------------------------------------------------------------------------- /.github/workflows/docs-build.yml: -------------------------------------------------------------------------------- 1 | name: docs-build 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request_target: ~ 8 | merge_group: ~ 9 | 10 | jobs: 11 | docs-preview: 12 | uses: elastic/docs-builder/.github/workflows/preview-build.yml@main 13 | with: 14 | path-pattern: docs/** 15 | permissions: 16 | deployments: write 17 | id-token: write 18 | contents: read 19 | pull-requests: read 20 | -------------------------------------------------------------------------------- /.github/workflows/docs-cleanup.yml: -------------------------------------------------------------------------------- 1 | name: docs-cleanup 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - closed 7 | 8 | jobs: 9 | docs-preview: 10 | uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main 11 | permissions: 12 | contents: none 13 | id-token: write 14 | deployments: write 15 | -------------------------------------------------------------------------------- /.github/workflows/github-commands-comment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: github-commands-comment 3 | 4 | on: 5 | pull_request_target: 6 | types: 7 | - opened 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | comment: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | pull-requests: write 17 | steps: 18 | - uses: elastic/oblt-actions/elastic/github-commands@v1 19 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | name: "Issue Labeler" 2 | on: 3 | issues: 4 | types: [opened] 5 | pull_request_target: 6 | types: [opened] 7 | 8 | permissions: 9 | contents: read 10 | issues: write 11 | pull-requests: write 12 | 13 | jobs: 14 | triage: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: AlexanderWert/issue-labeler@v2.3 18 | with: 19 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 20 | configuration-path: .github/labeler-config.yml 21 | enable-versioned-regex: 0 22 | -------------------------------------------------------------------------------- /.github/workflows/microbenchmark.yml: -------------------------------------------------------------------------------- 1 | name: microbenchmark 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | paths-ignore: 9 | - '**.md' 10 | - '**.asciidoc' 11 | tags: 12 | - "v*.*.*" 13 | 14 | # limit the access of the generated GITHUB_TOKEN 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | microbenchmark: 20 | runs-on: ubuntu-latest 21 | timeout-minutes: 5 22 | steps: 23 | - name: Run microbenchmark 24 | uses: elastic/oblt-actions/buildkite/run@v1 25 | with: 26 | pipeline: "apm-agent-microbenchmark" 27 | token: ${{ secrets.BUILDKITE_TOKEN }} 28 | wait-for: false 29 | env-vars: | 30 | script=scripts/ci/bench.sh 31 | repo=apm-agent-go 32 | sha=${{ github.sha }} 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.test 3 | *.out 4 | docs/html 5 | build 6 | .idea 7 | dist 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Release notes are now available in our documentation at ([elastic.co](https://www.elastic.co/guide/en/apm/agent/go/current/release-notes.html)) 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 303 See Other 2 | 3 | Location: https://www.elastic.co/community/codeofconduct 4 | -------------------------------------------------------------------------------- /apmconfig/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 apmconfig provides an API for watching agent config 19 | // changes. 20 | package apmconfig // import "go.elastic.co/apm/v2/apmconfig" 21 | -------------------------------------------------------------------------------- /apmtest/configwatcher.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 apmtest // import "go.elastic.co/apm/v2/apmtest" 19 | 20 | import ( 21 | "context" 22 | 23 | "go.elastic.co/apm/v2/apmconfig" 24 | ) 25 | 26 | // WatchConfigFunc is a function type that implements apmconfig.Watcher. 27 | type WatchConfigFunc func(context.Context, apmconfig.WatchParams) <-chan apmconfig.Change 28 | 29 | // WatchConfig returns f(ctx, params). 30 | func (f WatchConfigFunc) WatchConfig(ctx context.Context, params apmconfig.WatchParams) <-chan apmconfig.Change { 31 | return f(ctx, params) 32 | } 33 | -------------------------------------------------------------------------------- /apmtest/env.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 apmtest // import "go.elastic.co/apm/v2/apmtest" 19 | 20 | import "os" 21 | 22 | func init() { 23 | if os.Getenv("ELASTIC_APM_CLOUD_PROVIDER") == "" { 24 | // Disable cloud metadata sniffing by default in tests. 25 | os.Setenv("ELASTIC_APM_CLOUD_PROVIDER", "none") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /capturebody_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 apm_test 19 | 20 | import ( 21 | "net/http" 22 | "strings" 23 | "testing" 24 | 25 | "go.elastic.co/apm/v2" 26 | "go.elastic.co/apm/v2/apmtest" 27 | ) 28 | 29 | func BenchmarkBodyCapturer(b *testing.B) { 30 | tracer := apmtest.NewDiscardTracer() 31 | defer tracer.Close() 32 | tracer.SetCaptureBody(apm.CaptureBodyAll) 33 | 34 | req, _ := http.NewRequest("GET", "http://testing.invalid", strings.NewReader(strings.Repeat("*", 1024*1024))) 35 | tx := tracer.StartTransaction("name", "type") 36 | 37 | for i := 0; i < b.N; i++ { 38 | bodyCapturer := tracer.CaptureHTTPRequestBody(req) 39 | tx.Context.SetHTTPRequestBody(bodyCapturer) 40 | bodyCapturer.Discard() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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 apm provides an API for tracing 19 | // transactions and capturing errors, sending the 20 | // data to Elastic APM. 21 | package apm // import "go.elastic.co/apm/v2" 22 | -------------------------------------------------------------------------------- /docs/docset.yml: -------------------------------------------------------------------------------- 1 | project: 'APM Go agent docs' 2 | products: 3 | - id: apm-agent 4 | cross_links: 5 | - apm-agent-rum-js 6 | - beats 7 | - docs-content 8 | - ecs 9 | - ecs-logging 10 | - ecs-logging-go-logrus 11 | - ecs-logging-go-zap 12 | - elasticsearch 13 | toc: 14 | - toc: reference 15 | - toc: release-notes 16 | -------------------------------------------------------------------------------- /docs/reference/contributing.md: -------------------------------------------------------------------------------- 1 | --- 2 | mapped_pages: 3 | - https://www.elastic.co/guide/en/apm/agent/go/current/contributing.html 4 | --- 5 | 6 | # Contributing [contributing] 7 | 8 | The Go APM Agent is open source and we love to receive contributions from our community — you! 9 | 10 | There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code. 11 | 12 | You can get in touch with us through [Discuss](https://discuss.elastic.co/c/apm). Feedback and ideas are always welcome. 13 | 14 | 15 | ## Reporting bugs and contributing code [_reporting_bugs_and_contributing_code] 16 | 17 | To report bugs, please create an Issue on the [apm-agent-go](https://github.com/elastic/apm-agent-go) GitHub repository. For tips on contributing code fixes or enhancements, please see the [contributing guide](https://github.com/elastic/apm-agent-go/blob/main/CONTRIBUTING.md) in the code repository. 18 | 19 | -------------------------------------------------------------------------------- /docs/reference/images/dynamic-config.svg: -------------------------------------------------------------------------------- 1 | DynamicDynamic -------------------------------------------------------------------------------- /docs/reference/logs.md: -------------------------------------------------------------------------------- 1 | --- 2 | mapped_pages: 3 | - https://www.elastic.co/guide/en/apm/agent/go/current/logs.html 4 | --- 5 | 6 | # Logs [logs] 7 | 8 | Elastic APM Go Agent provides [*Log Correlation*](/reference/log-correlation.md). The agent will automaticaly inject correlation IDs that allow navigation between logs, traces and services. 9 | 10 | This features is part of [Application log ingestion strategies](docs-content://solutions/observability/logs/stream-application-logs.md). 11 | 12 | The [`ecslogrus`](ecs-logging-go-logrus://reference/index.md) and [`ecszap`](ecs-logging-go-zap://reference/index.md) libraries can also be used to use the [ECS logging](ecs-logging://reference/intro.md) format without an APM agent. When deployed with the Go APM agent, the agent will provide [log correlation](/reference/log-correlation.md) IDs. 13 | 14 | The Go agent provides integrations for popular logging frameworks that inject trace ID fields into the application’s log records. You can find a list of the supported logging frameworks under [supported technologies](/reference/supported-technologies.md#supported-tech-logging). 15 | 16 | If your favorite logging framework is not already supported, there are two other options: 17 | 18 | * Open a feature request, or contribute code, for additional support as described in [*Contributing*](/reference/contributing.md). 19 | * Manually inject trace IDs into log records, as described below in [Manual log correlation](/reference/log-correlation.md#log-correlation-manual). 20 | 21 | -------------------------------------------------------------------------------- /docs/reference/toc.yml: -------------------------------------------------------------------------------- 1 | project: 'APM Go agent reference' 2 | toc: 3 | - file: index.md 4 | - file: set-up-apm-go-agent.md 5 | children: 6 | - file: builtin-modules.md 7 | - file: custom-instrumentation.md 8 | - file: custom-instrumentation-propagation.md 9 | - file: supported-technologies.md 10 | - file: configuration.md 11 | - file: api-documentation.md 12 | - file: metrics.md 13 | - file: logs.md 14 | - file: log-correlation.md 15 | - file: opentelemetry-api.md 16 | - file: opentracing-api.md 17 | - file: contributing.md 18 | - file: upgrading.md -------------------------------------------------------------------------------- /docs/reference/upgrading.md: -------------------------------------------------------------------------------- 1 | --- 2 | mapped_pages: 3 | - https://www.elastic.co/guide/en/apm/agent/go/current/upgrading.html 4 | --- 5 | 6 | # Upgrading [upgrading] 7 | 8 | Upgrades between minor versions of the agent, like from 1.1 to 1.2 are always backwards compatible. Upgrades that involve a major version bump often come with some backwards incompatible changes. 9 | 10 | Before upgrading the agent, be sure to review the: 11 | 12 | * [Agent release notes](/release-notes/index.md) 13 | * [Agent and Server compatibility chart](docs-content://solutions/observability/apm/apm-agent-compatibility.md) 14 | 15 | 16 | ## End of life dates [end-of-life-dates] 17 | 18 | We love all our products, but sometimes we must say goodbye to a release so that we can continue moving forward on future development and innovation. Our [End of life policy](https://www.elastic.co/support/eol) defines how long a given release is considered supported, as well as how long a release is considered still in active development or maintenance. 19 | 20 | -------------------------------------------------------------------------------- /docs/release-notes/deprecations.md: -------------------------------------------------------------------------------- 1 | --- 2 | navigation_title: "Deprecations" 3 | --- 4 | 5 | # Elastic APM deprecations 6 | 7 | Review the deprecated functionality for your Elastic APM version. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. 8 | 9 | % To learn how to upgrade, check out . 10 | 11 | % ## Next version 12 | % **Release date:** Month day, year 13 | 14 | % ::::{dropdown} Deprecation title 15 | % Description of the deprecation. 16 | % For more information, check [PR #](PR link). 17 | % **Impact**
Impact of deprecation. 18 | % **Action**
Steps for mitigating deprecation impact. 19 | % :::: 20 | 21 | ## 2.7.0 [2-7-0] 22 | **Release date:** March 13, 2025 23 | 24 | ::::{dropdown} Drop support for Go 1.22 25 | Per our [Go version support](/reference/supported-technologies.md#supported-tech-go), we can drop support for Go 1.22, as it has reached EOL. 26 | For more information, check [#1697](https://github.com/elastic/apm-agent-go/pull/1697). 27 | % **Impact**
Impact of deprecation. 28 | % **Action**
Steps for mitigating deprecation impact. 29 | :::: 30 | -------------------------------------------------------------------------------- /docs/release-notes/known-issues.md: -------------------------------------------------------------------------------- 1 | --- 2 | navigation_title: "Known issues" 3 | 4 | --- 5 | 6 | # Elastic APM Go Agent known issues [elastic-apm-go-agent-known-issues] 7 | 8 | % Use the following template to add entries to this page. 9 | 10 | % :::{dropdown} Title of known issue 11 | % **Details** 12 | % On [Month/Day/Year], a known issue was discovered that [description of known issue]. 13 | 14 | % **Workaround** 15 | % Workaround description. 16 | 17 | % **Resolved** 18 | % On [Month/Day/Year], this issue was resolved. 19 | 20 | ::: -------------------------------------------------------------------------------- /docs/release-notes/toc.yml: -------------------------------------------------------------------------------- 1 | toc: 2 | - file: index.md 3 | - file: known-issues.md 4 | - file: deprecations.md -------------------------------------------------------------------------------- /error_syscall.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 | //go:build unix || windows 19 | 20 | package apm // import "go.elastic.co/apm/v2" 21 | 22 | import ( 23 | "reflect" 24 | "syscall" 25 | ) 26 | 27 | func init() { 28 | RegisterTypeErrorDetailer(reflect.TypeOf(syscall.Errno(0)), ErrorDetailerFunc(func(err error, details *ErrorDetails) { 29 | errno := err.(syscall.Errno) 30 | details.Code.String = errnoName(errno) 31 | if details.Code.String == "" { 32 | details.Code.Number = float64(errno) 33 | } 34 | })) 35 | } 36 | -------------------------------------------------------------------------------- /error_unix.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 | //go:build unix 19 | 20 | package apm // import "go.elastic.co/apm/v2" 21 | 22 | import ( 23 | "syscall" 24 | 25 | "golang.org/x/sys/unix" 26 | ) 27 | 28 | func errnoName(err syscall.Errno) string { 29 | return unix.ErrnoName(err) 30 | } 31 | -------------------------------------------------------------------------------- /error_windows.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 | //go:build windows 19 | 20 | package apm // import "go.elastic.co/apm/v2" 21 | 22 | import ( 23 | "syscall" 24 | ) 25 | 26 | func errnoName(err syscall.Errno) string { 27 | // There's currently no equivalent of unix.ErrnoName for Windows. 28 | return "" 29 | } 30 | -------------------------------------------------------------------------------- /features/api_key.feature: -------------------------------------------------------------------------------- 1 | Feature: APM server authentication with API key and secret token 2 | 3 | Scenario: A configured API key is sent in the Authorization header 4 | Given an agent configured with 5 | | setting | value | 6 | | api_key | RTNxMjlXNEJt | 7 | When the agent sends a request to APM server 8 | Then the Authorization header of the request is 'ApiKey RTNxMjlXNEJt' 9 | 10 | Scenario: A configured secret token is sent in the Authorization header 11 | Given an agent configured with 12 | | setting | value | 13 | | secret_token | secr3tT0ken | 14 | When the agent sends a request to APM server 15 | Then the Authorization header of the request is 'Bearer secr3tT0ken' 16 | 17 | Scenario: A configured API key takes precedence over a secret token 18 | Given an agent configured with 19 | | setting | value | 20 | | api_key | MjlXNEJasdfDt | 21 | | secret_token | secr3tT0ken | 22 | When the agent sends a request to APM server 23 | Then the Authorization header of the request is 'ApiKey MjlXNEJasdfDt' 24 | 25 | -------------------------------------------------------------------------------- /fnv.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 | // Based on Go's pkg/hash/fnv. 19 | // 20 | // Copyright 2011 The Go Authors. All rights reserved. 21 | // Use of this source code is governed by a BSD-style 22 | // license that can be found in the LICENSE file. 23 | 24 | package apm // import "go.elastic.co/apm/v2" 25 | 26 | const ( 27 | offset64 = 14695981039346656037 28 | prime64 = 1099511628211 29 | ) 30 | 31 | type fnv1a uint64 32 | 33 | func newFnv1a() fnv1a { 34 | return offset64 35 | } 36 | 37 | func (f *fnv1a) add(s string) { 38 | for i := 0; i < len(s); i++ { 39 | *f ^= fnv1a(s[i]) 40 | *f *= prime64 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /fnv_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 apm 19 | 20 | import ( 21 | "hash/fnv" 22 | "testing" 23 | "testing/quick" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestFnv1a(t *testing.T) { 29 | fa := newFnv1a() 30 | fb := fnv.New64a() 31 | err := quick.CheckEqual( 32 | func(s string) uint64 { 33 | fa.add(s) 34 | return uint64(fa) 35 | }, 36 | func(s string) uint64 { 37 | fb.Write([]byte(s)) 38 | return fb.Sum64() 39 | }, 40 | nil, 41 | ) 42 | assert.NoError(t, err) 43 | } 44 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/v2 2 | 3 | require ( 4 | github.com/armon/go-radix v1.0.0 5 | github.com/elastic/go-sysinfo v1.7.1 6 | github.com/google/go-cmp v0.5.4 7 | github.com/pkg/errors v0.9.1 8 | github.com/stretchr/testify v1.8.4 9 | go.elastic.co/fastjson v1.5.1 10 | golang.org/x/sys v0.8.0 11 | ) 12 | 13 | require ( 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect 20 | gopkg.in/yaml.v3 v3.0.1 // indirect 21 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 22 | ) 23 | 24 | go 1.23.0 25 | -------------------------------------------------------------------------------- /internal/apmgodog/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 apmgodog implements the Gherkin feature spec tests. 19 | package apmgodog // import "apmgodog" 20 | -------------------------------------------------------------------------------- /internal/apmhostutil/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 apmhostutil 19 | 20 | import "go.elastic.co/apm/v2/model" 21 | 22 | // Container returns information about the container running the process, or an 23 | // error the container information could not be determined. 24 | func Container() (*model.Container, error) { 25 | return containerInfo() 26 | } 27 | 28 | // Kubernetes returns information about the Kubernetes node and pod running 29 | // the process, or an error if they could not be determined. This information 30 | // does not include the KUBERNETES_* environment variables that can be set via 31 | // the Downward API. 32 | func Kubernetes() (*model.Kubernetes, error) { 33 | return kubernetesInfo() 34 | } 35 | -------------------------------------------------------------------------------- /internal/apmhostutil/container_nonlinux.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 | //go:build !linux 19 | // +build !linux 20 | 21 | package apmhostutil 22 | 23 | import ( 24 | "runtime" 25 | 26 | "github.com/pkg/errors" 27 | 28 | "go.elastic.co/apm/v2/model" 29 | ) 30 | 31 | func containerInfo() (*model.Container, error) { 32 | return nil, errors.Errorf("container ID computation not implemented for %s", runtime.GOOS) 33 | } 34 | 35 | func kubernetesInfo() (*model.Kubernetes, error) { 36 | return nil, errors.Errorf("kubernetes info gathering not implemented for %s", runtime.GOOS) 37 | } 38 | -------------------------------------------------------------------------------- /internal/apmschema/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/internal/apmschema/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/pkg/errors v0.9.1 7 | github.com/santhosh-tekuri/jsonschema v1.2.4 8 | github.com/stretchr/testify v1.8.4 9 | go.elastic.co/apm/v2 v2.7.1 10 | ) 11 | 12 | require ( 13 | github.com/armon/go-radix v1.0.0 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-sysinfo v1.7.1 // indirect 16 | github.com/elastic/go-windows v1.0.0 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | -------------------------------------------------------------------------------- /internal/apmschema/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | BRANCH=master 6 | 7 | FILES=( \ 8 | "error.json" \ 9 | "metadata.json" \ 10 | "metricset.json" \ 11 | "span.json" \ 12 | "transaction.json" \ 13 | ) 14 | 15 | for i in "${FILES[@]}"; do 16 | o=jsonschema/$i 17 | curl -sf https://raw.githubusercontent.com/elastic/apm-server/${BRANCH}/docs/spec/v2/${i} --compressed -o $o 18 | done 19 | -------------------------------------------------------------------------------- /internal/apmstrings/truncate.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 apmstrings 19 | 20 | // Truncate returns s truncated at n runes, and the number 21 | // of runes in the resulting string (<= n). 22 | func Truncate(s string, n int) (string, int) { 23 | var j int 24 | for i := range s { 25 | if j == n { 26 | return s[:i], n 27 | } 28 | j++ 29 | } 30 | return s, j 31 | } 32 | -------------------------------------------------------------------------------- /internal/apmstrings/truncate_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 apmstrings_test 19 | 20 | import ( 21 | "testing" 22 | "unicode/utf8" 23 | 24 | "github.com/stretchr/testify/assert" 25 | 26 | "go.elastic.co/apm/v2/internal/apmstrings" 27 | ) 28 | 29 | func TestTruncate(t *testing.T) { 30 | const limit = 2 31 | test := func(name, in, expect string) { 32 | t.Run(name, func(t *testing.T) { 33 | out, n := apmstrings.Truncate(in, limit) 34 | assert.Equal(t, expect, out) 35 | assert.Equal(t, utf8.RuneCountInString(out), n) 36 | }) 37 | } 38 | test("empty", "", "") 39 | test("limit_ascii", "xx", "xx") 40 | test("limit_multibyte", "世界", "世界") 41 | test("truncate_ascii", "xxx", "xx") 42 | test("truncate_multibyte", "世界世", "世界") 43 | } 44 | -------------------------------------------------------------------------------- /internal/apmversion/version.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 apmversion 19 | 20 | const ( 21 | // AgentVersion is the Elastic APM Go Agent version. 22 | AgentVersion = "2.7.1" 23 | ) 24 | -------------------------------------------------------------------------------- /internal/configutil/list.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 configutil 19 | 20 | import "strings" 21 | 22 | // ParseList parses s as a list of strings, separated by sep, 23 | // and with whitespace trimmed from the list items, omitting 24 | // empty items. 25 | func ParseList(s, sep string) []string { 26 | var list []string 27 | for _, item := range strings.Split(s, sep) { 28 | item = strings.TrimSpace(item) 29 | if item != "" { 30 | list = append(list, item) 31 | } 32 | } 33 | return list 34 | } 35 | -------------------------------------------------------------------------------- /internal/iochan/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 iochan provides a channel-based io.Reader. 19 | package iochan 20 | -------------------------------------------------------------------------------- /internal/ringbuffer/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 ringbuffer provides a ring buffer for storing blocks of bytes. 19 | // Bytes are written and read in discrete blocks. If the buffer becomes 20 | // full, then writing to it will evict the oldest blocks until there is 21 | // space for a new one. 22 | package ringbuffer 23 | -------------------------------------------------------------------------------- /internal/testdata/json-specs/cgroup_parsing.json: -------------------------------------------------------------------------------- 1 | { 2 | "testUnderscores": { 3 | "groupLine": "1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod90d81341_92de_11e7_8cf2_507b9d4141fa.slice/crio-2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63.scope", 4 | "containerId": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63", 5 | "podId": "90d81341-92de-11e7-8cf2-507b9d4141fa" 6 | }, 7 | "testOpenshiftForm": { 8 | "groupLine": "9:freezer:/kubepods.slice/kubepods-pod22949dce_fd8b_11ea_8ede_98f2b32c645c.slice/docker-b15a5bdedd2e7645c3be271364324321b908314e4c77857bbfd32a041148c07f.scope", 9 | "containerId": "b15a5bdedd2e7645c3be271364324321b908314e4c77857bbfd32a041148c07f", 10 | "podId": "22949dce-fd8b-11ea-8ede-98f2b32c645c" 11 | }, 12 | "testUbuntuCGroup": { 13 | "groupLine": "1:name=systemd:/user.slice/user-1000.slice/user@1000.service/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-75bc72bd-6642-4cf5-b62c-0674e11bfc84.scope", 14 | "containerId": null, 15 | "podId": null 16 | }, 17 | "testAwsEcsCGroup": { 18 | "groupLine": "1:name=systemd:/ecs/03752a671e744971a862edcee6195646/03752a671e744971a862edcee6195646-4015103728", 19 | "containerId": "03752a671e744971a862edcee6195646-4015103728", 20 | "podId": null 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /internal/tracecontexttest/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:latest 2 | ADD . /go/src/go.elastic.co/apm 3 | ENV GO111MODULE=on 4 | ENV GOPROXY=https://proxy.golang.org 5 | WORKDIR /go/src/go.elastic.co/apm/internal/tracecontexttest 6 | RUN go build -o /trace-context-service main.go 7 | 8 | EXPOSE 5000/tcp 9 | HEALTHCHECK CMD curl -X POST -H "Content-Type: application/json" -d "{}" http://localhost:5000 10 | CMD /trace-context-service 11 | -------------------------------------------------------------------------------- /internal/tracecontexttest/Dockerfile-harness: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | WORKDIR /w3c 3 | RUN apk add --no-cache git 4 | RUN git clone https://github.com/w3c/trace-context.git 5 | 6 | FROM python:3.12.5-slim-bookworm 7 | RUN pip install aiohttp 8 | WORKDIR /w3c/trace-context 9 | COPY --from=0 /w3c/trace-context . 10 | EXPOSE 7777/tcp 11 | -------------------------------------------------------------------------------- /internal/tracecontexttest/go.mod: -------------------------------------------------------------------------------- 1 | module tracecontexttest/v2 2 | 3 | require go.elastic.co/apm/module/apmhttp/v2 v2.7.1 4 | 5 | require ( 6 | github.com/armon/go-radix v1.0.0 // indirect 7 | github.com/elastic/go-sysinfo v1.7.1 // indirect 8 | github.com/elastic/go-windows v1.0.0 // indirect 9 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 10 | github.com/pkg/errors v0.9.1 // indirect 11 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 12 | go.elastic.co/apm/v2 v2.7.1 // indirect 13 | go.elastic.co/fastjson v1.5.1 // indirect 14 | golang.org/x/sys v0.8.0 // indirect 15 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 16 | ) 17 | 18 | replace go.elastic.co/apm/v2 => ../.. 19 | 20 | replace go.elastic.co/apm/module/apmhttp/v2 => ../../module/apmhttp 21 | 22 | go 1.23.0 23 | -------------------------------------------------------------------------------- /internal/wildcard/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 wildcard provides a fast, zero-allocation wildcard matcher. 19 | package wildcard 20 | -------------------------------------------------------------------------------- /internal/wildcard/matchers.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 wildcard 19 | 20 | // Matchers is a slice of Matcher, matching any of the contained matchers. 21 | type Matchers []*Matcher 22 | 23 | // MatchAny returns true iff any of the matchers returns true. 24 | func (m Matchers) MatchAny(s string) bool { 25 | for _, m := range m { 26 | if m.Match(s) { 27 | return true 28 | } 29 | } 30 | return false 31 | } 32 | -------------------------------------------------------------------------------- /logger.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 apm // import "go.elastic.co/apm/v2" 19 | 20 | // Logger is an interface for logging, used by the tracer 21 | // to log tracer errors and other interesting events. 22 | type Logger interface { 23 | // Debugf logs a message at debug level. 24 | Debugf(format string, args ...interface{}) 25 | 26 | // Errorf logs a message at error level. 27 | Errorf(format string, args ...interface{}) 28 | 29 | // Warningf logs a message at warning level. 30 | Warningf(format string, args ...interface{}) 31 | } 32 | -------------------------------------------------------------------------------- /model/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 model provides the Elastic APM model types. 19 | // 20 | // https://www.elastic.co/guide/en/apm/server/current/intake-api.html 21 | package model // import "go.elastic.co/apm/v2/model" 22 | -------------------------------------------------------------------------------- /model/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | cd "$(dirname "$(readlink -f "$0")")" 4 | 5 | GOMOD=$(pwd)/../tools/go.mod 6 | go run -modfile=$GOMOD go.elastic.co/fastjson/cmd/generate-fastjson -f -o marshal_fastjson.go . 7 | exec go run -modfile=$GOMOD github.com/elastic/go-licenser marshal_fastjson.go 8 | -------------------------------------------------------------------------------- /module/apmawssdkgo/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 apmawssdkgo provides tracing and error-reporting middleware for 19 | // aws-sdk-go. 20 | package apmawssdkgo // import "go.elastic.co/apm/module/apmawssdkgo/v2" 21 | -------------------------------------------------------------------------------- /module/apmawssdkgo/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmawssdkgo/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/aws/aws-sdk-go v1.38.14 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 9 | go.elastic.co/apm/v2 v2.7.1 10 | ) 11 | 12 | require ( 13 | github.com/armon/go-radix v1.0.0 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-sysinfo v1.7.1 // indirect 16 | github.com/elastic/go-windows v1.0.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jmespath/go-jmespath v0.4.0 // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/sys v0.8.0 // indirect 25 | golang.org/x/text v0.9.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | ) 29 | 30 | replace go.elastic.co/apm/v2 => ../.. 31 | 32 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 33 | -------------------------------------------------------------------------------- /module/apmazure/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 apmazure provides tracing and error-reporting middleware for 19 | // azure-sdk-for-go. 20 | package apmazure // import "go.elastic.co/apm/module/apmazure/v2" 21 | -------------------------------------------------------------------------------- /module/apmazure/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmazure/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/Azure/azure-pipeline-go v0.2.3 7 | github.com/Azure/azure-storage-blob-go v0.14.0 8 | github.com/Azure/azure-storage-file-go v0.8.0 9 | github.com/Azure/azure-storage-queue-go v0.0.0-20191125232315-636801874cdd 10 | github.com/stretchr/testify v1.8.4 11 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 12 | go.elastic.co/apm/v2 v2.7.1 13 | ) 14 | 15 | require ( 16 | github.com/armon/go-radix v1.0.0 // indirect 17 | github.com/davecgh/go-spew v1.1.1 // indirect 18 | github.com/elastic/go-sysinfo v1.7.1 // indirect 19 | github.com/elastic/go-windows v1.0.0 // indirect 20 | github.com/google/go-cmp v0.5.4 // indirect 21 | github.com/google/uuid v1.2.0 // indirect 22 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 23 | github.com/mattn/go-ieproxy v0.0.1 // indirect 24 | github.com/pkg/errors v0.9.1 // indirect 25 | github.com/pmezard/go-difflib v1.0.0 // indirect 26 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 27 | go.elastic.co/fastjson v1.5.1 // indirect 28 | golang.org/x/net v0.38.0 // indirect 29 | golang.org/x/sys v0.31.0 // indirect 30 | golang.org/x/text v0.23.0 // indirect 31 | gopkg.in/yaml.v3 v3.0.1 // indirect 32 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 33 | ) 34 | 35 | replace go.elastic.co/apm/v2 => ../.. 36 | 37 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 38 | -------------------------------------------------------------------------------- /module/apmbeego/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 apmbeego provides tracing and error-reporting middleware for Beego applications. 19 | package apmbeego // import "go.elastic.co/apm/module/apmbeego/v2" 20 | -------------------------------------------------------------------------------- /module/apmbeego/example_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 apmbeego_test 19 | 20 | import ( 21 | "github.com/astaxie/beego" 22 | 23 | "go.elastic.co/apm/module/apmbeego/v2" 24 | ) 25 | 26 | func ExampleMiddleware() { 27 | beego.Router("/", &testController{}) 28 | beego.Router("/thing/:id:int", &testController{}, "get:Get") 29 | beego.RunWithMiddleWares("localhost:8080", apmbeego.Middleware()) 30 | } 31 | -------------------------------------------------------------------------------- /module/apmchi/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 apmchi provides middleware for the Chi router, 19 | // for tracing HTTP requests. 20 | package apmchi // import "go.elastic.co/apm/module/apmchi/v2" 21 | -------------------------------------------------------------------------------- /module/apmchi/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmchi/v2 2 | 3 | require ( 4 | github.com/go-chi/chi v1.5.1 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | 28 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 29 | 30 | go 1.23.0 31 | -------------------------------------------------------------------------------- /module/apmchiv5/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 apmchiv5 provides middleware for the v5 Chi router, 19 | // for tracing HTTP requests. 20 | package apmchiv5 // import "go.elastic.co/apm/module/apmchiv5/v2" 21 | -------------------------------------------------------------------------------- /module/apmchiv5/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmchiv5/v2 2 | 3 | require ( 4 | github.com/go-chi/chi/v5 v5.0.2 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | 28 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 29 | 30 | go 1.23.0 31 | -------------------------------------------------------------------------------- /module/apmecho/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 apmecho provides middleware for the Echo framework, 19 | // for tracing HTTP requests. 20 | package apmecho // import "go.elastic.co/apm/module/apmecho/v2" 21 | -------------------------------------------------------------------------------- /module/apmecho/example_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 apmecho_test 19 | 20 | import ( 21 | "github.com/labstack/echo" 22 | 23 | "go.elastic.co/apm/module/apmecho/v2" 24 | "go.elastic.co/apm/v2" 25 | ) 26 | 27 | func ExampleMiddleware() { 28 | e := echo.New() 29 | e.Use(apmecho.Middleware()) 30 | 31 | e.GET("/hello/:name", func(c echo.Context) error { 32 | // The request context contains an apm.Transaction, 33 | // so spans can be reported by passing the context 34 | // to apm.StartSpan. 35 | span, _ := apm.StartSpan(c.Request().Context(), "work", "custom") 36 | defer span.End() 37 | return nil 38 | }) 39 | } 40 | -------------------------------------------------------------------------------- /module/apmecho/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmecho/v2 2 | 3 | require ( 4 | github.com/labstack/echo v3.3.10+incompatible 5 | github.com/pkg/errors v0.9.1 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/google/go-cmp v0.5.4 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/labstack/gommon v0.2.8 // indirect 19 | github.com/mattn/go-colorable v0.0.9 // indirect 20 | github.com/mattn/go-isatty v0.0.4 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | github.com/valyala/bytebufferpool v1.0.0 // indirect 24 | github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 // indirect 25 | go.elastic.co/fastjson v1.5.1 // indirect 26 | golang.org/x/crypto v0.35.0 // indirect 27 | golang.org/x/net v0.23.0 // indirect 28 | golang.org/x/sys v0.30.0 // indirect 29 | golang.org/x/text v0.22.0 // indirect 30 | gopkg.in/yaml.v3 v3.0.1 // indirect 31 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 32 | ) 33 | 34 | replace go.elastic.co/apm/v2 => ../.. 35 | 36 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 37 | 38 | go 1.23.0 39 | -------------------------------------------------------------------------------- /module/apmechov4/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 apmechov4 provides middleware for the version 4 of Echo framework, 19 | // for tracing HTTP requests. 20 | package apmechov4 // import "go.elastic.co/apm/module/apmechov4/v2" 21 | -------------------------------------------------------------------------------- /module/apmechov4/example_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 apmechov4_test 19 | 20 | import ( 21 | "github.com/labstack/echo/v4" 22 | 23 | apmecho "go.elastic.co/apm/module/apmechov4/v2" 24 | "go.elastic.co/apm/v2" 25 | ) 26 | 27 | func ExampleMiddleware() { 28 | e := echo.New() 29 | e.Use(apmecho.Middleware()) 30 | 31 | e.GET("/hello/:name", func(c echo.Context) error { 32 | // The request context contains an apm.Transaction, 33 | // so spans can be reported by passing the context 34 | // to apm.StartSpan. 35 | span, _ := apm.StartSpan(c.Request().Context(), "work", "custom") 36 | defer span.End() 37 | return nil 38 | }) 39 | } 40 | -------------------------------------------------------------------------------- /module/apmechov4/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmechov4/v2 2 | 3 | require ( 4 | github.com/labstack/echo/v4 v4.9.0 5 | github.com/pkg/errors v0.9.1 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/google/go-cmp v0.5.4 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/labstack/gommon v0.3.1 // indirect 19 | github.com/mattn/go-colorable v0.1.11 // indirect 20 | github.com/mattn/go-isatty v0.0.14 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | github.com/valyala/bytebufferpool v1.0.0 // indirect 24 | github.com/valyala/fasttemplate v1.2.1 // indirect 25 | go.elastic.co/fastjson v1.5.1 // indirect 26 | golang.org/x/crypto v0.36.0 // indirect 27 | golang.org/x/net v0.38.0 // indirect 28 | golang.org/x/sys v0.31.0 // indirect 29 | golang.org/x/text v0.23.0 // indirect 30 | gopkg.in/yaml.v3 v3.0.1 // indirect 31 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 32 | ) 33 | 34 | replace go.elastic.co/apm/v2 => ../.. 35 | 36 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 37 | 38 | go 1.23.0 39 | -------------------------------------------------------------------------------- /module/apmelasticsearch/client_example_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 apmelasticsearch 19 | 20 | import ( 21 | "net/http" 22 | ) 23 | 24 | func ExampleWrapRoundTripper() { 25 | httpClient := &http.Client{ 26 | Transport: WrapRoundTripper(http.DefaultTransport), 27 | } 28 | _ = httpClient 29 | 30 | // client, err := elastic.NewClient(elastic.SetHttpClient(httpClient)) 31 | // ... 32 | } 33 | -------------------------------------------------------------------------------- /module/apmelasticsearch/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 apmelasticsearch provides support for tracing the 19 | // HTTP transport layer of Elasticsearch clients. 20 | package apmelasticsearch // import "go.elastic.co/apm/module/apmelasticsearch/v2" 21 | -------------------------------------------------------------------------------- /module/apmelasticsearch/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmelasticsearch/v2 2 | 3 | require ( 4 | github.com/stretchr/testify v1.8.4 5 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/elastic/go-sysinfo v1.7.1 // indirect 13 | github.com/elastic/go-windows v1.0.0 // indirect 14 | github.com/google/go-cmp v0.5.4 // indirect 15 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 16 | github.com/pkg/errors v0.9.1 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | golang.org/x/sys v0.8.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 23 | ) 24 | 25 | replace go.elastic.co/apm/v2 => ../.. 26 | 27 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 28 | 29 | go 1.23.0 30 | -------------------------------------------------------------------------------- /module/apmelasticsearch/internal/integration/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 integration holds integration tests for apmelasticsearch. 19 | // 20 | // This exists as a separate module to avoid adding unnecessary 21 | // third-party dependencies to the apmelasticsearch module. 22 | package integration // import "apmelasticsearch_integration" 23 | -------------------------------------------------------------------------------- /module/apmelasticsearch/internal/integration/go.mod: -------------------------------------------------------------------------------- 1 | module apmelasticsearch_integration/v2 2 | 3 | require ( 4 | github.com/elastic/go-elasticsearch/v7 v7.5.0 5 | github.com/olivere/elastic v6.2.16+incompatible 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmelasticsearch/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/fortytw2/leaktest v1.3.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 19 | github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 // indirect 24 | go.elastic.co/fastjson v1.5.1 // indirect 25 | golang.org/x/sys v0.8.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | ) 29 | 30 | replace go.elastic.co/apm/v2 => ../../../.. 31 | 32 | replace go.elastic.co/apm/module/apmelasticsearch/v2 => ../.. 33 | 34 | replace go.elastic.co/apm/module/apmhttp/v2 => ../../../apmhttp 35 | 36 | go 1.23.0 37 | -------------------------------------------------------------------------------- /module/apmelasticsearch/requestname.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 apmelasticsearch // import "go.elastic.co/apm/module/apmelasticsearch/v2" 19 | 20 | import ( 21 | "net/http" 22 | "strings" 23 | ) 24 | 25 | func requestName(req *http.Request) string { 26 | const prefix = "Elasticsearch:" 27 | path := strings.TrimLeft(req.URL.Path, "/") 28 | 29 | var b strings.Builder 30 | b.Grow(len(prefix) + 1 + len(req.Method) + 1 + len(path)) 31 | b.WriteString(prefix) 32 | b.WriteRune(' ') 33 | b.WriteString(req.Method) 34 | b.WriteRune(' ') 35 | b.WriteString(path) 36 | return b.String() 37 | } 38 | -------------------------------------------------------------------------------- /module/apmfasthttp/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 apmfasthttp provides a tracing middleware fasthttp.RequestHandler for 19 | // servers. 20 | package apmfasthttp // import "go.elastic.co/apm/module/apmfasthttp/v2" 21 | -------------------------------------------------------------------------------- /module/apmfasthttp/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmfasthttp/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.4 7 | github.com/valyala/bytebufferpool v1.0.0 8 | github.com/valyala/fasthttp v1.34.0 9 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 10 | go.elastic.co/apm/v2 v2.7.1 11 | ) 12 | 13 | require ( 14 | github.com/andybalholm/brotli v1.0.4 // indirect 15 | github.com/armon/go-radix v1.0.0 // indirect 16 | github.com/davecgh/go-spew v1.1.1 // indirect 17 | github.com/elastic/go-sysinfo v1.7.1 // indirect 18 | github.com/elastic/go-windows v1.0.0 // indirect 19 | github.com/google/go-cmp v0.5.4 // indirect 20 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 21 | github.com/klauspost/compress v1.15.0 // indirect 22 | github.com/pkg/errors v0.9.1 // indirect 23 | github.com/pmezard/go-difflib v1.0.0 // indirect 24 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 25 | go.elastic.co/fastjson v1.5.1 // indirect 26 | golang.org/x/sys v0.8.0 // indirect 27 | gopkg.in/yaml.v3 v3.0.1 // indirect 28 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 29 | ) 30 | 31 | replace ( 32 | go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 33 | go.elastic.co/apm/v2 => ../.. 34 | ) 35 | -------------------------------------------------------------------------------- /module/apmfiber/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 apmfiber provides a tracing middleware for fasthttp-based server framework Fiber. 19 | package apmfiber // import "go.elastic.co/apm/module/apmfiber/v2" 20 | -------------------------------------------------------------------------------- /module/apmgin/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 apmgin provides middleware for the Gin framework, 19 | // for tracing HTTP requests. 20 | package apmgin // import "go.elastic.co/apm/module/apmgin/v2" 21 | -------------------------------------------------------------------------------- /module/apmgocql/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 apmgocql provides an observer for tracing gocql (Cassandra) query spans. 19 | package apmgocql // import "go.elastic.co/apm/module/apmgocql/v2" 20 | -------------------------------------------------------------------------------- /module/apmgocql/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgocql/v2 2 | 3 | require ( 4 | github.com/gocql/gocql v0.0.0-20181124151448-70385f88b28b 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect 12 | github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/sys v0.8.0 // indirect 25 | gopkg.in/inf.v0 v0.9.1 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | ) 29 | 30 | replace go.elastic.co/apm/v2 => ../.. 31 | 32 | go 1.23.0 33 | -------------------------------------------------------------------------------- /module/apmgokit/README.md: -------------------------------------------------------------------------------- 1 | # apmgokit 2 | 3 | Package apmgokit provides examples and integration tests 4 | for tracing services implemented with Go kit. 5 | 6 | We do not provide any Go kit specific code, as the other 7 | generic modules ([module/apmhttp](../apmhttp) and [module/apmgrpc](../apmgrpc)) 8 | are sufficient. 9 | 10 | Go kit-based HTTP servers can be traced by instrumenting the 11 | kit/transport/http.Server with apmhttp.Wrap, and HTTP clients 12 | can be traced by providing a net/http.Client instrumented with 13 | apmhttp.WrapClient. 14 | 15 | Go kit-based gRPC servers and clients can both be wrapped using 16 | the interceptors provided in module/apmgrpc. 17 | -------------------------------------------------------------------------------- /module/apmgokit/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 apmgokit provides examples and integration tests 19 | // for tracing services implemented with Go kit. 20 | // 21 | // We do not provide any Go kit specific code, as the other 22 | // generic modules (apmhttp and apmgrpc) are sufficient. 23 | // 24 | // Go kit-based HTTP servers can be traced by instrumenting 25 | // the kit/transport/http.Server with apmhttp.Wrap, and HTTP 26 | // clients can be traced by providing a net/http.Client 27 | // instrumented with apmhttp.WrapClient. 28 | // 29 | // Go kit-based gRPC servers and clients can both be wrapped 30 | // using the interceptors provided in module/apmgrpc. 31 | package apmgokit // import "go.elastic.co/apm/module/apmgokit/v2" 32 | -------------------------------------------------------------------------------- /module/apmgometrics/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgometrics/v2 2 | 3 | require ( 4 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/elastic/go-sysinfo v1.7.1 // indirect 13 | github.com/elastic/go-windows v1.0.0 // indirect 14 | github.com/google/go-cmp v0.5.4 // indirect 15 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 16 | github.com/pkg/errors v0.9.1 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | golang.org/x/sys v0.8.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 23 | ) 24 | 25 | replace go.elastic.co/apm/v2 => ../.. 26 | 27 | go 1.23.0 28 | -------------------------------------------------------------------------------- /module/apmgopg/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 apmgopg provides wrappers for tracing go-pg operations. 19 | package apmgopg // import "go.elastic.co/apm/module/apmgopg/v2" 20 | -------------------------------------------------------------------------------- /module/apmgopg/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgopg/v2 2 | 3 | require ( 4 | github.com/go-pg/pg v8.0.7+incompatible 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmsql/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.5 // indirect 16 | github.com/jinzhu/inflection v1.0.0 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/onsi/ginkgo v1.16.5 // indirect 19 | github.com/onsi/gomega v1.18.1 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/crypto v0.35.0 // indirect 25 | golang.org/x/sys v0.30.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | mellium.im/sasl v0.3.1 // indirect 29 | ) 30 | 31 | replace go.elastic.co/apm/v2 => ../.. 32 | 33 | replace go.elastic.co/apm/module/apmsql/v2 => ../apmsql 34 | 35 | go 1.23.0 36 | -------------------------------------------------------------------------------- /module/apmgopgv10/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 apmgopgv10 provides wrappers for tracing go-pg/v10 operations. 19 | package apmgopgv10 // import "go.elastic.co/apm/module/apmgopgv10/v2" 20 | -------------------------------------------------------------------------------- /module/apmgopgv10/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgopgv10/v2 2 | 3 | require ( 4 | github.com/go-pg/pg/v10 v10.7.3 5 | github.com/pkg/errors v0.9.1 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmsql/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/go-pg/zerochecker v0.2.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jinzhu/inflection v1.0.0 // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/pmezard/go-difflib v1.0.0 // indirect 21 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 22 | github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect 23 | github.com/vmihailenco/bufpool v0.1.11 // indirect 24 | github.com/vmihailenco/msgpack/v5 v5.0.0 // indirect 25 | github.com/vmihailenco/tagparser v0.1.2 // indirect 26 | go.elastic.co/fastjson v1.5.1 // indirect 27 | go.opentelemetry.io/otel v0.14.0 // indirect 28 | golang.org/x/crypto v0.35.0 // indirect 29 | golang.org/x/sys v0.30.0 // indirect 30 | gopkg.in/yaml.v3 v3.0.1 // indirect 31 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 32 | mellium.im/sasl v0.3.1 // indirect 33 | ) 34 | 35 | replace go.elastic.co/apm/v2 => ../.. 36 | 37 | replace go.elastic.co/apm/module/apmsql/v2 => ../apmsql 38 | 39 | go 1.23.0 40 | -------------------------------------------------------------------------------- /module/apmgoredis/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 apmgoredis provides helpers for tracing github.com/go-redis/redis client operations as spans. 19 | package apmgoredis // import "go.elastic.co/apm/module/apmgoredis/v2" 20 | -------------------------------------------------------------------------------- /module/apmgoredis/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgoredis/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/go-redis/redis v6.15.9+incompatible 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/google/go-cmp v0.5.4 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/onsi/ginkgo v1.8.0 // indirect 19 | github.com/onsi/gomega v1.5.0 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/net v0.38.0 // indirect 25 | golang.org/x/sys v0.31.0 // indirect 26 | gopkg.in/yaml.v2 v2.4.0 // indirect 27 | gopkg.in/yaml.v3 v3.0.1 // indirect 28 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 29 | ) 30 | 31 | replace go.elastic.co/apm/v2 => ../.. 32 | -------------------------------------------------------------------------------- /module/apmgoredisv8/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 apmgoredisv8 provides helpers for tracing github.com/go-redis/redis/v8 client operations as spans. 19 | package apmgoredisv8 // import "go.elastic.co/apm/module/apmgoredisv8/v2" 20 | -------------------------------------------------------------------------------- /module/apmgoredisv8/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgoredisv8/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/go-redis/redis/v8 v8.11.4 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/cespare/xxhash/v2 v2.1.2 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect 16 | github.com/elastic/go-sysinfo v1.7.1 // indirect 17 | github.com/elastic/go-windows v1.0.0 // indirect 18 | github.com/google/go-cmp v0.5.6 // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/net v0.38.0 // indirect 25 | golang.org/x/sys v0.31.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | ) 29 | 30 | replace go.elastic.co/apm/v2 => ../.. 31 | -------------------------------------------------------------------------------- /module/apmgorilla/context_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 apmgorilla 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestMassageTemplate(t *testing.T) { 27 | out := massageTemplate("/articles/{category}/{id:[0-9]+}") 28 | assert.Equal(t, "/articles/{category}/{id}", out) 29 | } 30 | -------------------------------------------------------------------------------- /module/apmgorilla/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgorilla/v2 2 | 3 | require ( 4 | github.com/gorilla/mux v1.6.2 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/gorilla/context v1.1.1 // indirect 17 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 18 | github.com/pkg/errors v0.9.1 // indirect 19 | github.com/pmezard/go-difflib v1.0.0 // indirect 20 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 21 | go.elastic.co/fastjson v1.5.1 // indirect 22 | golang.org/x/sys v0.8.0 // indirect 23 | gopkg.in/yaml.v3 v3.0.1 // indirect 24 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 25 | ) 26 | 27 | replace go.elastic.co/apm/v2 => ../.. 28 | 29 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 30 | 31 | go 1.23.0 32 | -------------------------------------------------------------------------------- /module/apmgorm/dialects/mysql/init.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 apmgormmysql imports the gorm mysql dialect package, 19 | // and also registers the mysql driver with apmsql. 20 | package apmgormmysql // import "go.elastic.co/apm/module/apmgorm/v2/dialects/mysql" 21 | 22 | import ( 23 | _ "github.com/jinzhu/gorm/dialects/mysql" // import the mysql dialect 24 | 25 | _ "go.elastic.co/apm/module/apmsql/v2/mysql" // register mysql with apmsql 26 | ) 27 | -------------------------------------------------------------------------------- /module/apmgorm/dialects/postgres/init.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 apmgormpostgres imports the gorm postgres dialect package, 19 | // and also registers the lib/pq driver with apmsql. 20 | package apmgormpostgres // import "go.elastic.co/apm/module/apmgorm/v2/dialects/postgres" 21 | 22 | import ( 23 | _ "github.com/jinzhu/gorm/dialects/postgres" // import the postgres dialect 24 | 25 | _ "go.elastic.co/apm/module/apmsql/v2/pq" // register lib/pq with apmsql 26 | ) 27 | -------------------------------------------------------------------------------- /module/apmgorm/dialects/sqlite/init.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 apmgormsqlite imports the gorm sqlite dialect package, 19 | // and also registers the sqlite3 driver with apmsql. 20 | package apmgormsqlite // import "go.elastic.co/apm/module/apmgorm/v2/dialects/sqlite" 21 | 22 | import ( 23 | _ "github.com/jinzhu/gorm/dialects/sqlite" // import the sqlite dialect 24 | 25 | _ "go.elastic.co/apm/module/apmsql/v2/sqlite3" // register sqlite3 with apmsql 26 | ) 27 | -------------------------------------------------------------------------------- /module/apmgorm/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 apmgorm provides wrappers for tracing GORM operations. 19 | package apmgorm // import "go.elastic.co/apm/module/apmgorm/v2" 20 | -------------------------------------------------------------------------------- /module/apmgorm/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgorm/v2 2 | 3 | require ( 4 | github.com/jinzhu/gorm v1.9.10 5 | github.com/pkg/errors v0.9.1 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmsql/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/elastic/go-sysinfo v1.7.1 // indirect 15 | github.com/elastic/go-windows v1.0.0 // indirect 16 | github.com/go-sql-driver/mysql v1.5.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jinzhu/inflection v1.0.0 // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/lib/pq v1.10.2 // indirect 21 | github.com/mattn/go-sqlite3 v1.10.0 // indirect 22 | github.com/pmezard/go-difflib v1.0.0 // indirect 23 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 24 | go.elastic.co/fastjson v1.5.1 // indirect 25 | golang.org/x/sys v0.30.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 28 | ) 29 | 30 | replace go.elastic.co/apm/v2 => ../.. 31 | 32 | replace go.elastic.co/apm/module/apmsql/v2 => ../apmsql 33 | 34 | go 1.23.0 35 | -------------------------------------------------------------------------------- /module/apmgormv2/README.md: -------------------------------------------------------------------------------- 1 | # apmgormv2 2 | 3 | Package apmgormv2 provides drivers to gorm.io/gorm 4 | for tracing database operations as spans of a transaction traced 5 | by Elastic APM. 6 | 7 | ## Usage 8 | 9 | Swap `gorm.io/driver/*` to `go.elastic.co/apm/module/apmgormv2/driver/*` 10 | 11 | Example :- 12 | 13 | ```golang 14 | import ( 15 | mysql "go.elastic.co/apm/module/apmgormv2/driver/mysql" 16 | "gorm.io/gorm" 17 | ) 18 | 19 | db, err := gorm.Open(mysql.Open("dsn"), &gorm.Config{}) 20 | ``` -------------------------------------------------------------------------------- /module/apmgormv2/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 apmgormv2 provides wrappers for tracing GORM operations. 19 | package apmgormv2 // import "go.elastic.co/apm/module/apmgormv2/v2" 20 | -------------------------------------------------------------------------------- /module/apmgormv2/driver/mysql/init.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 apmmysql imports the gorm mysql dialect package, 19 | // and also registers the mysql driver with apmsql. 20 | package apmmysql // import "go.elastic.co/apm/module/apmgormv2/v2/driver/mysql" 21 | 22 | import ( 23 | "gorm.io/driver/mysql" 24 | "gorm.io/gorm" 25 | 26 | "go.elastic.co/apm/module/apmsql/v2" 27 | 28 | _ "go.elastic.co/apm/module/apmsql/v2/mysql" // register mysql with apmsql 29 | ) 30 | 31 | // Open creates a dialect with apmsql 32 | func Open(dsn string) gorm.Dialector { 33 | driverName := mysql.Dialector{}.Name() 34 | dialect := &mysql.Dialector{ 35 | Config: &mysql.Config{ 36 | DriverName: apmsql.DriverPrefix + driverName, 37 | DSN: dsn, 38 | }, 39 | } 40 | 41 | return dialect 42 | } 43 | -------------------------------------------------------------------------------- /module/apmgormv2/driver/postgres/init.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 apmpostgres imports the gorm mysql dialect package, 19 | // and also registers the mysql driver with apmsql. 20 | package apmpostgres // import "go.elastic.co/apm/module/apmgormv2/v2/driver/postgres" 21 | 22 | import ( 23 | "gorm.io/driver/postgres" 24 | "gorm.io/gorm" 25 | 26 | apmpgxv4 "go.elastic.co/apm/module/apmsql/v2/pgxv4" 27 | ) 28 | 29 | // Open creates a dialect with apmsql 30 | func Open(dsn string) gorm.Dialector { 31 | dialect := &postgres.Dialector{ 32 | Config: &postgres.Config{ 33 | DriverName: apmpgxv4.DriverName, 34 | DSN: dsn, 35 | }, 36 | } 37 | 38 | return dialect 39 | } 40 | -------------------------------------------------------------------------------- /module/apmgormv2/driver/sqlite/init.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 apmsqlite imports the gorm sqlite dialect package, 19 | // and also registers the sqlite3 driver with apmsql. 20 | package apmsqlite // import "go.elastic.co/apm/module/apmgormv2/v2/driver/sqlite" 21 | 22 | import ( 23 | "gorm.io/driver/sqlite" 24 | "gorm.io/gorm" 25 | 26 | "go.elastic.co/apm/module/apmsql/v2" 27 | 28 | _ "go.elastic.co/apm/module/apmsql/v2/sqlite3" // register sqlite3 with apmsql 29 | ) 30 | 31 | // Open creates a dialect with apmsql 32 | func Open(dsn string) gorm.Dialector { 33 | 34 | dialect := &sqlite.Dialector{ 35 | DSN: dsn, 36 | DriverName: apmsql.DriverPrefix + sqlite.DriverName, 37 | } 38 | 39 | return dialect 40 | } 41 | -------------------------------------------------------------------------------- /module/apmgormv2/driver/sqlserver/init.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 apmsqlserver imports the gorm sqlserver dialect package, 19 | // and also registers the sqlserver driver with apmsql. 20 | package apmsqlserver // import "go.elastic.co/apm/module/apmgormv2/v2/driver/sqlserver" 21 | 22 | import ( 23 | "gorm.io/driver/sqlserver" 24 | "gorm.io/gorm" 25 | 26 | "go.elastic.co/apm/module/apmsql/v2" 27 | 28 | _ "go.elastic.co/apm/module/apmsql/v2/sqlserver" // register sqlserver with apmsql 29 | ) 30 | 31 | // Open creates a dialect with apmsql 32 | func Open(dsn string) gorm.Dialector { 33 | 34 | dialect := &sqlserver.Dialector{ 35 | Config: &sqlserver.Config{ 36 | DriverName: apmsql.DriverPrefix + sqlserver.Dialector{}.Name(), 37 | DSN: dsn, 38 | }, 39 | } 40 | 41 | return dialect 42 | } 43 | -------------------------------------------------------------------------------- /module/apmgrpc/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 apmgrpc provides interceptors for tracing gRPC. 19 | package apmgrpc // import "go.elastic.co/apm/module/apmgrpc/v2" 20 | -------------------------------------------------------------------------------- /module/apmgrpc/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmgrpc/v2 2 | 3 | require ( 4 | github.com/google/go-cmp v0.5.9 5 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 8 | go.elastic.co/apm/v2 v2.7.1 9 | google.golang.org/grpc v1.57.1 10 | google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 11 | google.golang.org/protobuf v1.33.0 12 | ) 13 | 14 | require ( 15 | github.com/armon/go-radix v1.0.0 // indirect 16 | github.com/davecgh/go-spew v1.1.1 // indirect 17 | github.com/elastic/go-sysinfo v1.7.1 // indirect 18 | github.com/elastic/go-windows v1.0.0 // indirect 19 | github.com/golang/protobuf v1.5.3 // indirect 20 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 21 | github.com/pkg/errors v0.9.1 // indirect 22 | github.com/pmezard/go-difflib v1.0.0 // indirect 23 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 24 | go.elastic.co/fastjson v1.5.1 // indirect 25 | golang.org/x/net v0.33.0 // indirect 26 | golang.org/x/sys v0.28.0 // indirect 27 | golang.org/x/text v0.21.0 // indirect 28 | google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect 29 | gopkg.in/yaml.v3 v3.0.1 // indirect 30 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 31 | ) 32 | 33 | replace go.elastic.co/apm/v2 => ../.. 34 | 35 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 36 | 37 | go 1.23.0 38 | -------------------------------------------------------------------------------- /module/apmgrpc/internal/testservice/testservice.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package go.elastic.co.apm.module.apmgrpc.testservice; 4 | 5 | option go_package = "go.elastic.co/apm/module/apmgrpc/v2/internal/testservice"; 6 | 7 | service Accumulator { 8 | rpc Accumulate(stream AccumulateRequest) returns (stream AccumulateReply) {} 9 | } 10 | 11 | message AccumulateRequest { 12 | int64 value = 1; 13 | } 14 | 15 | message AccumulateReply { 16 | int64 value = 1; 17 | } 18 | -------------------------------------------------------------------------------- /module/apmgrpc/packages.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 apmgrpc // import "go.elastic.co/apm/module/apmgrpc/v2" 19 | 20 | import "go.elastic.co/apm/v2/stacktrace" 21 | 22 | func init() { 23 | stacktrace.RegisterLibraryPackage( 24 | "google.golang.org/grpc", 25 | "github.com/grpc-ecosystem", 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /module/apmhttp/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 apmhttp // import "go.elastic.co/apm/module/apmhttp/v2" 19 | 20 | import ( 21 | "fmt" 22 | ) 23 | 24 | var standardStatusCodeResults = [...]string{ 25 | "HTTP 1xx", 26 | "HTTP 2xx", 27 | "HTTP 3xx", 28 | "HTTP 4xx", 29 | "HTTP 5xx", 30 | } 31 | 32 | // StatusCodeResult returns the transaction result value to use for the given 33 | // status code. 34 | func StatusCodeResult(statusCode int) string { 35 | switch i := statusCode / 100; i { 36 | case 1, 2, 3, 4, 5: 37 | return standardStatusCodeResults[i-1] 38 | } 39 | return fmt.Sprintf("HTTP %d", statusCode) 40 | } 41 | -------------------------------------------------------------------------------- /module/apmhttp/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 apmhttp provides a tracing middleware http.Handler for 19 | // servers, and a tracing http.RoundTripper for clients. 20 | package apmhttp // import "go.elastic.co/apm/module/apmhttp/v2" 21 | -------------------------------------------------------------------------------- /module/apmhttp/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmhttp/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/elastic/go-sysinfo v1.7.1 // indirect 13 | github.com/elastic/go-windows v1.0.0 // indirect 14 | github.com/google/go-cmp v0.5.4 // indirect 15 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 16 | github.com/pmezard/go-difflib v1.0.0 // indirect 17 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 18 | go.elastic.co/fastjson v1.5.1 // indirect 19 | golang.org/x/sys v0.8.0 // indirect 20 | gopkg.in/yaml.v3 v3.0.1 // indirect 21 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 22 | ) 23 | 24 | replace go.elastic.co/apm/v2 => ../.. 25 | 26 | go 1.23.0 27 | -------------------------------------------------------------------------------- /module/apmhttprouter/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmhttprouter/v2 2 | 3 | require ( 4 | github.com/julienschmidt/httprouter v1.2.0 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | 28 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 29 | 30 | go 1.23.0 31 | -------------------------------------------------------------------------------- /module/apmlambda/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 apmlambda provides tracing for AWS Lambda functions. 19 | package apmlambda // import "go.elastic.co/apm/module/apmlambda/v2" 20 | -------------------------------------------------------------------------------- /module/apmlambda/example.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 | //go:build ignore 19 | // +build ignore 20 | 21 | package main 22 | 23 | import ( 24 | "context" 25 | 26 | "github.com/aws/aws-lambda-go/lambda" 27 | 28 | _ "go.elastic.co/apm/module/apmlambda/v2" 29 | ) 30 | 31 | type Request struct { 32 | Name string `json:"name"` 33 | } 34 | 35 | func Handler(ctx context.Context, req Request) (string, error) { 36 | return "Hello, " + req.Name, nil 37 | } 38 | 39 | func main() { 40 | lambda.Start(Handler) 41 | } 42 | -------------------------------------------------------------------------------- /module/apmlambda/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmlambda/v2 2 | 3 | require ( 4 | github.com/aws/aws-lambda-go v1.8.0 5 | go.elastic.co/apm/v2 v2.7.1 6 | ) 7 | 8 | require ( 9 | github.com/armon/go-radix v1.0.0 // indirect 10 | github.com/elastic/go-sysinfo v1.7.1 // indirect 11 | github.com/elastic/go-windows v1.0.0 // indirect 12 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 13 | github.com/pkg/errors v0.9.1 // indirect 14 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 15 | go.elastic.co/fastjson v1.5.1 // indirect 16 | golang.org/x/sys v0.8.0 // indirect 17 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 18 | ) 19 | 20 | replace go.elastic.co/apm/v2 => ../.. 21 | 22 | go 1.23.0 23 | -------------------------------------------------------------------------------- /module/apmlogrus/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmlogrus/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/sirupsen/logrus v1.8.3 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | golang.org/x/sys v0.15.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 23 | ) 24 | 25 | replace go.elastic.co/apm/v2 => ../.. 26 | 27 | go 1.23.0 28 | -------------------------------------------------------------------------------- /module/apmmongo/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 apmmongo provides a CommandMonitor implementation 19 | // for tracing Mongo commands. 20 | package apmmongo // import "go.elastic.co/apm/module/apmmongo/v2" 21 | -------------------------------------------------------------------------------- /module/apmmongo/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmmongo/v2 2 | 3 | require ( 4 | github.com/stretchr/testify v1.8.4 5 | go.elastic.co/apm/v2 v2.7.1 6 | go.mongodb.org/mongo-driver v1.5.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/aws/aws-sdk-go v1.34.28 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/go-stack/stack v1.8.0 // indirect 16 | github.com/golang/snappy v0.0.1 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jmespath/go-jmespath v0.4.0 // indirect 19 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 20 | github.com/klauspost/compress v1.9.5 // indirect 21 | github.com/pkg/errors v0.9.1 // indirect 22 | github.com/pmezard/go-difflib v1.0.0 // indirect 23 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 24 | github.com/xdg-go/pbkdf2 v1.0.0 // indirect 25 | github.com/xdg-go/scram v1.0.2 // indirect 26 | github.com/xdg-go/stringprep v1.0.2 // indirect 27 | github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect 28 | go.elastic.co/fastjson v1.5.1 // indirect 29 | golang.org/x/crypto v0.35.0 // indirect 30 | golang.org/x/sync v0.11.0 // indirect 31 | golang.org/x/sys v0.30.0 // indirect 32 | golang.org/x/text v0.22.0 // indirect 33 | gopkg.in/yaml.v3 v3.0.1 // indirect 34 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 35 | ) 36 | 37 | replace go.elastic.co/apm/v2 => ../.. 38 | 39 | go 1.23.0 40 | -------------------------------------------------------------------------------- /module/apmnegroni/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmnegroni/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.4 7 | github.com/urfave/negroni v1.0.0 8 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 9 | go.elastic.co/apm/v2 v2.7.1 10 | ) 11 | 12 | require ( 13 | github.com/armon/go-radix v1.0.0 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-sysinfo v1.7.1 // indirect 16 | github.com/elastic/go-windows v1.0.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 19 | github.com/pkg/errors v0.9.1 // indirect 20 | github.com/pmezard/go-difflib v1.0.0 // indirect 21 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 22 | go.elastic.co/fastjson v1.5.1 // indirect 23 | golang.org/x/sys v0.8.0 // indirect 24 | gopkg.in/yaml.v3 v3.0.1 // indirect 25 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 26 | ) 27 | 28 | replace go.elastic.co/apm/v2 => ../.. 29 | 30 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 31 | -------------------------------------------------------------------------------- /module/apmot/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 apmot provides an Elastic APM implementation of the OpenTracing API. 19 | // 20 | // Things not implemented by this tracer: 21 | // - binary propagation format 22 | // - baggage 23 | // - logging (generally; errors are reported) 24 | package apmot // import "go.elastic.co/apm/module/apmot/v2" 25 | -------------------------------------------------------------------------------- /module/apmot/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmot/v2 2 | 3 | require ( 4 | github.com/opentracing/opentracing-go v1.1.0 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | 28 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 29 | 30 | go 1.23.0 31 | -------------------------------------------------------------------------------- /module/apmotel/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 apmotel provides helpers for exporting OpenTelemetry data to the Elastic APM Agent. 19 | package apmotel // import "go.elastic.co/apm/module/apmotel/v2" 20 | -------------------------------------------------------------------------------- /module/apmotel/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmotel/v2 2 | 3 | require ( 4 | github.com/stretchr/testify v1.9.0 5 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 6 | go.elastic.co/apm/v2 v2.7.1 7 | go.opentelemetry.io/otel v1.25.0 8 | go.opentelemetry.io/otel/metric v1.25.0 9 | go.opentelemetry.io/otel/sdk v1.25.0 10 | go.opentelemetry.io/otel/sdk/metric v1.25.0 11 | go.opentelemetry.io/otel/trace v1.25.0 12 | ) 13 | 14 | require ( 15 | github.com/armon/go-radix v1.0.0 // indirect 16 | github.com/davecgh/go-spew v1.1.1 // indirect 17 | github.com/elastic/go-sysinfo v1.7.1 // indirect 18 | github.com/elastic/go-windows v1.0.1 // indirect 19 | github.com/go-logr/logr v1.4.1 // indirect 20 | github.com/go-logr/stdr v1.2.2 // indirect 21 | github.com/google/go-cmp v0.6.0 // indirect 22 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 23 | github.com/pkg/errors v0.9.1 // indirect 24 | github.com/pmezard/go-difflib v1.0.0 // indirect 25 | github.com/prometheus/procfs v0.7.3 // indirect 26 | go.elastic.co/fastjson v1.5.1 // indirect 27 | golang.org/x/sys v0.18.0 // indirect 28 | gopkg.in/yaml.v3 v3.0.1 // indirect 29 | howett.net/plist v1.0.0 // indirect 30 | ) 31 | 32 | replace go.elastic.co/apm/v2 => ../.. 33 | 34 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 35 | 36 | go 1.23.0 37 | -------------------------------------------------------------------------------- /module/apmotel/tracer_provider_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 apmotel 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestNewTracerProvider(t *testing.T) { 27 | tp, err := NewTracerProvider() 28 | assert.NoError(t, err) 29 | assert.NotNil(t, tp) 30 | } 31 | 32 | func TestTracerProviderTracer(t *testing.T) { 33 | tp, err := NewTracerProvider() 34 | assert.NoError(t, err) 35 | 36 | tr := tp.Tracer("test") 37 | assert.NotNil(t, tr) 38 | assert.Equal(t, tr, tp.Tracer("test")) 39 | } 40 | -------------------------------------------------------------------------------- /module/apmpgx/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 apmpgx provides helpers for tracing github.com/jackc/pgx/v4. Minimal required version is v4.17 19 | package apmpgx // import "go.elastic.co/apm/module/apmpgx/v2" 20 | -------------------------------------------------------------------------------- /module/apmpgx/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmpgx/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/jackc/pgx/v4 v4.18.2 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/module/apmsql/v2 v2.7.1 9 | go.elastic.co/apm/v2 v2.7.1 10 | ) 11 | 12 | require ( 13 | github.com/armon/go-radix v1.0.0 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-sysinfo v1.7.1 // indirect 16 | github.com/elastic/go-windows v1.0.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jackc/chunkreader/v2 v2.0.1 // indirect 19 | github.com/jackc/pgconn v1.14.3 // indirect 20 | github.com/jackc/pgio v1.0.0 // indirect 21 | github.com/jackc/pgpassfile v1.0.0 // indirect 22 | github.com/jackc/pgproto3/v2 v2.3.3 // indirect 23 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 24 | github.com/jackc/pgtype v1.14.0 // indirect 25 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 26 | github.com/pkg/errors v0.9.1 // indirect 27 | github.com/pmezard/go-difflib v1.0.0 // indirect 28 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 29 | go.elastic.co/fastjson v1.5.1 // indirect 30 | golang.org/x/crypto v0.35.0 // indirect 31 | golang.org/x/sys v0.30.0 // indirect 32 | golang.org/x/text v0.22.0 // indirect 33 | gopkg.in/yaml.v3 v3.0.1 // indirect 34 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 35 | ) 36 | 37 | replace go.elastic.co/apm/v2 => ../.. 38 | 39 | replace go.elastic.co/apm/module/apmsql/v2 => ../apmsql 40 | -------------------------------------------------------------------------------- /module/apmpgxv5/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 apmpgxv5 provides helpers for tracing github.com/jackc/pgx/v5. Minimal required version is v5 19 | package apmpgxv5 // import "go.elastic.co/apm/module/apmpgxv5/v2" 20 | -------------------------------------------------------------------------------- /module/apmpgxv5/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmpgxv5/v2 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/jackc/pgx/v5 v5.5.4 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/module/apmsql/v2 v2.7.1 9 | go.elastic.co/apm/v2 v2.7.1 10 | ) 11 | 12 | require ( 13 | github.com/armon/go-radix v1.0.0 // indirect 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/elastic/go-sysinfo v1.7.1 // indirect 16 | github.com/elastic/go-windows v1.0.0 // indirect 17 | github.com/google/go-cmp v0.5.4 // indirect 18 | github.com/jackc/pgpassfile v1.0.0 // indirect 19 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 20 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 21 | github.com/kr/text v0.2.0 // indirect 22 | github.com/pkg/errors v0.9.1 // indirect 23 | github.com/pmezard/go-difflib v1.0.0 // indirect 24 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 25 | github.com/rogpeppe/go-internal v1.6.1 // indirect 26 | go.elastic.co/fastjson v1.5.1 // indirect 27 | golang.org/x/crypto v0.35.0 // indirect 28 | golang.org/x/sys v0.30.0 // indirect 29 | golang.org/x/text v0.22.0 // indirect 30 | gopkg.in/yaml.v3 v3.0.1 // indirect 31 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 32 | ) 33 | 34 | replace go.elastic.co/apm/v2 => ../.. 35 | 36 | replace go.elastic.co/apm/module/apmsql/v2 => ../apmsql 37 | -------------------------------------------------------------------------------- /module/apmpgxv5/tracer.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 apmpgxv5 // import "go.elastic.co/apm/module/apmpgxv5/v2" 19 | 20 | import ( 21 | "github.com/jackc/pgx/v5" 22 | ) 23 | 24 | type Tracer struct { 25 | QueryTracer 26 | BatchTracer 27 | CopyFromTracer 28 | ConnectTracer 29 | } 30 | 31 | // Instrument setups tracer and sets it to provided config 32 | func Instrument(cfg *pgx.ConnConfig) { 33 | cfg.Tracer = Tracer{} 34 | } 35 | -------------------------------------------------------------------------------- /module/apmprometheus/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmprometheus/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/prometheus/client_golang v1.11.1 6 | github.com/prometheus/client_model v0.2.0 7 | github.com/stretchr/testify v1.8.4 8 | go.elastic.co/apm/v2 v2.7.1 9 | ) 10 | 11 | require ( 12 | github.com/armon/go-radix v1.0.0 // indirect 13 | github.com/beorn7/perks v1.0.1 // indirect 14 | github.com/cespare/xxhash/v2 v2.1.1 // indirect 15 | github.com/davecgh/go-spew v1.1.1 // indirect 16 | github.com/elastic/go-sysinfo v1.7.1 // indirect 17 | github.com/elastic/go-windows v1.0.0 // indirect 18 | github.com/golang/protobuf v1.5.0 // indirect 19 | github.com/google/go-cmp v0.5.5 // indirect 20 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 21 | github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect 22 | github.com/pmezard/go-difflib v1.0.0 // indirect 23 | github.com/prometheus/common v0.26.0 // indirect 24 | github.com/prometheus/procfs v0.6.0 // indirect 25 | go.elastic.co/fastjson v1.5.1 // indirect 26 | golang.org/x/sys v0.8.0 // indirect 27 | google.golang.org/protobuf v1.33.0 // indirect 28 | gopkg.in/yaml.v3 v3.0.1 // indirect 29 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 30 | ) 31 | 32 | replace go.elastic.co/apm/v2 => ../.. 33 | 34 | go 1.23.0 35 | -------------------------------------------------------------------------------- /module/apmredigo/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 apmredigo provides helpers for tracing github.com/gomodule/redigo/redis client operations as spans. 19 | package apmredigo // import "go.elastic.co/apm/module/apmredigo/v2" 20 | -------------------------------------------------------------------------------- /module/apmredigo/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmredigo/v2 2 | 3 | require ( 4 | github.com/gomodule/redigo v1.8.2 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/elastic/go-sysinfo v1.7.1 // indirect 13 | github.com/elastic/go-windows v1.0.0 // indirect 14 | github.com/google/go-cmp v0.5.4 // indirect 15 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 16 | github.com/pkg/errors v0.9.1 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | golang.org/x/sys v0.8.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 23 | ) 24 | 25 | replace go.elastic.co/apm/v2 => ../.. 26 | 27 | go 1.23.0 28 | -------------------------------------------------------------------------------- /module/apmrestful/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 apmrestful provides a tracing and panic/exception 19 | // reporting filter for for the go-restful framework. 20 | package apmrestful // import "go.elastic.co/apm/module/apmrestful/v2" 21 | -------------------------------------------------------------------------------- /module/apmrestful/filter_example_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 apmrestful_test 19 | 20 | import ( 21 | restful "github.com/emicklei/go-restful/v3" 22 | 23 | "go.elastic.co/apm/module/apmrestful/v2" 24 | ) 25 | 26 | func ExampleFilter() { 27 | // Install the filter into the default/global Container. 28 | restful.Filter(apmrestful.Filter()) 29 | } 30 | -------------------------------------------------------------------------------- /module/apmrestful/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmrestful/v2 2 | 3 | require ( 4 | github.com/emicklei/go-restful/v3 v3.12.0 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pkg/errors v0.9.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.0 // indirect 19 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 20 | go.elastic.co/fastjson v1.5.1 // indirect 21 | golang.org/x/sys v0.8.0 // indirect 22 | gopkg.in/yaml.v3 v3.0.1 // indirect 23 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 24 | ) 25 | 26 | replace go.elastic.co/apm/v2 => ../.. 27 | 28 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 29 | 30 | go 1.23.0 31 | -------------------------------------------------------------------------------- /module/apmrestful/route_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 apmrestful 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestMassageRoutePath(t *testing.T) { 27 | out := massageRoutePath("/articles/{category}/{id:[0-9]+}") 28 | assert.Equal(t, "/articles/{category}/{id}", out) 29 | } 30 | -------------------------------------------------------------------------------- /module/apmrestfulv3/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 apmrestfulv3 provides a tracing and panic/exception 19 | // reporting filter for for the go-restful framework version 3. 20 | package apmrestfulv3 // import "go.elastic.co/apm/module/apmrestfulv3/v2" 21 | -------------------------------------------------------------------------------- /module/apmrestfulv3/filter_example_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 apmrestfulv3_test 19 | 20 | import ( 21 | "github.com/emicklei/go-restful/v3" 22 | 23 | "go.elastic.co/apm/module/apmrestfulv3/v2" 24 | ) 25 | 26 | func ExampleFilter() { 27 | // Install the filter into the default/global Container. 28 | restful.Filter(apmrestfulv3.Filter()) 29 | } 30 | -------------------------------------------------------------------------------- /module/apmrestfulv3/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmrestfulv3/v2 2 | 3 | require ( 4 | github.com/emicklei/go-restful/v3 v3.8.0 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/module/apmhttp/v2 v2.7.1 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/json-iterator/go v1.1.11 // indirect 18 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect 19 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 23 | go.elastic.co/fastjson v1.5.1 // indirect 24 | golang.org/x/sys v0.8.0 // indirect 25 | gopkg.in/yaml.v3 v3.0.1 // indirect 26 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 27 | ) 28 | 29 | replace go.elastic.co/apm/v2 => ../.. 30 | 31 | replace go.elastic.co/apm/module/apmhttp/v2 => ../apmhttp 32 | 33 | go 1.23.0 34 | -------------------------------------------------------------------------------- /module/apmrestfulv3/route_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 apmrestfulv3 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestMassageRoutePath(t *testing.T) { 27 | out := massageRoutePath("/articles/{category}/{id:[0-9]+}") 28 | assert.Equal(t, "/articles/{category}/{id}", out) 29 | } 30 | -------------------------------------------------------------------------------- /module/apmslog/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmslog/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | ) 8 | 9 | require ( 10 | github.com/armon/go-radix v1.0.0 // indirect 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/elastic/go-sysinfo v1.7.1 // indirect 13 | github.com/elastic/go-windows v1.0.0 // indirect 14 | github.com/google/go-cmp v0.5.4 // indirect 15 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 16 | github.com/pmezard/go-difflib v1.0.0 // indirect 17 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 18 | go.elastic.co/fastjson v1.5.1 // indirect 19 | golang.org/x/sys v0.8.0 // indirect 20 | gopkg.in/yaml.v3 v3.0.1 // indirect 21 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 22 | ) 23 | 24 | replace go.elastic.co/apm/v2 => ../.. 25 | 26 | go 1.23.0 27 | -------------------------------------------------------------------------------- /module/apmsql/README.md: -------------------------------------------------------------------------------- 1 | # apmsql 2 | 3 | Package apmsql provides a wrapper for database/sql/driver.Drivers 4 | for tracing database operations as spans of a transaction traced 5 | by Elastic APM. 6 | 7 | To instrument a driver, you can simply swap your application's 8 | calls to [sql.Register](https://golang.org/pkg/database/sql/#Register) 9 | and [sql.Open](https://golang.org/pkg/database/sql/#Open) to 10 | apmsql.Register and apmsql.Open respectively. The apmsql.Register 11 | function accepts zero or more options to influence how tracing 12 | is performed. 13 | -------------------------------------------------------------------------------- /module/apmsql/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 apmsql provides wrappers for tracing SQL query spans. 19 | package apmsql // import "go.elastic.co/apm/module/apmsql/v2" 20 | -------------------------------------------------------------------------------- /module/apmsql/internal/pgutil/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 pgutil provides utilities to postgres related modules. 19 | package pgutil 20 | -------------------------------------------------------------------------------- /module/apmsql/mysql/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 apmmysql registers the "mysql" driver with 19 | // apmsql, so that you can trace go-sql-driver/mysql 20 | // database connections. 21 | package apmmysql // import "go.elastic.co/apm/module/apmsql/v2/mysql" 22 | -------------------------------------------------------------------------------- /module/apmsql/mysql/init.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 apmmysql // import "go.elastic.co/apm/module/apmsql/v2/mysql" 19 | 20 | import ( 21 | "github.com/go-sql-driver/mysql" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | func init() { 27 | apmsql.Register("mysql", &mysql.MySQLDriver{}, apmsql.WithDSNParser(ParseDSN)) 28 | } 29 | -------------------------------------------------------------------------------- /module/apmsql/pgxv4/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 apmpgxv4 registers the "postgres" driver with 19 | // apmsql, so that you can trace pgx/v4 database connections. 20 | package apmpgxv4 // import "go.elastic.co/apm/module/apmsql/v2/pgxv4" 21 | -------------------------------------------------------------------------------- /module/apmsql/pgxv4/init.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 apmpgxv4 // import "go.elastic.co/apm/module/apmsql/v2/pgxv4" 19 | 20 | import ( 21 | "github.com/jackc/pgx/v4/stdlib" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | "go.elastic.co/apm/module/apmsql/v2/internal/pgutil" 25 | ) 26 | 27 | // DriverName for pgx v4 28 | const DriverName = apmsql.DriverPrefix + "pgx" 29 | 30 | func init() { 31 | apmsql.Register("pgx", &stdlib.Driver{}, apmsql.WithDSNParser(pgutil.ParseDSN)) 32 | } 33 | -------------------------------------------------------------------------------- /module/apmsql/pq/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 apmpq registers the "postgres" driver with 19 | // apmsql, so that you can trace lib/pq database connections. 20 | package apmpq // import "go.elastic.co/apm/module/apmsql/v2/pq" 21 | -------------------------------------------------------------------------------- /module/apmsql/pq/init.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 apmpq // import "go.elastic.co/apm/module/apmsql/v2/pq" 19 | 20 | import ( 21 | "github.com/lib/pq" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | func init() { 27 | apmsql.Register("postgres", &pq.Driver{}, apmsql.WithDSNParser(ParseDSN)) 28 | } 29 | -------------------------------------------------------------------------------- /module/apmsql/pq/parser.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 apmpq // import "go.elastic.co/apm/module/apmsql/v2/pq" 19 | 20 | import ( 21 | "go.elastic.co/apm/module/apmsql/v2" 22 | "go.elastic.co/apm/module/apmsql/v2/internal/pgutil" 23 | ) 24 | 25 | // ParseDSN is proxy to pgutils.ParseDSN to maintain api compatibility 26 | func ParseDSN(name string) apmsql.DSNInfo { 27 | return pgutil.ParseDSN(name) 28 | } 29 | -------------------------------------------------------------------------------- /module/apmsql/sqlite3/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 apmsqlite3 registers the "sqlite3" driver with 19 | // apmsql, so that you can trace sqlite3 database connections. 20 | package apmsqlite3 // import "go.elastic.co/apm/module/apmsql/v2/sqlite3" 21 | -------------------------------------------------------------------------------- /module/apmsql/sqlite3/init.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 apmsqlite3 // import "go.elastic.co/apm/module/apmsql/v2/sqlite3" 19 | 20 | import ( 21 | sqlite3 "github.com/mattn/go-sqlite3" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | func init() { 27 | apmsql.Register("sqlite3", &sqlite3.SQLiteDriver{}, apmsql.WithDSNParser(ParseDSN)) 28 | } 29 | -------------------------------------------------------------------------------- /module/apmsql/sqlite3/parser.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 apmsqlite3 // import "go.elastic.co/apm/module/apmsql/v2/sqlite3" 19 | 20 | import ( 21 | "strings" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | // ParseDSN parses the sqlite3 datasource name. 27 | func ParseDSN(name string) apmsql.DSNInfo { 28 | if pos := strings.IndexRune(name, '?'); pos >= 0 { 29 | name = name[:pos] 30 | } 31 | return apmsql.DSNInfo{ 32 | Database: name, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /module/apmsql/sqlite3/parser_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 apmsqlite3_test 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | 25 | "go.elastic.co/apm/module/apmsql/v2" 26 | apmsqlite3 "go.elastic.co/apm/module/apmsql/v2/sqlite3" 27 | _ "go.elastic.co/apm/v2/apmtest" // disable default tracer 28 | ) 29 | 30 | func TestParseDSN(t *testing.T) { 31 | assert.Equal(t, apmsql.DSNInfo{Database: "test.db"}, apmsqlite3.ParseDSN("test.db")) 32 | assert.Equal(t, apmsql.DSNInfo{Database: ":memory:"}, apmsqlite3.ParseDSN(":memory:")) 33 | assert.Equal(t, apmsql.DSNInfo{Database: "file:test.db"}, apmsqlite3.ParseDSN("file:test.db?cache=shared&mode=memory")) 34 | } 35 | -------------------------------------------------------------------------------- /module/apmsql/sqlserver/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 apmsqlserver registers the "sqlserver" driver with 19 | // apmsql, so that you can trace microsoft/go-mssqldb 20 | // database connections. 21 | package apmsqlserver // import "go.elastic.co/apm/module/apmsql/v2/sqlserver" 22 | -------------------------------------------------------------------------------- /module/apmsql/sqlserver/init.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 apmsqlserver // import "go.elastic.co/apm/module/apmsql/v2/sqlserver" 19 | 20 | import ( 21 | mssql "github.com/microsoft/go-mssqldb" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | func init() { 27 | apmsql.Register("sqlserver", &mssql.Driver{}, apmsql.WithDSNParser(ParseDSN)) 28 | } 29 | -------------------------------------------------------------------------------- /module/apmsql/sqlserver/parser.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 apmsqlserver // import "go.elastic.co/apm/module/apmsql/v2/sqlserver" 19 | 20 | import ( 21 | "github.com/microsoft/go-mssqldb/msdsn" 22 | 23 | "go.elastic.co/apm/module/apmsql/v2" 24 | ) 25 | 26 | // ParseDSN parses the given microsoft/go-mssqldb datasource name. 27 | func ParseDSN(name string) apmsql.DSNInfo { 28 | cfg, err := msdsn.Parse(name) 29 | if err != nil { 30 | // sqlserver.Open will fail with the same error, 31 | // so just return a zero value. 32 | return apmsql.DSNInfo{} 33 | } 34 | return apmsql.DSNInfo{ 35 | Address: cfg.Host, 36 | Port: int(cfg.Port), 37 | Database: cfg.Database, 38 | User: cfg.User, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /module/apmzap/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmzap/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/stretchr/testify v1.8.4 6 | go.elastic.co/apm/v2 v2.7.1 7 | go.uber.org/zap v1.9.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | go.uber.org/atomic v1.3.2 // indirect 21 | go.uber.org/multierr v1.1.0 // indirect 22 | golang.org/x/sys v0.8.0 // indirect 23 | gopkg.in/yaml.v3 v3.0.1 // indirect 24 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 25 | ) 26 | 27 | replace go.elastic.co/apm/v2 => ../.. 28 | 29 | go 1.23.0 30 | -------------------------------------------------------------------------------- /module/apmzerolog/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 apmzerolog provides an implementaton of zerolog.LevelWriter 19 | // for sending error records to Elastic APM, as well as functions for 20 | // adding trace context and detailed error stack traces to log records. 21 | package apmzerolog // import "go.elastic.co/apm/module/apmzerolog/v2" 22 | -------------------------------------------------------------------------------- /module/apmzerolog/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/module/apmzerolog/v2 2 | 3 | require ( 4 | github.com/pkg/errors v0.9.1 5 | github.com/rs/zerolog v1.14.3 6 | github.com/stretchr/testify v1.8.4 7 | go.elastic.co/apm/v2 v2.7.1 8 | ) 9 | 10 | require ( 11 | github.com/armon/go-radix v1.0.0 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/elastic/go-sysinfo v1.7.1 // indirect 14 | github.com/elastic/go-windows v1.0.0 // indirect 15 | github.com/google/go-cmp v0.5.4 // indirect 16 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 19 | go.elastic.co/fastjson v1.5.1 // indirect 20 | golang.org/x/sys v0.8.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 23 | ) 24 | 25 | replace go.elastic.co/apm/v2 => ../.. 26 | 27 | go 1.23.0 28 | -------------------------------------------------------------------------------- /scripts/Dockerfile-sqlserver: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/mssql/server:2022-latest 2 | 3 | WORKDIR /opt 4 | COPY ./docker_sqlserver_entrypoint.sh ./entrypoint.sh 5 | 6 | USER root 7 | RUN chmod +x ./entrypoint.sh 8 | 9 | CMD /bin/bash ./entrypoint.sh & /opt/mssql/bin/sqlservr -------------------------------------------------------------------------------- /scripts/check_goimports.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | out=$(GOIMPORTSFLAGS=-l ./scripts/goimports.sh) 5 | if [ -n "$out" ]; then 6 | out=$(echo $out | sed 's/ /\n - /') 7 | printf "goimports differs:\n - $out\n" >&2 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /scripts/check_vanity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | out=$(go run -modfile=tools/go.mod github.com/jcchavezs/porto/cmd/porto -l .) 5 | out=$(echo $out | (xargs grep -L "Code generated by" || true)) 6 | 7 | if [ -n "$out" ]; then 8 | out=$(echo $out | sed 's/ /\n - /') 9 | printf "Vanity imports are not up to date:\n - $out\n" >&2 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /scripts/ci/bench.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -exo pipefail 3 | 4 | ## Buildkite specific configuration 5 | if [ "$CI" == "true" ] ; then 6 | export GO111MODULE=on 7 | 8 | # If HOME is not set then use the current directory 9 | # that's normally happening when running in the CI 10 | # owned by Elastic. 11 | if [ -z "$HOME" ] ; then 12 | HOME=$(realpath ~) 13 | export HOME 14 | fi 15 | 16 | # Make sure gomod can be deleted automatically as part of the CI 17 | clean_up () { 18 | ARG=$? 19 | # see https://github.com/golang/go/issues/31481#issuecomment-485008558 20 | chmod u+w -R $HOME/go/pkg 21 | exit $ARG 22 | } 23 | trap clean_up EXIT 24 | fi 25 | 26 | ## Fetch the latest stable goversion 27 | export GO_VERSION=$(curl 'https://go.dev/VERSION?m=text' | grep 'go' | sed 's#go##g') 28 | 29 | ## Bench specific 30 | set -u 31 | source ./scripts/ci/setenv.sh 32 | 33 | export GOFLAGS='-run=NONE -benchmem -bench=.' 34 | export OUT_FILE="build/bench.out" 35 | mkdir -p build 36 | 37 | make test | tee ${OUT_FILE} 38 | 39 | ## Send data if running in the CI 40 | if [ "$CI" == "true" ] ; then 41 | set +x 42 | set +u 43 | echo "Sending data with gobench" 44 | go run -modfile=scripts/ci/ci.go.mod github.com/elastic/gobench -index "benchmark-go" -es "${APM_AGENT_GO_CLOUD_SECRET}" < ${OUT_FILE} 45 | fi 46 | -------------------------------------------------------------------------------- /scripts/ci/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euxo pipefail 3 | 4 | source ./scripts/ci/setenv.sh 5 | 6 | make precheck check-modules 7 | -------------------------------------------------------------------------------- /scripts/ci/ci.go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/scripts/ci 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/elastic/gobench v0.0.0-20220608141032-f30bc57e329c // indirect 7 | github.com/jstemmer/go-junit-report v0.9.1 // indirect 8 | github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /scripts/ci/docker-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euxo pipefail 3 | 4 | source ./scripts/ci/setenv.sh 5 | 6 | 7 | export COV_FILE="build/coverage/coverage.cov" 8 | export OUT_FILE="build/test-report.out" 9 | mkdir -p build/coverage 10 | 11 | echo "W3C Distributed Tracing Validation" 12 | ./scripts/docker-compose-testing run -T --rm trace-context-harness 13 | 14 | ./scripts/docker-compose-testing up -d --build 15 | ./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage GOFLAGS=-v 2> >(tee ${OUT_FILE} 1>&2) > ${COV_FILE} 16 | 17 | gocover-cobertura < "${COV_FILE}" > build/coverage/coverage-apm-agent-go-docker-report.xml 18 | go-junit-report > build/junit-apm-agent-go-docker.xml < ${OUT_FILE} 19 | -------------------------------------------------------------------------------- /scripts/ci/package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Bash strict mode 4 | set -eo pipefail 5 | trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR 6 | 7 | # Found current script directory 8 | readonly RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 9 | 10 | # Found project directory 11 | readonly BASE_PROJECT="$(dirname $(dirname "${RELATIVE_DIR}"))" 12 | 13 | # Extract application version 14 | APP_VERSION="$(sed -n 's/AgentVersion = \"\(.*\)\"/\1/p' version.go | sed -e 's/^[[:space:]]*//')" 15 | 16 | # Create a dist folder 17 | rm -rf "${BASE_PROJECT}/dist" 18 | mkdir -p "${BASE_PROJECT}/dist" 19 | 20 | # Create tarball 21 | cd "${BASE_PROJECT}" 22 | tar -czf "./dist/workspace-${APP_VERSION}.tar.gz" --exclude="workspace-${APP_VERSION}.tar.gz" -C ./ . 23 | -------------------------------------------------------------------------------- /scripts/ci/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euxo pipefail 3 | 4 | source ./scripts/ci/setenv.sh 5 | 6 | # Run the tests 7 | set +e 8 | export OUT_FILE="build/test-report.out" 9 | mkdir -p build 10 | make test 2>&1 | tee ${OUT_FILE} 11 | status=$? 12 | 13 | go-junit-report > "build/junit-apm-agent-go-${GO_VERSION}.xml" < ${OUT_FILE} 14 | 15 | exit ${status} 16 | -------------------------------------------------------------------------------- /scripts/ci/windows/build-test.bat: -------------------------------------------------------------------------------- 1 | :: 2 | :: This script runs the build and test 3 | :: 4 | 5 | mkdir build 6 | 7 | go get -v -u github.com/jstemmer/go-junit-report 8 | go test -v ./... > build\\test.out 2>&1 9 | 10 | type build\\test.out 11 | type build\\test.out | go-junit-report > build\\junit-apm-agent-go.xml 12 | type build\\junit-apm-agent-go.xml 13 | -------------------------------------------------------------------------------- /scripts/docker-compose-testing: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec docker compose -p apm-agent-go-testing -f scripts/docker-compose-testing.yml "$@" 3 | -------------------------------------------------------------------------------- /scripts/docker_sqlserver_entrypoint.sh: -------------------------------------------------------------------------------- 1 | # SQL Server can take a while to start, this scripts waits until it's ready and then creates a database 2 | for i in {1..90}; 3 | do 4 | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password123 -d master -q "IF DB_ID('test_db') IS NULL CREATE DATABASE test_db" 5 | if [ $? -eq 0 ] 6 | then 7 | echo "setup complete" 8 | break 9 | else 10 | echo "not ready yet..." 11 | sleep 1 12 | fi 13 | done -------------------------------------------------------------------------------- /scripts/generate-testservice.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") 4 | 5 | PATH="${TOOLS_DIR}/build/bin:${PATH}" protoc \ 6 | --proto_path=./module/apmgrpc/internal/testservice/ \ 7 | --go_out=./module/apmgrpc \ 8 | --go-grpc_out=./module/apmgrpc \ 9 | --go_opt=module=go.elastic.co/apm/module/apmgrpc/v2 \ 10 | --go-grpc_opt=module=go.elastic.co/apm/module/apmgrpc/v2 \ 11 | ./module/apmgrpc/internal/testservice/testservice.proto 12 | -------------------------------------------------------------------------------- /scripts/generate.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 | //go:generate go run gendockerfile.go -base=.. 19 | 20 | package scripts // import "go.elastic.co/apm/v2/scripts" 21 | -------------------------------------------------------------------------------- /scripts/genmod/go.mod: -------------------------------------------------------------------------------- 1 | module genmod/v2 2 | 3 | require go.elastic.co/apm/v2 v2.7.1 4 | 5 | require ( 6 | github.com/armon/go-radix v1.0.0 // indirect 7 | github.com/elastic/go-sysinfo v1.7.1 // indirect 8 | github.com/elastic/go-windows v1.0.0 // indirect 9 | github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect 10 | github.com/pkg/errors v0.9.1 // indirect 11 | github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect 12 | go.elastic.co/fastjson v1.5.1 // indirect 13 | golang.org/x/sys v0.8.0 // indirect 14 | howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect 15 | ) 16 | 17 | replace go.elastic.co/apm/v2 => ../.. 18 | 19 | go 1.23.0 20 | -------------------------------------------------------------------------------- /scripts/goimports.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dirs=$(find . -maxdepth 1 -type d \! \( -name '.*' -or -name vendor \)) 4 | exec go run -modfile=tools/go.mod golang.org/x/tools/cmd/goimports $GOIMPORTSFLAGS -local go.elastic.co,github.com/elastic *.go $dirs 5 | -------------------------------------------------------------------------------- /scripts/install-protobuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PLATFORM=$(go env GOOS) 4 | PROTOBUF_VERSION="24.2" 5 | PROTOC_GO_VERSION="v1.31.0" 6 | PROTOC_GO_GRPC_VERSION="v1.3.0" 7 | 8 | 9 | if [ "${PLATFORM}" = "darwin" ]; then 10 | PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-osx-x86_64.zip" 11 | elif [ "${PLATFORM}" = "linux" ]; then 12 | PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" 13 | elif [ "${PLATFORM}" = "windows" ]; then 14 | PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-win64.zip" 15 | else 16 | echo "Unsupported platform: ${PLATFORM}" 17 | exit 1 18 | fi 19 | 20 | TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") 21 | BUILD_DIR="${TOOLS_DIR}/build" 22 | PROTOBUF_ZIP="/tmp/protobuf.zip" 23 | 24 | curl -L "${PROTOBUF_URL}" -o "${PROTOBUF_ZIP}" 25 | 26 | if ! unzip -o "${PROTOBUF_ZIP}" -d "${BUILD_DIR}"; then 27 | echo "failed to extract protobuf" 28 | exit 1 29 | fi 30 | 31 | if ! PATH="${BUILD_DIR}/bin" protoc --version; then 32 | echo "failed to verify protobuf installation" 33 | exit 1 34 | fi 35 | 36 | GOBIN="${BUILD_DIR}/bin" go install "google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GO_VERSION}" 37 | GOBIN="${BUILD_DIR}/bin" go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GO_GRPC_VERSION}" 38 | -------------------------------------------------------------------------------- /scripts/moduledirs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Print the module directories. If modules are disabled or unsupported 4 | # by the installed Go toolchain, then just print the current working 5 | # directory (assumed to be the repo top level.) 6 | if test -z "$(go env GOMOD)"; then 7 | pwd 8 | else 9 | # Remove the folder internal/scripts ignore once 10 | # https://github.com/golang/go/issues/65653 has been fixed 11 | find . -type f -not -path '*/tools/*' \ 12 | -not -path '*/internal/*' -not -path '*/scripts/*' \ 13 | -name go.mod -exec dirname '{}' \; 14 | fi 15 | -------------------------------------------------------------------------------- /scripts/tagversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | SED=sed 5 | if [[ $(uname -s) == "Darwin" ]]; then SED=gsed; fi 6 | 7 | prefix=go.elastic.co/apm 8 | version=$(${SED} 's@^\s*AgentVersion = "\(.*\)"$@\1@;t;d' version.go) 9 | major_version=$(echo $version | cut -d. -f1) 10 | modules=$(for dir in $(./scripts/moduledirs.sh); do (cd $dir && go list -m); done | grep ${prefix}) 11 | 12 | echo "# Create tags" 13 | for m in $modules; do 14 | unversioned=$(echo $m | ${SED} "s@^${prefix}/\(.*\)@\1@" | $SED "s@/\?v${major_version}\$@@") 15 | tag=$(echo "${unversioned}/v${version}" | $SED "s@^/@@") 16 | echo git tag -s ${tag} -m v${version} 17 | done 18 | 19 | echo 20 | echo "# Push tags" 21 | echo -n git push upstream 22 | for m in $modules; do 23 | unversioned=$(echo $m | ${SED} "s@^${prefix}/\(.*\)@\1@" | $SED "s@/\?v${major_version}\$@@") 24 | tag=$(echo "${unversioned}/v${version}" | $SED "s@^/@@") 25 | echo -n " ${tag}" 26 | done 27 | echo 28 | -------------------------------------------------------------------------------- /scripts/test_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | profile_out=$(mktemp) 6 | function on_exit { 7 | rm -f $profile_out 8 | } 9 | trap on_exit EXIT 10 | 11 | echo "mode: atomic" 12 | for dir in $(scripts/moduledirs.sh); do 13 | ( 14 | cd $dir 15 | for pkg in $(go list ./...); do 16 | go test -coverpkg=go.elastic.co/apm/... -coverprofile=$profile_out -covermode=atomic $pkg 1>&2 17 | if [ -f $profile_out ]; then 18 | grep -v "mode: atomic" $profile_out || true 19 | rm $profile_out 20 | fi 21 | done 22 | ) 23 | done 24 | -------------------------------------------------------------------------------- /sqlutil/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 sqlutil provides utilities to SQL-related instrumentation modules. 19 | package sqlutil // import "go.elastic.co/apm/v2/sqlutil" 20 | -------------------------------------------------------------------------------- /stacktrace/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 stacktrace provides a simplified stack frame type, 19 | // functions for obtaining stack frames, and related utilities. 20 | package stacktrace // import "go.elastic.co/apm/v2/stacktrace" 21 | -------------------------------------------------------------------------------- /stacktrace/frame.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 stacktrace // import "go.elastic.co/apm/v2/stacktrace" 19 | 20 | // Frame describes a stack frame. 21 | type Frame struct { 22 | // File is the filename of the location of the stack frame. 23 | // This may be either the absolute or base name of the file. 24 | File string 25 | 26 | // Line is the 1-based line number of the location of the 27 | // stack frame, or zero if unknown. 28 | Line int 29 | 30 | // Function is the name of the function name for this stack 31 | // frame. This should be package-qualified, and may be split 32 | // using stacktrace.SplitFunctionName. 33 | Function string 34 | } 35 | -------------------------------------------------------------------------------- /stacktrace/testdata/foo.go: -------------------------------------------------------------------------------- 1 | package testdata 2 | 3 | // Foo does foo. 4 | func Foo() { 5 | panic("context!") 6 | } 7 | -------------------------------------------------------------------------------- /tools/go.mod: -------------------------------------------------------------------------------- 1 | module go.elastic.co/apm/v2/tools 2 | 3 | go 1.23 4 | 5 | require ( 6 | github.com/elastic/go-licenser v0.4.0 7 | github.com/jcchavezs/porto v0.1.0 8 | go.elastic.co/fastjson v1.5.1 9 | golang.org/x/tools v0.30.0 10 | ) 11 | 12 | require ( 13 | golang.org/x/mod v0.23.0 // indirect 14 | golang.org/x/sync v0.11.0 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /tools/tools.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 | //go:build tools 19 | // +build tools 20 | 21 | package main 22 | 23 | import ( 24 | _ "github.com/jcchavezs/porto" 25 | _ "golang.org/x/tools/cmd/goimports" 26 | 27 | _ "github.com/elastic/go-licenser" 28 | _ "go.elastic.co/fastjson/cmd/generate-fastjson" 29 | ) 30 | -------------------------------------------------------------------------------- /transport/api.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 transport // import "go.elastic.co/apm/v2/transport" 19 | 20 | import ( 21 | "context" 22 | "io" 23 | ) 24 | 25 | // Transport provides an interface for sending streams of encoded model 26 | // entities to the Elastic APM server, and for querying config. Methods 27 | // are not required to be safe for concurrent use. 28 | type Transport interface { 29 | // SendStream sends a data stream to the server, returning when the 30 | // stream has been closed (Read returns io.EOF) or the HTTP request 31 | // terminates. 32 | SendStream(context.Context, io.Reader) error 33 | } 34 | -------------------------------------------------------------------------------- /transport/discard.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 transport // import "go.elastic.co/apm/v2/transport" 19 | 20 | import ( 21 | "context" 22 | "io" 23 | ) 24 | 25 | var ( 26 | // Discard is a Transport on which all operations 27 | // succeed without doing anything. 28 | Discard = discardTransport{} 29 | ) 30 | 31 | // NewDiscardTransport returns a Transport that returns the given 32 | // error from all operations. 33 | func NewDiscardTransport(err error) Transport { 34 | return discardTransport{err} 35 | } 36 | 37 | type discardTransport struct { 38 | err error 39 | } 40 | 41 | func (s discardTransport) SendStream(context.Context, io.Reader) error { 42 | return s.err 43 | } 44 | -------------------------------------------------------------------------------- /transport/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 transport provides an interface and implementation 19 | // for transporting data to the Elastic APM server. 20 | package transport // import "go.elastic.co/apm/v2/transport" 21 | -------------------------------------------------------------------------------- /transport/testdata/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC9DCCAdygAwIBAgIRAPrpYLvUsk2GY0O0HrSy1tMwDQYJKoZIhvcNAQELBQAw 3 | EjEQMA4GA1UEChMHQWNtZSBDbzAeFw0xODExMjIwNjQyNDNaFw0xOTExMjIwNjQy 4 | NDNaMBIxEDAOBgNVBAoTB0FjbWUgQ28wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw 5 | ggEKAoIBAQDzcGv/FzFuZTFZ882wWJwYhkah+LiVwXfcN3ZkkzXGI5emz2ghBhkx 6 | RXymZVXj7nX8KktXgPjIF+JUSuDexlp20dcy4Xq9Kfn/zZ025S3l+JqmByboGdU0 7 | cCl7t6nUvySPvVRVWxHuByVCHEWKU+ELR4zlVmREgdHlYj6UGeYsou4pUmYrQkrF 8 | Iw1o+LqTtQ70nUtr82u7qG6i76h0gUYI0bRxmkAwW2kSAsNSM2Hgqou+I+zX0T9v 9 | X6HGsh4pTU6XVJ/r+klBOZM0wXNh9lRQx2+3J8mTxKadXVrBCry333OIRIO9Vv56 10 | 9pEGNHsUqvWMZhpKs7f323MNkMdIu+olAgMBAAGjRTBDMA4GA1UdDwEB/wQEAwIF 11 | oDATBgNVHSUEDDAKBggrBgEFBQcDATAMBgNVHRMBAf8EAjAAMA4GA1UdEQQHMAWC 12 | A2ZvbzANBgkqhkiG9w0BAQsFAAOCAQEAb9hSwjlOzSRWJ4BdJfuSBUjqRUTpulGX 13 | gGzNKH9PZM8wlpRh/Xiv09jN08XpW4pmnDFOMGZnYk4OR3et4pRmlJ2v8yPRsydD 14 | pr4BrKMykY+jsngmsp7tzZBt+vHACyqplD8K8SivIuxsXrbUu9ekkMemv0G82TmO 15 | ZUCerakCm8sojmQOTfb7ZqAfZifnGwTRi+6y3TCkwIupTL3l/S8E42L7l8gg+xGU 16 | 5nYYHVgyZroEuoJtGVmvakJJpGLcEzD2ai4X212qKC1dp9cjzfWgWxImn9jivYqy 17 | cxsI6aaSYdZaM2JkmtnDLV0auBs0r8SN2nluFxxEStpK/zxn8SH5Sw== 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /transport/transporttest/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 transporttest provides implementations of 19 | // transport.Transport for testing purposes. 20 | package transporttest // import "go.elastic.co/apm/v2/transport/transporttest" 21 | -------------------------------------------------------------------------------- /updatecli-compose.yaml: -------------------------------------------------------------------------------- 1 | policies: 2 | - name: Handle apm-data server specs 3 | policy: ghcr.io/elastic/oblt-updatecli-policies/apm/apm-data-spec:0.6.0@sha256:c0bbdec23541bed38df1342c95aeb601530a113db1ff11715c1c7616ed5e9e8b 4 | values: 5 | - .ci/updatecli/values.d/scm.yml 6 | - .ci/updatecli/values.d/apm-data-spec.yml 7 | - name: Handle apm gherkin specs 8 | policy: ghcr.io/elastic/oblt-updatecli-policies/apm/apm-gherkin:0.6.0@sha256:dbaf4d855c5c212c3b5a8d2cc98c243a2b769ac347198ae8814393a1a0576587 9 | values: 10 | - .ci/updatecli/values.d/scm.yml 11 | - .ci/updatecli/values.d/apm-gherkin.yml 12 | - name: Handle apm json specs 13 | policy: ghcr.io/elastic/oblt-updatecli-policies/apm/apm-json-specs:0.6.0@sha256:e5a74c159ceed02fd20515ea76fa25ff81e3ccf977e74e636f9973db86aa52a5 14 | values: 15 | - .ci/updatecli/values.d/scm.yml 16 | - .ci/updatecli/values.d/apm-json-specs.yml 17 | - name: Update Updatecli policies 18 | policy: ghcr.io/updatecli/policies/autodiscovery/updatecli:0.8.0@sha256:99e9e61b501575c2c176c39f2275998d198b590a3f6b1fe829f7315f8d457e7f 19 | values: 20 | - .ci/updatecli/values.d/scm.yml 21 | - .ci/updatecli/values.d/update-compose.yml 22 | -------------------------------------------------------------------------------- /utils_linux.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 apm // import "go.elastic.co/apm/v2" 19 | 20 | import ( 21 | "bytes" 22 | "syscall" 23 | "unsafe" 24 | ) 25 | 26 | func currentProcessTitle() (string, error) { 27 | // PR_GET_NAME (since Linux 2.6.11) 28 | // Return the name of the calling thread, in the buffer pointed to by 29 | // (char *) arg2. The buffer should allow space for up to 16 bytes; 30 | // the returned string will be null-terminated. 31 | var buf [16]byte 32 | if _, _, errno := syscall.RawSyscall6( 33 | syscall.SYS_PRCTL, syscall.PR_GET_NAME, 34 | uintptr(unsafe.Pointer(&buf[0])), 35 | 0, 0, 0, 0, 36 | ); errno != 0 { 37 | return "", errno 38 | } 39 | return string(buf[:bytes.IndexByte(buf[:], 0)]), nil 40 | } 41 | -------------------------------------------------------------------------------- /utils_other.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 | //go:build !linux 19 | // +build !linux 20 | 21 | package apm // import "go.elastic.co/apm/v2" 22 | 23 | import ( 24 | "github.com/pkg/errors" 25 | 26 | sysinfo "github.com/elastic/go-sysinfo" 27 | ) 28 | 29 | func currentProcessTitle() (string, error) { 30 | proc, err := sysinfo.Self() 31 | if err != nil { 32 | return "", errors.Wrap(err, "failed to get process info") 33 | } 34 | info, err := proc.Info() 35 | if err != nil { 36 | return "", errors.Wrap(err, "failed to get process info") 37 | } 38 | return info.Name, nil 39 | } 40 | -------------------------------------------------------------------------------- /version.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 apm // import "go.elastic.co/apm/v2" 19 | 20 | const ( 21 | // AgentVersion is the Elastic APM Go Agent version. 22 | AgentVersion = "2.7.1" 23 | ) 24 | -------------------------------------------------------------------------------- /version_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 apm_test 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | 25 | "go.elastic.co/apm/v2" 26 | "go.elastic.co/apm/v2/internal/apmversion" 27 | ) 28 | 29 | func TestAgentVersion(t *testing.T) { 30 | // Ensure apmversion.AgentVersion is kept in sync. 31 | // 32 | // NOTE We do not want a dependency from apmversion back 33 | // to apm, and we want to use a string literal in the 34 | // apm package for godoc. 35 | assert.Equal(t, apmversion.AgentVersion, apm.AgentVersion) 36 | } 37 | --------------------------------------------------------------------------------