Skip to content

Commit

Permalink
add user-agent spec + gherkin spec (#514)
Browse files Browse the repository at this point in the history
* add user-agent spec + gherkin spec

* update regex

* make regex a bit more strict

* wording fix specs/agents/transport.md

Co-authored-by: Trent Mick <trentm@gmail.com>

* align spec to es-client user-agent header

Co-authored-by: Trent Mick <trentm@gmail.com>
  • Loading branch information
SylvainJuge and trentm authored Oct 12, 2021
1 parent 1831cc3 commit 9dd05a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions specs/agents/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

Agents send data to the APM Server as JSON (application/json) or ND-JSON (application/x-ndjson) over HTTP. We describe here various details to guide transport implementation.

### User-Agent

In order to help debugging and gathering usage statistics, agents should use one of the following values for the `User-Agent` HTTP header:

- Header value should start with agent github repository as prefix and version `apm-agent-${language}/${agent.version}`.
- If both `service.name` and `service.version` are set, append ` (${service.name} ${service.version})`
- If only `service.name` is set, append `(${service.name})`

An executable gherkin specification is also provided in [user_agent.feature](../../tests/agents/gherkin-specs/user_agent.feature).

Examples:
- `apm-agent-java/v1.25.0`
- `apm-agent-ruby/4.4.0 (myservice)`
- `apm-agent-python/6.4.0 (myservice v42.7)`

### Background sending

In order to avoid impacting application performance and behaviour, agents should (where possible) send data in a non-blocking manner, e.g. via a background thread/goroutine/process/what-have-you, or using asynchronous I/O.
Expand Down
19 changes: 19 additions & 0 deletions tests/agents/gherkin-specs/user_agent.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Agent Transport User agent Header

Scenario: Default user-agent
Given an agent
When service name is not set
When service version is not set
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]*'

Scenario: User-agent with service name only
Given an agent
When service name is set to 'myService'
When service version is not set
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]* \(myService\)'

Scenario: User-agent with service name and service version
Given an agent
When service name is set to 'myService'
When service version is set to 'v42'
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]* \(myService v42\)'

0 comments on commit 9dd05a8

Please sign in to comment.