Skip to content

Commit 5a53e49

Browse files
authored
Merge pull request #281 from jeremydvoss/samples
Removed conn str and added exclude
2 parents d15c427 + dca628c commit 5a53e49

18 files changed

+22
-51
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Update samples
6+
([#281](https://github.com/microsoft/ApplicationInsights-Python/pull/281))
7+
58
## [1.0.0b12](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b12) - 2023-05-05
69

710
- Remove most configuration for Public Preview

azure-monitor-opentelemetry/samples/logging/correlated_logs.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from azure.monitor.opentelemetry import configure_azure_monitor
1010
from opentelemetry import trace
1111

12-
configure_azure_monitor(
13-
connection_string="<your-connection-string>",
14-
)
12+
configure_azure_monitor()
1513

1614
logger = getLogger(__name__)
1715
tracer = trace.get_tracer(__name__)

azure-monitor-opentelemetry/samples/logging/custom_properties.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
from azure.monitor.opentelemetry import configure_azure_monitor
1010

11-
configure_azure_monitor(
12-
connection_string="<your-connection-string>",
13-
)
11+
configure_azure_monitor()
1412

1513
logger = getLogger(__name__)
1614
logger.setLevel(DEBUG)

azure-monitor-opentelemetry/samples/logging/exception_logs.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
from azure.monitor.opentelemetry import configure_azure_monitor
1010

11-
configure_azure_monitor(
12-
connection_string="<your-connection-string>",
13-
)
11+
configure_azure_monitor()
1412

1513
logger = getLogger(__name__)
1614

azure-monitor-opentelemetry/samples/logging/logs_with_traces.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import flask
1010
from azure.monitor.opentelemetry import configure_azure_monitor
1111

12-
configure_azure_monitor(
13-
connection_string="<your-connection-string>",
14-
)
12+
configure_azure_monitor()
1513

1614
logger = getLogger(__name__)
1715
logger.setLevel(INFO)

azure-monitor-opentelemetry/samples/logging/simple.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from azure.monitor.opentelemetry import configure_azure_monitor
1010
from opentelemetry.sdk.resources import Resource, ResourceAttributes
1111

12-
configure_azure_monitor(
13-
connection_string="<your-connection-string>",
14-
)
12+
configure_azure_monitor()
1513

1614
logger = getLogger(__name__)
1715

azure-monitor-opentelemetry/samples/metrics/attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
from opentelemetry import metrics
66

77
# Configure Azure monitor collection telemetry pipeline
8-
configure_azure_monitor(
9-
connection_string="<your-connection-string>",
10-
)
8+
configure_azure_monitor()
119

1210
attribute_set1 = {"key1": "val1"}
1311
attribute_set2 = {"key2": "val2"}

azure-monitor-opentelemetry/samples/metrics/instruments.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from opentelemetry.sdk.resources import Resource, ResourceAttributes
99

1010
# Configure Azure monitor collection telemetry pipeline
11-
configure_azure_monitor(
12-
connection_string="<your-connection-string>",
13-
)
11+
configure_azure_monitor()
1412

1513

1614
# Callback functions for observable instruments

azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from azure.monitor.opentelemetry import configure_azure_monitor
88

99
# Configure Azure monitor collection telemetry pipeline
10-
configure_azure_monitor(
11-
connection_string="<your-connection-string>",
12-
)
10+
configure_azure_monitor()
1311

1412
# Database calls using the psycopg2 library will be automatically captured
1513
cnx = psycopg2.connect(database="test", user="<user>", password="<password>")

azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from django.http import HttpResponse
99

1010
# Configure Azure monitor collection telemetry pipeline
11-
configure_azure_monitor(
12-
connection_string="<your-connection-string>",
13-
)
11+
configure_azure_monitor()
1412

1513

1614
# Requests sent to the django application will be automatically captured

azure-monitor-opentelemetry/samples/tracing/http_fastapi.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from azure.monitor.opentelemetry import configure_azure_monitor
88

99
# Configure Azure monitor collection telemetry pipeline
10-
configure_azure_monitor(
11-
connection_string="<your-connection-string>",
12-
)
10+
configure_azure_monitor()
1311

1412
app = fastapi.FastAPI()
1513

@@ -26,6 +24,7 @@ async def exception():
2624
raise Exception("Hit an exception")
2725

2826

27+
# Set the OTEL_PYTHON_EXCLUDE_URLS environment variable to "http://127.0.0.1:8000/exclude"
2928
# Telemetry from this endpoint will not be captured due to excluded_urls config above
3029
@app.get("/exclude")
3130
async def exclude():

azure-monitor-opentelemetry/samples/tracing/http_flask.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from azure.monitor.opentelemetry import configure_azure_monitor
88

99
# Configure Azure monitor collection telemetry pipeline
10-
configure_azure_monitor(
11-
connection_string="<your-connection-string>",
12-
)
10+
configure_azure_monitor()
1311

1412
app = flask.Flask(__name__)
1513

azure-monitor-opentelemetry/samples/tracing/http_requests.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
logger = logging.getLogger(__name__)
1313

1414
# Configure Azure monitor collection telemetry pipeline
15-
configure_azure_monitor(
16-
connection_string="<your-connection-string>",
17-
)
15+
configure_azure_monitor()
1816

1917
tracer = trace.get_tracer(__name__)
2018
with tracer.start_as_current_span("Request parent span") as span:
2119
try:
2220
# Requests made using the requests library will be automatically captured
2321
response = requests.get("https://azure.microsoft.com/", timeout=5)
22+
# Set the OTEL_PYTHON_EXCLUDE_URLS environment variable to "http://example.com"
2423
# This request will not be tracked due to the excluded_urls configuration
2524
response = requests.get("http://example.com", timeout=5)
2625
logger.warning("Request sent")

azure-monitor-opentelemetry/samples/tracing/http_urllib.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
logger = logging.getLogger(__name__)
1313

1414
# Configure Azure monitor collection telemetry pipeline
15-
configure_azure_monitor(
16-
connection_string="<your-connection-string>",
17-
)
15+
configure_azure_monitor()
1816

1917
tracer = trace.get_tracer(__name__)
2018
with tracer.start_as_current_span("Request parent span") as span:

azure-monitor-opentelemetry/samples/tracing/http_urllib3.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
logger = logging.getLogger(__name__)
1313

1414
# Configure Azure monitor collection telemetry pipeline
15-
configure_azure_monitor(
16-
connection_string="<your-connection-string>",
17-
)
15+
configure_azure_monitor()
1816

1917
http = urllib3.PoolManager()
2018

azure-monitor-opentelemetry/samples/tracing/manual.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
88
from sqlalchemy import create_engine, text
99

10-
configure_azure_monitor(
11-
connection_string="<your-connection-string>",
12-
)
10+
configure_azure_monitor()
1311

1412
engine = create_engine("sqlite:///:memory:")
1513
# SQLAlchemy instrumentation is not officially supported by this package

azure-monitor-opentelemetry/samples/tracing/sampling.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
# Sampling ratio of between 0 and 1 inclusive
1212
# 0.1 means approximately 10% of your traces are sent
1313

14-
configure_azure_monitor(
15-
connection_string="<your-connection-string>",
16-
)
14+
configure_azure_monitor()
1715

1816
tracer = trace.get_tracer(__name__)
1917

azure-monitor-opentelemetry/samples/tracing/simple.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from opentelemetry import trace
99
from opentelemetry.sdk.resources import Resource, ResourceAttributes
1010

11-
configure_azure_monitor(
12-
connection_string="<your-connection-string>",
13-
)
11+
configure_azure_monitor()
1412

1513
tracer = trace.get_tracer(__name__)
1614

0 commit comments

Comments
 (0)