diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ddf229..13ffca69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Update samples + ([#281](https://github.com/microsoft/ApplicationInsights-Python/pull/281)) + ## [1.0.0b12](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b12) - 2023-05-05 - Remove most configuration for Public Preview diff --git a/azure-monitor-opentelemetry/samples/logging/correlated_logs.py b/azure-monitor-opentelemetry/samples/logging/correlated_logs.py index 43d77540..f47bdce4 100644 --- a/azure-monitor-opentelemetry/samples/logging/correlated_logs.py +++ b/azure-monitor-opentelemetry/samples/logging/correlated_logs.py @@ -9,9 +9,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor from opentelemetry import trace -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() logger = getLogger(__name__) tracer = trace.get_tracer(__name__) diff --git a/azure-monitor-opentelemetry/samples/logging/custom_properties.py b/azure-monitor-opentelemetry/samples/logging/custom_properties.py index 4cc9f19f..8d4c2c45 100644 --- a/azure-monitor-opentelemetry/samples/logging/custom_properties.py +++ b/azure-monitor-opentelemetry/samples/logging/custom_properties.py @@ -8,9 +8,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() logger = getLogger(__name__) logger.setLevel(DEBUG) diff --git a/azure-monitor-opentelemetry/samples/logging/exception_logs.py b/azure-monitor-opentelemetry/samples/logging/exception_logs.py index ff566adc..8761d4d7 100644 --- a/azure-monitor-opentelemetry/samples/logging/exception_logs.py +++ b/azure-monitor-opentelemetry/samples/logging/exception_logs.py @@ -8,9 +8,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() logger = getLogger(__name__) diff --git a/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py b/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py index a646100d..e7008701 100644 --- a/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py +++ b/azure-monitor-opentelemetry/samples/logging/logs_with_traces.py @@ -9,9 +9,7 @@ import flask from azure.monitor.opentelemetry import configure_azure_monitor -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() logger = getLogger(__name__) logger.setLevel(INFO) diff --git a/azure-monitor-opentelemetry/samples/logging/simple.py b/azure-monitor-opentelemetry/samples/logging/simple.py index 60085a1c..9786d35f 100644 --- a/azure-monitor-opentelemetry/samples/logging/simple.py +++ b/azure-monitor-opentelemetry/samples/logging/simple.py @@ -9,9 +9,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor from opentelemetry.sdk.resources import Resource, ResourceAttributes -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() logger = getLogger(__name__) diff --git a/azure-monitor-opentelemetry/samples/metrics/attributes.py b/azure-monitor-opentelemetry/samples/metrics/attributes.py index 95766db5..5060e721 100644 --- a/azure-monitor-opentelemetry/samples/metrics/attributes.py +++ b/azure-monitor-opentelemetry/samples/metrics/attributes.py @@ -5,9 +5,7 @@ from opentelemetry import metrics # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() attribute_set1 = {"key1": "val1"} attribute_set2 = {"key2": "val2"} diff --git a/azure-monitor-opentelemetry/samples/metrics/instruments.py b/azure-monitor-opentelemetry/samples/metrics/instruments.py index 663c54bf..ed4fb417 100644 --- a/azure-monitor-opentelemetry/samples/metrics/instruments.py +++ b/azure-monitor-opentelemetry/samples/metrics/instruments.py @@ -8,9 +8,7 @@ from opentelemetry.sdk.resources import Resource, ResourceAttributes # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() # Callback functions for observable instruments diff --git a/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py b/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py index ae7be561..d69784e8 100644 --- a/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py +++ b/azure-monitor-opentelemetry/samples/tracing/db_psycopg2.py @@ -7,9 +7,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() # Database calls using the psycopg2 library will be automatically captured cnx = psycopg2.connect(database="test", user="", password="") diff --git a/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py b/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py index eb5a25aa..02c2c9f0 100644 --- a/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py +++ b/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py @@ -8,9 +8,7 @@ from django.http import HttpResponse # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() # Requests sent to the django application will be automatically captured diff --git a/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py b/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py index 123890e0..96d5edd5 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_fastapi.py @@ -7,9 +7,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() app = fastapi.FastAPI() @@ -26,6 +24,7 @@ async def exception(): raise Exception("Hit an exception") +# Set the OTEL_PYTHON_EXCLUDE_URLS environment variable to "http://127.0.0.1:8000/exclude" # Telemetry from this endpoint will not be captured due to excluded_urls config above @app.get("/exclude") async def exclude(): diff --git a/azure-monitor-opentelemetry/samples/tracing/http_flask.py b/azure-monitor-opentelemetry/samples/tracing/http_flask.py index 06dc5c3c..a36478a4 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_flask.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_flask.py @@ -7,9 +7,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() app = flask.Flask(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/http_requests.py b/azure-monitor-opentelemetry/samples/tracing/http_requests.py index 26f94249..f252bb02 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_requests.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_requests.py @@ -12,15 +12,14 @@ logger = logging.getLogger(__name__) # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() tracer = trace.get_tracer(__name__) with tracer.start_as_current_span("Request parent span") as span: try: # Requests made using the requests library will be automatically captured response = requests.get("https://azure.microsoft.com/", timeout=5) + # Set the OTEL_PYTHON_EXCLUDE_URLS environment variable to "http://example.com" # This request will not be tracked due to the excluded_urls configuration response = requests.get("http://example.com", timeout=5) logger.warning("Request sent") diff --git a/azure-monitor-opentelemetry/samples/tracing/http_urllib.py b/azure-monitor-opentelemetry/samples/tracing/http_urllib.py index af260666..9b2568ef 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_urllib.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_urllib.py @@ -12,9 +12,7 @@ logger = logging.getLogger(__name__) # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() tracer = trace.get_tracer(__name__) with tracer.start_as_current_span("Request parent span") as span: diff --git a/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py b/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py index 92446121..82cfdeb3 100644 --- a/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py +++ b/azure-monitor-opentelemetry/samples/tracing/http_urllib3.py @@ -12,9 +12,7 @@ logger = logging.getLogger(__name__) # Configure Azure monitor collection telemetry pipeline -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() http = urllib3.PoolManager() diff --git a/azure-monitor-opentelemetry/samples/tracing/manual.py b/azure-monitor-opentelemetry/samples/tracing/manual.py index 47649f8d..7bbf1e50 100644 --- a/azure-monitor-opentelemetry/samples/tracing/manual.py +++ b/azure-monitor-opentelemetry/samples/tracing/manual.py @@ -7,9 +7,7 @@ from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor from sqlalchemy import create_engine, text -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() engine = create_engine("sqlite:///:memory:") # SQLAlchemy instrumentation is not officially supported by this package diff --git a/azure-monitor-opentelemetry/samples/tracing/sampling.py b/azure-monitor-opentelemetry/samples/tracing/sampling.py index a89bc4e6..23d996e2 100644 --- a/azure-monitor-opentelemetry/samples/tracing/sampling.py +++ b/azure-monitor-opentelemetry/samples/tracing/sampling.py @@ -11,9 +11,7 @@ # Sampling ratio of between 0 and 1 inclusive # 0.1 means approximately 10% of your traces are sent -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() tracer = trace.get_tracer(__name__) diff --git a/azure-monitor-opentelemetry/samples/tracing/simple.py b/azure-monitor-opentelemetry/samples/tracing/simple.py index ef7e0865..80a45ab1 100644 --- a/azure-monitor-opentelemetry/samples/tracing/simple.py +++ b/azure-monitor-opentelemetry/samples/tracing/simple.py @@ -8,9 +8,7 @@ from opentelemetry import trace from opentelemetry.sdk.resources import Resource, ResourceAttributes -configure_azure_monitor( - connection_string="", -) +configure_azure_monitor() tracer = trace.get_tracer(__name__)