Skip to content

Commit 79177cd

Browse files
lzcheninirudebwoy
authored andcommitted
Add deprecation message for using instrumentation key (census-instrumentation#1118)
1 parent 552910e commit 79177cd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
([#1113](https://github.com/census-instrumentation/opencensus-python/pull/1113))
77
- Statsbeat bug fixes - do not log if statsbeat
88
([#1116](https://github.com/census-instrumentation/opencensus-python/pull/1116))
9+
- Add deprecation warning for explicitly using instrumentation key
10+
([#1118](https://github.com/census-instrumentation/opencensus-python/pull/1118))
911

1012
## 1.1.3
1113
Released 2022-03-03

contrib/opencensus-ext-azure/opencensus/ext/azure/common/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import logging
1516
import os
1617
import tempfile
1718

@@ -21,6 +22,8 @@
2122
INSTRUMENTATION_KEY = 'instrumentationkey'
2223
TEMPDIR_PREFIX = "opencensus-python-"
2324

25+
_logger = logging.getLogger(__name__)
26+
2427

2528
def process_options(options):
2629
# Connection string/ikey
@@ -30,6 +33,13 @@ def process_options(options):
3033
os.getenv('APPLICATIONINSIGHTS_CONNECTION_STRING'))
3134
env_ikey = os.getenv('APPINSIGHTS_INSTRUMENTATIONKEY')
3235

36+
# Deprecation note about explicit instrumentation key usage
37+
if (not code_cs and code_ikey) or (not env_cs and env_ikey):
38+
_logger.warning(
39+
"DeprecationWarning: Explicitly using instrumentation key is"
40+
"deprecated. Please use a connection string instead."
41+
)
42+
3343
# The priority of which value takes on the instrumentation key is:
3444
# 1. Key from explicitly passed in connection string
3545
# 2. Key from explicitly passed in instrumentation key

0 commit comments

Comments
 (0)