Skip to content

Instantly share code, notes, and snippets.

@axw
Created February 21, 2018 04:45
Show Gist options
  • Save axw/db86c1ba241da6c65f5516f54568f5f9 to your computer and use it in GitHub Desktop.
Save axw/db86c1ba241da6c65f5516f54568f5f9 to your computer and use it in GitHub Desktop.
WIP Swagger spec for APM intake API
swagger: "2.0"
info:
description: Elastic APM intake API
title: Elastic APM
version: "1.0"
schemes:
- http
basePath: "/v1"
paths:
/transactions:
post:
summary: Process transaction trace data.
consumes:
- application/json
parameters:
- name: payload
in: body
required: true
schema:
$ref: "#/definitions/TransactionsPayload"
responses:
202:
description: transactions payload accepted
503:
description: transactions payload could not be accepted
default:
description: generic error
/errors:
post:
summary: Process error data.
consumes:
- application/json
parameters:
- name: payload
in: body
required: true
schema:
$ref: "#/definitions/ErrorsPayload"
responses:
202:
description: errors payload accepted
503:
description: errors payload could not be accepted
default:
description: generic error
definitions:
TransactionsPayload:
type: object
required:
- transactions
- service
properties:
service:
$ref: "#/definitions/Service"
process:
$ref: "#/definitions/Process"
system:
$ref: "#/definitions/System"
transactions:
type: array
items:
$ref: "#/definitions/Transaction"
minItems: 1
ErrorsPayload:
type: object
required:
- errors
- service
properties:
service:
$ref: "#/definitions/Service"
process:
$ref: "#/definitions/Process"
system:
$ref: "#/definitions/System"
errors:
type: array
items:
$ref: "#/definitions/Error"
minItems: 1
Transaction:
type: object
required:
- id
- duration
- type
- timestamp
properties:
id:
format: uuid
duration:
format: float
type:
type: string
timestamp:
format: date-time
context:
$ref: "#/definitions/Context"
name:
type: string
maxLength: 1024
result:
type: string
maxLength: 1024
sampled:
type: boolean
marks:
type: object
additionalProperties:
$ref: "#/definitions/Mark"
span_count:
type: object
properties:
dropped:
type: object
properties:
total:
type: number
spans:
type: array
items:
$ref: "#/definitions/Span"
Service:
type: object
required:
- agent
- name
properties:
name:
type: string
pattern: "^[a-zA-Z0-9 _-]+$"
maxLength: 1024
version:
type: string
maxLength: 1024
environment:
type: string
maxLength: 1024
agent:
$ref: "#/definitions/Agent"
framework:
$ref: "#/definitions/Framework"
language:
$ref: "#/definitions/Language"
runtime:
$ref: "#/definitions/Runtime"
Process:
type: object
required:
- pid
properties:
pid:
type: integer
ppid:
type: integer
title:
type: string
maxLength: 1024
argv:
type: array
items:
type: string
System:
type: object
properties:
architecture:
type: string
maxLength: 1024
hostname:
type: string
maxLength: 1024
platform:
type: string
maxLength: 1024
Agent:
type: object
required:
- name
- version
properties:
name:
type: string
maxLength: 1024
version:
type: string
maxLength: 1024
Framework:
type: object
required:
- name
- version
properties:
name:
type: string
maxLength: 1024
version:
type: string
maxLength: 1024
Language:
type: object
required:
- name
properties:
name:
type: string
maxLength: 1024
version:
type: string
maxLength: 1024
Runtime:
type: object
required:
- name
- version
properties:
name:
type: string
maxLength: 1024
version:
type: string
maxLength: 1024
Context:
type: object
properties:
custom:
type: object
additionalProperties:
type: object
version:
type: string
maxLength: 1024
request:
$ref: "#/definitions/Request"
response:
$ref: "#/definitions/Response"
tags:
type: object
additionalProperties:
type: string
user:
$ref: "#/definitions/User"
Request:
type: object
required:
- url
- method
properties:
body:
type: object
env:
type: object
headers:
type: object
properties:
"content-type":
type: string
cookie:
type: string
"user-agent":
type: string
http_version:
type: string
maxLength: 1024
method:
type: string
maxLength: 1024
socket:
type: object
properties:
encrypted:
type: boolean
remote_address:
type: string
url:
properties:
raw:
type: string
maxLength: 1024
protocol:
type: string
maxLength: 1024
full:
type: string
maxLength: 1024
hostname:
type: string
maxLength: 1024
port:
type: string
maxLength: 1024
pathname:
type: string
maxLength: 1024
search:
type: string
maxLength: 1024
hash:
type: string
maxLength: 1024
cookies:
type: object
Response:
type: object
properties:
finished:
type: boolean
headers:
type: object
properties:
"content-type":
type: string
headers_sent:
type: boolean
status_code:
type: integer
User:
type: object
properties:
id:
# XXX OAS 2.0 doesn't support oneOf, so we use type object
# to signify that the value can be of any type. We'll need
# to have custom validation code to check that it's either
# a string or a number.
type: object
email:
format: email
maxLength: 1024
username:
type: string
maxLength: 1024
Mark:
type: object
additionalProperties:
type: number
Span:
type: object
required:
- duration
- name
- start
- type
properties:
id:
type: integer
parent:
# XXX in JSON-Schema, there's a dependency on "id".
# OAS 2.0 (nor 3.0, AFAICT) support dependencies.
type: integer
start:
type: number
duration:
type: number
name:
type: string
maxLength: 1024
type:
type: string
maxLength: 1024
stacktrace:
type: array
items:
$ref: "#/definitions/StacktraceFrame"
context:
type: object
properties:
db:
type: object
properties:
instance:
type: string
statement:
type: string
type:
type: string
user:
type: string
StacktraceFrame:
type: object
required:
- filename
- lineno
properties:
abs_path:
type: string
colno:
type: integer
context_line:
type: string
filename:
type: string
function:
type: string
library_frame:
type: boolean
lineno:
type: integer
module:
type: string
post_context:
type: array
items:
type: string
pre_context:
type: array
items:
type: string
vars:
type: object
additionalProperties:
type: object
Error:
type: object
required:
- timestamp
properties:
context:
$ref: "#/definitions/Context"
id:
format: uuid
timestamp:
format: date-time
culprit:
type: string
exception:
$ref: "#/definitions/Exception"
log:
$ref: "#/definitions/LogRecord"
transaction:
type: object
properties:
id:
format: uuid
Exception:
type: object
required:
- message
properties:
code:
# XXX OAS 2.0 doesn't support oneOf, so we use type object
# to signify that the value can be of any type. We'll need
# to have custom validation code to check that it's either
# a string or a number.
type: object
message:
type: string
module:
type: string
maxLength: 1024
type:
type: string
maxLength: 1024
handled:
type: boolean
attributes:
type: object
stacktrace:
type: array
items:
$ref: "#/definitions/StacktraceFrame"
LogRecord:
type: object
required:
- message
properties:
level:
type: string
default: error
enum:
- debug
- info
- warning
- error
- fatal
maxLength: 1024
logger_name:
type: string
default: default
maxLength: 1024
message:
type: string
param_message:
type: string
maxLength: 1024
stacktrace:
type: array
items:
$ref: "#/definitions/StacktraceFrame"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment