Skip to content

New values for span.type and introduce span.subtype, span.action #8

Closed
@roncohen

Description

@roncohen

At the moment our span types are in the form of span.type: db.mysql.query and indexed as a keyword.

They are loosely defined and you cannot easily search for example mysql. It hampers our ability to aggregate information across spans and makes the UI and data model more complicated than needed.

To fix this , we're going to introduce two new fields: span.subtype and span.action. We're also changing span.type from the dot-delimited format: span.type: db.mysql.query to just be the overarching span type: db, template, external:

Here's some examples:

| Field | Optional |
Description | Examples |
| --- | --- | --- | --- |
| type | No | Overarching type of span | * db
* cache
* template
* external |
| subtype | Yes | Sub division per type | * postgresql, mysql (db)
* jinja2, mustache (template)
* http , thrift (external) |
| action | Yes | Detail on what actually transpired | * query
* connect |

The values will not be enforced in the APM Server, but we should align on what the fields mean and some common values. Agents should be able to set the values for new instrumentations as they see fit.

Agent devs should make the actual alignment in this doc: https://docs.google.com/spreadsheets/d/1SmWeX5AeqUcayrArUauS_CxGgsjwRgMYH4ZY8yQsMhQ/edit#gid=644582948

OpenTracing

OpenTracing doesn't have a specification for these, however, we should make a mapping that allows us the set the span.type from the tags that users set using the OpenTracing API:

OT states:

Database type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis".

Here's a quick attempt at such a mapping:

OT tags ElasticAPM types
db.type=sql type=db, subtype=sql
db.type=cassandra type=db, subtype=cassandra
db.type=redis type=db, subtype=redis
http.* is set type=ext, subtype=http
message_bus.* is set, peer.service=kafka type=message_bus, subtype=kafka

As you can see, SQL is a bit of a special case in OpenTracing. We might be able to deduct the SQL software from peer.service, but it's also fine to start as type=db/subtype=sql for the OT case for now.

You may ask, what happens if both db.type=sql and message_bus.something is set:

  1. I can't come up with a situation where that makes sense.
  2. We'd need to just pick one of them to use in the mapping

Backwards compatibility

The UI could handle it gracefully and just show the type as type.split('.')[0], but anyone who relies on the types for dashboards etc. would be out of luck. We're OK with this breaking change in a minor, as I think it's not likely that anyone has built custom dashboards that rely on the type.


@elastic/apm-agent-devs @elastic/apm-ui please create an issue in your repo and add the link here / check the checkbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions