-
Notifications
You must be signed in to change notification settings - Fork 16
Svls 6036 respect timeouts #537
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,13 @@ use async_trait::async_trait; | |
| use std::str::FromStr; | ||
| use std::sync::Arc; | ||
| use tokio::sync::Mutex; | ||
| use tracing::{debug, error}; | ||
|
|
||
| use crate::config; | ||
| use crate::traces::stats_aggregator::StatsAggregator; | ||
| use datadog_trace_protobuf::pb; | ||
| use datadog_trace_utils::{config_utils::trace_stats_url, stats_utils}; | ||
| use ddcommon::Endpoint; | ||
| use tracing::{debug, error}; | ||
|
|
||
| #[async_trait] | ||
| pub trait StatsFlusher { | ||
|
|
@@ -49,7 +49,7 @@ impl StatsFlusher for ServerlessStatsFlusher { | |
| let endpoint = Endpoint { | ||
| url: hyper::Uri::from_str(&stats_url).expect("can't make URI from stats url, exiting"), | ||
| api_key: Some(api_key.clone().into()), | ||
| timeout_ms: Endpoint::DEFAULT_TIMEOUT, | ||
| timeout_ms: config.flush_timeout * 1_000, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if flush_timeout is not set? Do we have a default?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should, it's not an Option
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the |
||
| test_token: None, | ||
| }; | ||
|
|
||
|
|
@@ -60,16 +60,6 @@ impl StatsFlusher for ServerlessStatsFlusher { | |
| } | ||
| } | ||
|
|
||
| async fn flush(&self) { | ||
| let mut guard = self.aggregator.lock().await; | ||
|
|
||
| let mut stats = guard.get_batch(); | ||
| while !stats.is_empty() { | ||
| self.send(stats).await; | ||
|
|
||
| stats = guard.get_batch(); | ||
| } | ||
| } | ||
| async fn send(&self, stats: Vec<pb::ClientStatsPayload>) { | ||
| if stats.is_empty() { | ||
| return; | ||
|
|
@@ -88,17 +78,37 @@ impl StatsFlusher for ServerlessStatsFlusher { | |
| } | ||
| }; | ||
|
|
||
| match stats_utils::send_stats_payload( | ||
| let stats_url = trace_stats_url(&self.config.site); | ||
|
|
||
| let start = std::time::Instant::now(); | ||
|
|
||
| let resp = stats_utils::send_stats_payload( | ||
| serialized_stats_payload, | ||
| &self.endpoint, | ||
| &self.config.api_key, | ||
| ) | ||
| .await | ||
| { | ||
| .await; | ||
| let elapsed = start.elapsed(); | ||
| debug!( | ||
| "Stats request to {} took {}ms", | ||
| stats_url, | ||
| elapsed.as_millis() | ||
| ); | ||
| match resp { | ||
| Ok(()) => debug!("Successfully flushed stats"), | ||
| Err(e) => { | ||
| error!("Error sending stats: {e:?}"); | ||
| } | ||
| }; | ||
| } | ||
| async fn flush(&self) { | ||
| let mut guard = self.aggregator.lock().await; | ||
|
|
||
| let mut stats = guard.get_batch(); | ||
| while !stats.is_empty() { | ||
| self.send(stats).await; | ||
|
|
||
| stats = guard.get_batch(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,22 @@ | ||
| // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use crate::config; | ||
| use crate::tags::provider; | ||
| use crate::traces::span_pointers::{attach_span_pointers_to_meta, SpanPointer}; | ||
| use crate::traces::{ | ||
| AWS_XRAY_DAEMON_ADDRESS_URL_PREFIX, DNS_LOCAL_HOST_ADDRESS_URL_PREFIX, | ||
| DNS_NON_ROUTABLE_ADDRESS_URL_PREFIX, INVOCATION_SPAN_RESOURCE, LAMBDA_EXTENSION_URL_PREFIX, | ||
| LAMBDA_RUNTIME_URL_PREFIX, LAMBDA_STATSD_URL_PREFIX, | ||
| }; | ||
| use datadog_trace_obfuscation::obfuscate::obfuscate_span; | ||
| use datadog_trace_obfuscation::obfuscation_config; | ||
| use datadog_trace_protobuf::pb; | ||
| use datadog_trace_protobuf::pb::Span; | ||
| use datadog_trace_utils::config_utils::trace_intake_url; | ||
| use datadog_trace_utils::send_data::{RetryBackoffType, RetryStrategy}; | ||
| use datadog_trace_utils::trace_utils::SendData; | ||
| use datadog_trace_utils::trace_utils::{self}; | ||
| use datadog_trace_utils::tracer_header_tags; | ||
| use datadog_trace_utils::tracer_payload::{ | ||
| TraceChunkProcessor, TraceCollection::V07, TracerPayloadCollection, | ||
|
|
@@ -14,16 +25,6 @@ use ddcommon::Endpoint; | |
| use std::str::FromStr; | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::config; | ||
| use crate::traces::{ | ||
| AWS_XRAY_DAEMON_ADDRESS_URL_PREFIX, DNS_LOCAL_HOST_ADDRESS_URL_PREFIX, | ||
| DNS_NON_ROUTABLE_ADDRESS_URL_PREFIX, INVOCATION_SPAN_RESOURCE, LAMBDA_EXTENSION_URL_PREFIX, | ||
| LAMBDA_RUNTIME_URL_PREFIX, LAMBDA_STATSD_URL_PREFIX, | ||
| }; | ||
| use datadog_trace_obfuscation::obfuscate::obfuscate_span; | ||
| use datadog_trace_protobuf::pb::Span; | ||
| use datadog_trace_utils::trace_utils::{self, SendData}; | ||
|
|
||
| #[derive(Clone)] | ||
| #[allow(clippy::module_name_repetitions)] | ||
| pub struct ServerlessTraceProcessor { | ||
|
|
@@ -161,11 +162,18 @@ impl TraceProcessor for ServerlessTraceProcessor { | |
| let endpoint = Endpoint { | ||
| url: hyper::Uri::from_str(&intake_url).expect("can't parse trace intake URL, exiting"), | ||
| api_key: Some(self.resolved_api_key.clone().into()), | ||
| timeout_ms: Endpoint::DEFAULT_TIMEOUT, | ||
| timeout_ms: config.flush_timeout * 1_000, | ||
| test_token: None, | ||
| }; | ||
|
|
||
| SendData::new(body_size, payload, header_tags, &endpoint) | ||
| let mut send_data = SendData::new(body_size, payload, header_tags, &endpoint); | ||
| send_data.set_retry_strategy(RetryStrategy::new( | ||
| 1, | ||
| 100, | ||
|
Comment on lines
+171
to
+172
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magic numbers
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they come from defaults here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't you just create it once and clone it another place? |
||
| RetryBackoffType::Exponential, | ||
| None, | ||
| )); | ||
| send_data | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.