Skip to content

Commit

Permalink
align spec to es-client user-agent header
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge committed Oct 11, 2021
1 parent ab86083 commit 0e2bc44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions specs/agents/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ Agents send data to the APM Server as JSON (application/json) or ND-JSON (applic

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 `elasticapm-${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}`
- 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:
- `elasticapm-java/v1.25.0`
- `elasticapm-ruby/4.4.0 myservice`
- `elasticapm-python/6.4.0 myservice/v42.7`
- `apm-agent-java/v1.25.0`
- `apm-agent-ruby/4.4.0 (myservice)`
- `apm-agent-python/6.4.0 (myservice v42.7)`

### Background sending

Expand Down
6 changes: 3 additions & 3 deletions tests/agents/gherkin-specs/user_agent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Feature: Agent Transport User agent Header
Given an agent
When service name is not set
When service version is not set
Then the User-Agent header matches regex '^elasticapm-[a-z]+/[^ ]*'
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 '^elasticapm-[a-z]+/[^ ]* myService'
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 '^elasticapm-[a-z]+/[^ ]* myService/v42'
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]* \(myService v42\)'

0 comments on commit 0e2bc44

Please sign in to comment.