|
2 | 2 |
|
3 | 3 | require_relative '../../tracing/configuration/ext' |
4 | 4 | require_relative '../../core/environment/variable_helpers' |
| 5 | +require_relative '../contrib/status_range_matcher' |
| 6 | +require_relative '../contrib/status_range_env_parser' |
5 | 7 | require_relative 'http' |
6 | 8 |
|
7 | 9 | module Datadog |
@@ -490,6 +492,46 @@ def self.extended(base) |
490 | 492 | o.env Tracing::Configuration::Ext::Distributed::ENV_X_DATADOG_TAGS_MAX_LENGTH |
491 | 493 | o.default 512 |
492 | 494 | end |
| 495 | + |
| 496 | + # HTTP error statuses configuration |
| 497 | + # @public_api |
| 498 | + settings :http_error_statuses do |
| 499 | + # Defines the range of status codes to be considered errors on http.server span kinds. |
| 500 | + # Once set, only the values within the specified range are considered errors. |
| 501 | + # |
| 502 | + # Format of env var: comma-separated list of values like 500,501,502 or ranges like 500-599 (e.g. `500,502,504-510`) |
| 503 | + # |
| 504 | + # @default `DD_TRACE_HTTP_SERVER_ERROR_STATUSES` environment variable, otherwise `500..599`. |
| 505 | + # @return [Tracing::Contrib::StatusRangeMatcher] |
| 506 | + option :server do |o| |
| 507 | + o.env Tracing::Configuration::Ext::HTTPErrorStatuses::ENV_SERVER_ERROR_STATUSES |
| 508 | + o.default 500..599 |
| 509 | + o.setter do |v| |
| 510 | + Tracing::Contrib::StatusRangeMatcher.new(v) if v |
| 511 | + end |
| 512 | + o.env_parser do |values| |
| 513 | + Tracing::Contrib::StatusRangeEnvParser.call(values) |
| 514 | + end |
| 515 | + end |
| 516 | + |
| 517 | + # Defines the range of status codes to be considered errors on http.client span kinds. |
| 518 | + # Once set, only the values within the specified range are considered errors. |
| 519 | + # |
| 520 | + # Format of env var: comma-separated list of values like 400,401,402 or ranges like 400-499 (e.g. `400,402,404-410`) |
| 521 | + # |
| 522 | + # @default `DD_TRACE_HTTP_CLIENT_ERROR_STATUSES` environment variable, otherwise `400..499`. |
| 523 | + # @return [Tracing::Contrib::StatusRangeMatcher] |
| 524 | + option :client do |o| |
| 525 | + o.env Tracing::Configuration::Ext::HTTPErrorStatuses::ENV_CLIENT_ERROR_STATUSES |
| 526 | + o.default 400..499 |
| 527 | + o.setter do |v| |
| 528 | + Tracing::Contrib::StatusRangeMatcher.new(v) if v |
| 529 | + end |
| 530 | + o.env_parser do |values| |
| 531 | + Tracing::Contrib::StatusRangeEnvParser.call(values) |
| 532 | + end |
| 533 | + end |
| 534 | + end |
493 | 535 | end |
494 | 536 | end |
495 | 537 | end |
|
0 commit comments