honeyhive.tracer.processing.otlp_profiles
Environment-aware OTLP configuration profiles with full dynamic logic.
This module provides intelligent OTLP session configuration profiles that automatically optimize connection pooling based on detected environment characteristics, leveraging the existing resource detection from the tracer core.
Key Features: - Reuses existing environment detection from tracer core (no duplication) - Fully dynamic configuration - no hardcoded values - Resource-aware optimization based on actual system characteristics
- Environment-specific optimization patterns
- Intelligent scaling based on detected constraints
Architecture: - Leverages tracer._detect_container_environment_dynamically() - Leverages tracer._detect_cloud_environment_dynamically() - Uses dynamic logic throughout - all values calculated from environment
EnvironmentProfile
Bases: BaseModel
Environment-specific OTLP configuration profile.
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
name
class-attribute
instance-attribute
name: str = Field(
...,
description="Profile name for identification",
min_length=1,
max_length=100,
)
pool_connections
class-attribute
instance-attribute
pool_connections: int = Field(
...,
description="Number of connection pools to maintain",
ge=1,
le=50,
)
pool_maxsize
class-attribute
instance-attribute
pool_maxsize: int = Field(
...,
description="Maximum size of each connection pool",
ge=1,
le=100,
)
max_retries
class-attribute
instance-attribute
max_retries: int = Field(
...,
description="Maximum number of retry attempts",
ge=0,
le=10,
)
timeout
class-attribute
instance-attribute
timeout: float = Field(
...,
description="Request timeout in seconds",
gt=0.0,
le=300.0,
)
backoff_factor
class-attribute
instance-attribute
backoff_factor: float = Field(
...,
description="Backoff factor for retry delays",
ge=0.0,
le=5.0,
)
description
class-attribute
instance-attribute
description: str = Field(
"",
description="Human-readable profile description",
max_length=500,
)
pool_block
class-attribute
instance-attribute
pool_block: bool = Field(
False,
description="Whether connection pool should block when exhausted",
)
additional_config
class-attribute
instance-attribute
additional_config: Optional[Dict[str, Any]] = Field(
None, description="Additional configuration parameters"
)
validate_pool_maxsize
classmethod
Ensure pool_maxsize is at least as large as pool_connections.
Note: This validation logic is intentionally duplicated between EnvironmentProfile and OTLPSessionConfig classes as both need the same pool size validation constraints.
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
EnvironmentProfileManager
Manages environment-specific OTLP configuration profiles.
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
PROFILES
class-attribute
instance-attribute
PROFILES = {
"aws_lambda": EnvironmentProfile(
name="AWS Lambda",
description="Optimized for AWS Lambda serverless functions",
pool_connections=3,
pool_maxsize=8,
max_retries=2,
timeout=10.0,
backoff_factor=0.1,
additional_config={
"connection_reuse_priority": "critical",
"cold_start_optimization": True,
},
),
"kubernetes": EnvironmentProfile(
name="Kubernetes",
description="Optimized for Kubernetes orchestrated environments",
pool_connections=12,
pool_maxsize=20,
max_retries=4,
timeout=25.0,
backoff_factor=0.3,
additional_config={
"graceful_shutdown": True,
"scaling_aware": True,
},
),
"docker": EnvironmentProfile(
name="Docker Container",
description="Optimized for Docker containerized applications",
pool_connections=8,
pool_maxsize=15,
max_retries=3,
timeout=20.0,
backoff_factor=0.4,
additional_config={"container_optimized": True},
),
"gcp": EnvironmentProfile(
name="Google Cloud Platform",
description="Optimized for GCP environments",
pool_connections=10,
pool_maxsize=18,
max_retries=3,
timeout=22.0,
backoff_factor=0.35,
additional_config={"gcp_optimized": True},
),
"azure": EnvironmentProfile(
name="Microsoft Azure",
description="Optimized for Azure cloud environments",
pool_connections=10,
pool_maxsize=18,
max_retries=4,
timeout=24.0,
backoff_factor=0.4,
additional_config={"azure_optimized": True},
),
"aws_ec2": EnvironmentProfile(
name="AWS EC2",
description="Optimized for AWS EC2 instances",
pool_connections=15,
pool_maxsize=25,
max_retries=3,
timeout=30.0,
backoff_factor=0.3,
additional_config={
"aws_optimized": True,
"ec2_instance": True,
},
),
"standard": EnvironmentProfile(
name="Standard Environment",
description="Default profile for standard server environments",
pool_connections=10,
pool_maxsize=20,
max_retries=3,
timeout=30.0,
backoff_factor=0.5,
additional_config={"standard_environment": True},
),
}
get_optimal_profile
classmethod
get_optimal_profile(
tracer_instance: Optional[Any] = None,
) -> Tuple[EnvironmentProfile, Dict[str, Any]]
Get the optimal OTLP profile for the current environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracer_instance
|
Optional[Any]
|
Optional tracer instance for logging context |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[EnvironmentProfile, Dict[str, Any]]
|
Tuple of (selected_profile, environment_analysis) |
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
create_otlp_config_from_profile
classmethod
create_otlp_config_from_profile(
profile: EnvironmentProfile,
_tracer_instance: Optional[Any] = None,
**overrides: Any
) -> OTLPSessionConfig
Create an OTLPSessionConfig from an environment profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
EnvironmentProfile
|
Environment profile to use as base |
required |
tracer_instance
|
Optional tracer instance for context |
required | |
**overrides
|
Any
|
Explicit configuration overrides |
{}
|
Returns:
| Type | Description |
|---|---|
OTLPSessionConfig
|
Configured OTLPSessionConfig |
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
get_environment_optimized_config
get_environment_optimized_config(
tracer_instance: Optional[Any] = None, **overrides: Any
) -> OTLPSessionConfig
Get environment-optimized OTLP configuration.
This is the main entry point for getting an OTLP configuration that's automatically optimized for the current environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracer_instance
|
Optional[Any]
|
Optional tracer instance for context |
None
|
**overrides
|
Any
|
Explicit configuration overrides |
{}
|
Returns:
| Type | Description |
|---|---|
OTLPSessionConfig
|
Environment-optimized OTLPSessionConfig |
Source code in src/honeyhive/tracer/processing/otlp_profiles.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |