feat: explicit instrumentation opt-in with HARNESS_ env prefix#17
Open
shreyas70 wants to merge 1 commit into
Open
feat: explicit instrumentation opt-in with HARNESS_ env prefix#17shreyas70 wants to merge 1 commit into
shreyas70 wants to merge 1 commit into
Conversation
Instrumentation is now opt-in instead of opt-out. Nothing is instrumented
unless enabled via env flags:
- HARNESS_ENABLE_API: all non-AI instrumentation (HTTP servers/clients, gRPC,
DB, botocore, generic OTel contrib fallback)
- HARNESS_ENABLE_AI_{OPENAI,ANTHROPIC,LITELLM,GOOGLE_GENAI,MCP}: per-provider AI
Migrate the SDK env prefix to HARNESS_ while keeping HA_/AT_/TA_ as
backwards-compatible aliases (precedence HARNESS_ > HA_ > AT_ > TA_). The new
enable flags are strict HARNESS_-only with no legacy aliases, and the legacy
HA_GEN_AI_ENABLED master switch no longer controls instrumentation.
skip_libraries still takes precedence over enable flags.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes SDK instrumentation explicit opt-in (was opt-out) and migrates the env prefix to
HARNESS_with backwards compatibility.HARNESS_ENABLE_APIenables all non-AI instrumentation (HTTP servers/clients, gRPC, MySQL/PostgreSQL, botocore, generic OTel contrib fallback).HARNESS_ENABLE_AI_OPENAI,HARNESS_ENABLE_AI_ANTHROPIC,HARNESS_ENABLE_AI_LITELLM,HARNESS_ENABLE_AI_GOOGLE_GENAI,HARNESS_ENABLE_AI_MCP. Each enabled independently.true.skip_librariesstill works and takes precedence over enable flags.Env prefix migration (backwards compatible)
HARNESS_>HA_>AT_>TA_. ExistingHA_/AT_/TA_configs keep working.HARNESS_ENABLE_*opt-in flags are strictHARNESS_-only (no legacy aliases).HA_GEN_AI_ENABLEDmaster switch no longer controls instrumentation; use per-provider flags. Its removed per-call/instrument gates were pulled from the openai/anthropic/litellm/google_genai/mcp wrappers.Key changes
env.py:get_env_valueprecedence +is_env_var_present+is_harness_flag_enabled.instrumentation_definitions.py:API_LIBRARIES,AI_LIBRARY_ENV_FLAGS,is_library_enabled,is_api_instrumentation_enabled,any_ai_provider_enabled.agent.py:instrument()filters libraries by opt-in; generic contrib gated behindHARNESS_ENABLE_API.config/environment.py,config.py, litellm raw-capture, and console-exporter checks through the shared resolver.Test plan
test/instrumentation/test_opt_in_gating.py: default-off, API scope, per-provider independence, strict-true, no-legacy-alias,skip_librariesprecedence, Agent integration.environment_test.py: prefix precedence + legacy aliases.gen_ai_disabled_passthroughtests tolegacy_gen_ai_master_ignored; removed dead MCP disable tests; conftest/botocore updated for opt-in.Made with Cursor