def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        connection_string = self.get_from_env(
            "APPLICATIONINSIGHTS_CONNECTION_STRING")

        # Create clients
        self.exporter = AzureMonitorTraceExporter.from_connection_string(
            connection_string)

        trace.set_tracer_provider(TracerProvider())
        tracer = trace.get_tracer(__name__)
        self.spans_list = []
        for _ in range(self.args.num_spans):
            with tracer.start_as_current_span(name="name") as span:
                self.spans_list.append(span)
import requests
from opentelemetry import trace
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

import flask
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

# The preferred tracer implementation must be set, as the opentelemetry-api
# defines the interface with a no-op implementation.
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)

exporter = AzureMonitorTraceExporter.from_connection_string(
    os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"])

# SpanExporter receives the spans and send them to the target location.
span_processor = BatchExportSpanProcessor(exporter)
trace.get_tracer_provider().add_span_processor(span_processor)

# Integrations are the glue that binds the OpenTelemetry API and the
# frameworks and libraries that are used together, automatically creating
# Spans and propagating context as appropriate.

# Enable instrumentation in the requests library.
RequestsInstrumentor().instrument()

app = flask.Flask(__name__)
# Enable instrumentation in the flask library.
FlaskInstrumentor().instrument_app(app)
Ejemplo n.º 3
0
        )
    )
)

logging.basicConfig(
    format="%(asctime)s %(levelname)s: %(message)s",
    level=logging.INFO,
    datefmt="%d-%b-%y %H:%M:%S",
)

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.addHandler(AzureLogHandler(connection_string="InstrumentationKey=<your instrumentation key"))

exporter = AzureMonitorTraceExporter.from_connection_string(
    "InstrumentationKey=<your instrumentation key>"
)

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
span_processor = BatchSpanProcessor(exporter)
trace.get_tracer_provider().add_span_processor(span_processor)


@ dataclass
class RunJob:

    @ staticmethod
    def animation():
        anime = "|/-\\"
        for i in range(10):