Skip to content

Commit

Permalink
Update database semantic conventions
Browse files Browse the repository at this point in the history
Release v0.6.0 of the opentelemetry spec included some changes to the
database semantic conventions, among them being changes to some of the
fields used to convert to Azure Dependency Targets etc.

open-telemetry/opentelemetry-specification#575

This commit updates the exporter to handle the new names for these
fields, however as the new equivalent to `db.instance` is `db.name`,
which can change when the database is changed inside a connection.
  • Loading branch information
johnchildren committed Aug 6, 2020
1 parent c28457f commit a3b0f6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ The following of the Span's attributes map to special fields in Application Insi
| `db.statement` | Dependency Data |
| `http.host` | Dependency Target |
| `net.peer.name` | Dependency Target |
| `db.instance` | Dependency Target |
| `db.name` | Dependency Target |
| `http.status_code` | Dependency Result code |
| `db.type` | Dependency Type |
| `db.system` | Dependency Type |
| `messaging.system` | Dependency Type |
| `"HTTP"` if any `http.` attribute exists | Dependency Type |
| `"DB"` if any `db.` attribute exists | Dependency Type |
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
//! | `db.statement` | Dependency Data |
//! | `http.host` | Dependency Target |
//! | `net.peer.name` | Dependency Target |
//! | `db.instance` | Dependency Target |
//! | `db.name` | Dependency Target |
//! | `http.status_code` | Dependency Result code |
//! | `db.type` | Dependency Type |
//! | `db.system` | Dependency Type |
//! | `messaging.system` | Dependency Type |
//! | `"HTTP"` if any `http.` attribute exists | Dependency Type |
//! | `"DB"` if any `db.` attribute exists | Dependency Type |
Expand Down Expand Up @@ -254,14 +254,14 @@ impl Exporter {
data.target = Some(String::from(*host));
} else if let Some(peer_name) = attrs.get("net.peer.name") {
data.target = Some(String::from(*peer_name));
} else if let Some(db_instance) = attrs.get("db.instance") {
data.target = Some(String::from(*db_instance));
} else if let Some(db_name) = attrs.get("db.name") {
data.target = Some(String::from(*db_name));
}
if span.span_kind == SpanKind::Internal {
data.type_ = Some("InProc".into());
data.success = Some(true);
} else if let Some(db_type) = attrs.get("db.type") {
data.type_ = Some(String::from(*db_type));
} else if let Some(db_system) = attrs.get("db.system") {
data.type_ = Some(String::from(*db_system));
} else if let Some(messaging_system) = attrs.get("messaging.system") {
data.type_ = Some(String::from(*messaging_system));
} else if attrs.keys().any(|x| x.starts_with("http.")) {
Expand Down

0 comments on commit a3b0f6f

Please sign in to comment.