Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OpenTelemetry to 0.23 #77

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- Upgrade `opentelemetry` and `opentelemetry_sdk` to `v0.23`.
- Upgrade `opentelemetry-http` to `v0.12`.
- Upgrade `opentelemetry-semantic-conventions` to `v0.15`.
- This removes and deprecates some attributes. All removed/deprecated attributes continue to work. Consider migrating to the new attributes in the future. See "Deprecated attributes" in opentelemetry-application-insights documentation for suitable replacements.
- Set tags Cloud role and Cloud role instance also from resource attributes `k8s.{deployment,replicaset,statefulset,job,cronjob,daemonset,pod}.name`. This matches [the behavior of the JS exporter](https://github.com/Azure/azure-sdk-for-js/blob/c66cad23c4b803719db65cb48a453b0adc13307b/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts#L75-L138).
- Remove option to configure temporality seletor (`with_temporality_selector`). Application Insights supports delta temporality only as defined in the [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/58bfe48eabe887545198d66c43f44071b822373f/specification/metrics/sdk_exporters/otlp.md?plain=1#L46-L47).
- Add support for `ExponentialHistogram` export.
Expand Down Expand Up @@ -52,7 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Upgrade to `v0.20.0` of `opentelemetry`.
- Upgrade to `v0.12.0` of `opentelemetry-semantic-conventions`.
- This removes and deprecates some attributes. All removes/deprecated attributes continue to work. Consider migrating to the new attributes in the future. See "Deprecated attributes" in opentelemetry-application-insights documentation for suitable replacements.
- This removes and deprecates some attributes. All removed/deprecated attributes continue to work. Consider migrating to the new attributes in the future. See "Deprecated attributes" in opentelemetry-application-insights documentation for suitable replacements.

## [0.25.0] - 2023-03-26

Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ flate2 = "1"
http = "0.2"
once_cell = "1"
futures-util = { version = "0.3", default-features = false, optional = true }
opentelemetry = "0.22"
opentelemetry_sdk = "0.22.1"
opentelemetry-http = "0.11"
opentelemetry-semantic-conventions = "0.14"
opentelemetry = "0.23"
opentelemetry_sdk = "0.23"
opentelemetry-http = "0.12"
opentelemetry-semantic-conventions = "0.15"
reqwest = { version = "0.11", default-features = false, features = ["blocking"], optional = true }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand All @@ -56,8 +56,8 @@ doc-comment = "0.3.3"
env_logger = "0.11.2"
insta = "1.13.0"
isahc = "1.7.2"
opentelemetry_sdk = { version = "0.22.1", features = ["rt-async-std", "rt-tokio", "rt-tokio-current-thread"] }
opentelemetry-http = { version = "0.11", features = ["reqwest"] }
opentelemetry_sdk = { version = "0.23", features = ["rt-async-std", "rt-tokio", "rt-tokio-current-thread"] }
opentelemetry-http = { version = "0.12", features = ["reqwest"] }
opentelemetry-application-insights = { path = ".", features = ["live-metrics"] }
rand = "0.8.5"
regex = "1.5.5"
Expand Down
6 changes: 3 additions & 3 deletions examples/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn main() {
),
KeyValue::new(semcov::trace::SERVER_ADDRESS, "example.com"),
KeyValue::new(semcov::trace::SERVER_PORT, 8080),
KeyValue::new(semcov::trace::SERVER_SOCKET_ADDRESS, "10.1.2.4"),
KeyValue::new(semcov::trace::NETWORK_PEER_ADDRESS, "10.1.2.4"),
KeyValue::new(semcov::trace::HTTP_RESPONSE_STATUS_CODE, 200),
KeyValue::new(semcov::trace::ENDUSER_ID, "marry"),
])
Expand All @@ -101,7 +101,7 @@ fn main() {
KeyValue::new(semcov::trace::HTTP_ROUTE, "/hello/world"),
KeyValue::new(semcov::trace::HTTP_RESPONSE_STATUS_CODE, 200),
KeyValue::new(semcov::trace::CLIENT_ADDRESS, "10.1.2.3"),
KeyValue::new(semcov::trace::CLIENT_SOCKET_ADDRESS, "10.1.2.2"),
KeyValue::new(semcov::trace::NETWORK_PEER_ADDRESS, "10.1.2.2"),
KeyValue::new(semcov::trace::USER_AGENT_ORIGINAL, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"),
KeyValue::new(semcov::trace::ENDUSER_ID, "marry"),
]);
Expand All @@ -115,7 +115,7 @@ fn main() {
get_active_span(|span| {
let async_op_builder = server_tracer
.span_builder("async operation")
.with_links(vec![Link::new(span.span_context().clone(), Vec::new())]);
.with_links(vec![Link::new(span.span_context().clone(), Vec::new(), 0)]);
let async_op_context = Context::new();
let _span = server_tracer.build_with_context(async_op_builder, &async_op_context);
})
Expand Down
4 changes: 2 additions & 2 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mod tests {

#[test]
fn attrs_to_properties_encodes_links() {
let links = vec![Link::new(SpanContext::empty_context(), Vec::new())];
let links = vec![Link::new(SpanContext::empty_context(), Vec::new(), 0)];
let props = attrs_to_properties(&[], &Resource::empty(), &links).unwrap();
assert_eq!(props.len(), 1);
assert_eq!(
Expand All @@ -123,7 +123,7 @@ mod tests {
let input_len = MS_LINKS_MAX_LEN + 10;
let mut links = Vec::with_capacity(input_len);
for _ in 0..input_len {
links.push(Link::new(SpanContext::empty_context(), Vec::new()));
links.push(Link::new(SpanContext::empty_context(), Vec::new(), 0));
}
let props = attrs_to_properties(&[], &Resource::empty(), &links).unwrap();
assert_eq!(props.len(), 1);
Expand Down
65 changes: 33 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async fn main() {
//! | `db.statement` | Dependency Data |
//! | `http.request.header.host` | Dependency Target |
//! | `server.address` + `server.port` | Dependency Target |
//! | `server.socket.address` + `server.socket.port` | Dependency Target |
//! | `network.peer.address` + `network.peer.port` | Dependency Target |
//! | `db.name` | Dependency Target |
//! | `http.response.status_code` | Dependency Result code |
//! | `db.system` | Dependency Type |
Expand All @@ -229,7 +229,7 @@ async fn main() {
//! | `url.scheme` + `http.request.header.host` + `url.path` + `url.query` | Request Url |
//! | `url.scheme` + `server.address` + `server.port` + `url.path` + `url.query` | Request Url |
//! | `client.address` | Request Source |
//! | `client.socket.address` | Request Source |
//! | `network.peer.address` | Request Source |
//! | `http.response.status_code` | Request Response code |
//!
//! All other attributes are directly converted to custom properties.
Expand All @@ -240,24 +240,27 @@ async fn main() {
//!
//! The following deprecated attributes also work:
//!
//! | Attribute | Deprecated attribute |
//! | --------------------------- | --------------------------------------- |
//! | `http.request.method` | `http.method` |
//! | `http.request.header.host` | `http.host` |
//! | `http.response.status_code` | `http.status_code` |
//! | `url.full` | `http.url` |
//! | `url.scheme` | `http.scheme` |
//! | `url.path` + `url.query` | `http.target` |
//! | `client.address` | `http.client_ip` |
//! | `client.socket.address` | `net.sock.peer.addr` |
//! | `client.socket.address` | `net.peer.ip` |
//! | `server.address` | `net.peer.name` (for client spans) |
//! | `server.port` | `net.peer.port` (for client spans) |
//! | `server.socket.address` | `net.sock.peer.addr` (for client spans) |
//! | `server.socket.address` | `net.peer.ip` (for client spans) |
//! | `server.socket.port` | `net.sock.peer.port` (for client spans) |
//! | `server.address` | `net.host.name` (for server spans) |
//! | `server.port` | `net.host.port` (for server spans) |
//! | Attribute | Deprecated attribute |
//! | --------------------------- | ------------------------------------------ |
//! | `http.request.method` | `http.method` |
//! | `http.request.header.host` | `http.host` |
//! | `http.response.status_code` | `http.status_code` |
//! | `url.full` | `http.url` |
//! | `url.scheme` | `http.scheme` |
//! | `url.path` + `url.query` | `http.target` |
//! | `client.address` | `http.client_ip` |
//! | `network.peer.address` | `server.socket.address` (for client spans) |
//! | `network.peer.address` | `net.sock.peer.addr` (for client spans) |
//! | `network.peer.address` | `net.peer.ip` (for client spans) |
//! | `network.peer.port` | `server.socket.port` (for client spans) |
//! | `network.peer.port` | `net.sock.peer.port` (for client spans) |
//! | `network.peer.address` | `client.socket.address` (for server spans) |
//! | `network.peer.address` | `net.sock.peer.addr` (for server spans) |
//! | `network.peer.address` | `net.peer.ip` (for server spans) |
//! | `server.address` | `net.peer.name` (for client spans) |
//! | `server.port` | `net.peer.port` (for client spans) |
//! | `server.address` | `net.host.name` (for server spans) |
//! | `server.port` | `net.host.port` (for server spans) |
//!
//! ## Events
//!
Expand Down Expand Up @@ -642,12 +645,11 @@ where
/// that.
pub fn install_simple(self) -> Tracer {
let trace_provider = self.build_simple();
let tracer = trace_provider.versioned_tracer(
"opentelemetry-application-insights",
Some(env!("CARGO_PKG_VERSION")),
Some(semcov::SCHEMA_URL),
None,
);
let tracer = trace_provider
.tracer_builder("opentelemetry-application-insights")
.with_version(env!("CARGO_PKG_VERSION"))
.with_schema_url(semcov::SCHEMA_URL)
.build();
let _previous_provider = global::set_tracer_provider(trace_provider);
tracer
}
Expand All @@ -658,12 +660,11 @@ where
/// that.
pub fn install_batch<R: RuntimeChannel>(self, runtime: R) -> Tracer {
let trace_provider = self.build_batch(runtime);
let tracer = trace_provider.versioned_tracer(
"opentelemetry-application-insights",
Some(env!("CARGO_PKG_VERSION")),
Some(semcov::SCHEMA_URL),
None,
);
let tracer = trace_provider
.tracer_builder("opentelemetry-application-insights")
.with_version(env!("CARGO_PKG_VERSION"))
.with_schema_url(semcov::SCHEMA_URL)
.build();
let _previous_provider = global::set_tracer_provider(trace_provider);
tracer
}
Expand Down
28 changes: 25 additions & 3 deletions src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ const DEPRECATED_NET_PEER_IP: &str = "net.peer.ip";
/// `client.address`.
const DEPRECATED_HTTP_CLIENT_IP: &str = "http.client_ip";

/// Deprecated semantic convention key for client socket address.
///
/// Replaced in https://github.com/open-telemetry/opentelemetry-specification/pull/3713 with
/// `network.peer.address`.
const DEPRECATED_CLIENT_SOCKET_ADDRESS: &str = "client.socket.address";

/// Deprecated semantic convention key for server socket address.
///
/// Replaced in https://github.com/open-telemetry/opentelemetry-specification/pull/3713 with
/// `network.local.address`.
const DEPRECATED_SERVER_SOCKET_ADDRESS: &str = "server.socket.address";

/// Deprecated semantic convention key for server socket port.
///
/// Replaced in https://github.com/open-telemetry/opentelemetry-specification/pull/3713 with
/// `network.local.port`.
const DEPRECATED_SERVER_SOCKET_PORT: &str = "server.socket.port";

pub(crate) const EVENT_NAME_CUSTOM: &str = "ai.custom";
pub(crate) const EVENT_NAME_EXCEPTION: &str = "exception";

Expand Down Expand Up @@ -259,7 +277,9 @@ impl From<&SpanData> for RequestData {
data.source = Some(client_address.into());
} else if let Some(&client_ip) = attrs.get(DEPRECATED_HTTP_CLIENT_IP) {
data.source = Some(client_ip.into());
} else if let Some(&peer_addr) = attrs.get(semcov::trace::CLIENT_SOCKET_ADDRESS) {
} else if let Some(&peer_addr) = attrs.get(semcov::trace::NETWORK_PEER_ADDRESS) {
data.source = Some(peer_addr.into());
} else if let Some(&peer_addr) = attrs.get(DEPRECATED_CLIENT_SOCKET_ADDRESS) {
data.source = Some(peer_addr.into());
} else if let Some(&peer_addr) = attrs.get(
#[allow(deprecated)]
Expand Down Expand Up @@ -321,7 +341,8 @@ impl From<&SpanData> for RemoteDependencyData {
data.target = Some(host.into());
} else if let Some(&peer_name) = attrs
.get(semcov::trace::SERVER_ADDRESS)
.or_else(|| attrs.get(semcov::trace::SERVER_SOCKET_ADDRESS))
.or_else(|| attrs.get(semcov::trace::NETWORK_PEER_ADDRESS))
.or_else(|| attrs.get(DEPRECATED_SERVER_SOCKET_ADDRESS))
.or_else(|| {
attrs.get(
#[allow(deprecated)]
Expand All @@ -344,7 +365,8 @@ impl From<&SpanData> for RemoteDependencyData {
{
if let Some(peer_port) = attrs
.get(semcov::trace::SERVER_PORT)
.or_else(|| attrs.get(semcov::trace::SERVER_SOCKET_PORT))
.or_else(|| attrs.get(semcov::trace::NETWORK_PEER_PORT))
.or_else(|| attrs.get(DEPRECATED_SERVER_SOCKET_PORT))
.or_else(|| {
attrs.get(
#[allow(deprecated)]
Expand Down
6 changes: 3 additions & 3 deletions tests/http_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn traces_simple() {
),
KeyValue::new(semcov::trace::SERVER_ADDRESS, "example.com"),
KeyValue::new(semcov::trace::SERVER_PORT, 8080),
KeyValue::new(semcov::trace::SERVER_SOCKET_ADDRESS, "10.1.2.4"),
KeyValue::new(semcov::trace::NETWORK_PEER_ADDRESS, "10.1.2.4"),
KeyValue::new(semcov::trace::HTTP_RESPONSE_STATUS_CODE, 200),
KeyValue::new(semcov::trace::ENDUSER_ID, "marry"),
])
Expand All @@ -92,7 +92,7 @@ fn traces_simple() {
KeyValue::new(semcov::trace::HTTP_ROUTE, "/hello/world"),
KeyValue::new(semcov::trace::HTTP_RESPONSE_STATUS_CODE, 200),
KeyValue::new(semcov::trace::CLIENT_ADDRESS, "10.1.2.3"),
KeyValue::new(semcov::trace::CLIENT_SOCKET_ADDRESS, "10.1.2.2"),
KeyValue::new(semcov::trace::NETWORK_PEER_ADDRESS, "10.1.2.2"),
KeyValue::new(semcov::trace::USER_AGENT_ORIGINAL, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"),
KeyValue::new(semcov::trace::ENDUSER_ID,"marry"),
]);
Expand Down Expand Up @@ -120,7 +120,7 @@ fn traces_simple() {
span.record_error(error.as_ref());
let async_op_builder = server_tracer
.span_builder("async operation")
.with_links(vec![Link::new(span.span_context().clone(), Vec::new())]);
.with_links(vec![Link::new(span.span_context().clone(), Vec::new(), 0)]);
let async_op_context = Context::new();
let _span =
server_tracer.build_with_context(async_op_builder, &async_op_context);
Expand Down
20 changes: 10 additions & 10 deletions tests/snapshots/http_requests__live_metrics.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ x-ms-qps-role-name: unknown_service
"RoleName": "unknown_service",
"StreamId": "STRIPPED",
"Timestamp": "STRIPPED",
"Version": "opentelemetry:0.22.1"
"Version": "opentelemetry:0.23.0"
}


Expand Down Expand Up @@ -87,7 +87,7 @@ content-encoding: gzip
"RoleName": "unknown_service",
"StreamId": "STRIPPED",
"Timestamp": "STRIPPED",
"Version": "opentelemetry:0.22.1"
"Version": "opentelemetry:0.23.0"
}
]

Expand Down Expand Up @@ -144,7 +144,7 @@ content-encoding: gzip
"RoleName": "unknown_service",
"StreamId": "STRIPPED",
"Timestamp": "STRIPPED",
"Version": "opentelemetry:0.22.1"
"Version": "opentelemetry:0.23.0"
}
]

Expand All @@ -165,7 +165,7 @@ content-encoding: gzip
"service.name": "unknown_service",
"telemetry.sdk.language": "rust",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "0.22.1"
"telemetry.sdk.version": "0.23.0"
},
"resultCode": "2",
"success": false,
Expand All @@ -178,7 +178,7 @@ content-encoding: gzip
"sampleRate": 100.0,
"tags": {
"ai.cloud.role": "unknown_service",
"ai.internal.sdkVersion": "opentelemetry:0.22.1",
"ai.internal.sdkVersion": "opentelemetry:0.23.0",
"ai.operation.id": "STRIPPED"
},
"time": "STRIPPED"
Expand All @@ -201,7 +201,7 @@ content-encoding: gzip
"sampleRate": 100.0,
"tags": {
"ai.cloud.role": "unknown_service",
"ai.internal.sdkVersion": "opentelemetry:0.22.1",
"ai.internal.sdkVersion": "opentelemetry:0.23.0",
"ai.operation.id": "STRIPPED",
"ai.operation.parentId": "STRIPPED"
},
Expand All @@ -217,7 +217,7 @@ content-encoding: gzip
"service.name": "unknown_service",
"telemetry.sdk.language": "rust",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "0.22.1"
"telemetry.sdk.version": "0.23.0"
},
"responseCode": "2",
"success": false,
Expand All @@ -230,7 +230,7 @@ content-encoding: gzip
"sampleRate": 100.0,
"tags": {
"ai.cloud.role": "unknown_service",
"ai.internal.sdkVersion": "opentelemetry:0.22.1",
"ai.internal.sdkVersion": "opentelemetry:0.23.0",
"ai.operation.id": "STRIPPED"
},
"time": "STRIPPED"
Expand All @@ -245,7 +245,7 @@ content-encoding: gzip
"service.name": "unknown_service",
"telemetry.sdk.language": "rust",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "0.22.1"
"telemetry.sdk.version": "0.23.0"
},
"responseCode": "0",
"success": true,
Expand All @@ -258,7 +258,7 @@ content-encoding: gzip
"sampleRate": 100.0,
"tags": {
"ai.cloud.role": "unknown_service",
"ai.internal.sdkVersion": "opentelemetry:0.22.1",
"ai.internal.sdkVersion": "opentelemetry:0.23.0",
"ai.operation.id": "STRIPPED"
},
"time": "STRIPPED"
Expand Down
Loading
Loading