This repository was archived by the owner on Sep 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 250
AzureExporter not working with multiprocessingΒ #928
Copy link
Copy link
Open
Labels
Description
Describe your environment.
MacOS 10.14.6
Python 3.7.5
opencensus-ext-azure==1.0.4
opencensus-ext-requests==0.7.3
Steps to reproduce.
I have code that I want to monitor the dependency calls to Azure DevOps APIs. Our code is running multiprocessing using the Process
class. When the exporter is ran outside of multiprocessing, it sends telemetry to App Insights. When ran inside a multiprocessing Process, it doesn't. I added a callback to print the spandata and it doesn't get called when using Process
.
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from multiprocessing import Process, Pool, Queue
from base_insights import BaseInsights
from opencensus.common.runtime_context import RuntimeContext
class TestInsights:
def __init__(self):
self.tracer = BaseInsights.tracer
def process(self):
procs = []
organization_url = 'https://dev.azure.com/org'
credentials = BasicAuthentication('', '')
p1 = Process(target=self.my_loop, args=[organization_url, credentials])
p1.start()
p1.join()
def my_loop(self, organization_url, credentials, parent_span=None):
with self.tracer.span(name='TestLoopProcessThreadingInside'):
connection = Connection(base_url=organization_url, creds=credentials)
core_client = connection.clients.get_core_client()
org = core_client.get_project_collection("test")
TestInsights().process()
BaseInsights:
import os
from opencensus.ext.azure.trace_exporter import AzureExporter
from opencensus.trace import file_exporter
from opencensus.trace import config_integration
from opencensus.trace.samplers import ProbabilitySampler, AlwaysOnSampler
from opencensus.trace.tracer import Tracer
config_integration.trace_integrations(['requests'])
def singleton(cls):
return cls()
@singleton
class BaseInsights:
def __init__(self):
exporter = AzureExporter()
exporter.add_telemetry_processor(self.callback_function)
self.tracer = Tracer(exporter=exporter, sampler=AlwaysOnSampler())
def callback_function(self, envelope):
print(envelope)
What is the expected behavior?
Span data gets sent to Application Insights
What is the actual behavior?
Span data is not sent to Application Insights
jonasmiederer and mockodin