Open renan-alonkin opened 4 years ago
Hi @RenanAlonkin , Got the same issue on my docker webapp on Azure.
I have found a workaround, you can specify a storage_path when creating the AzureExporter object:
AzureExporter(
connection_string=f'InstrumentationKey={telemetry_key}',
storage_path=os.path.join(
os.path.expanduser('~'),
'.opencensus',
'.azure',
str(uuid.uuid4()),
os.path.basename(sys.argv[0]) or '.console',
)
)
It creates a folder with unique id per thread in the .azure folder (inspired from the default value of storage_path). I am not sure that uuid4 is a good solution but it seems to work just fine.
@RenanAlonkin Are you still wanting [#817] to be merged?
To be honest, no, I've created a workaround for my project. It does not look good, but it works. What jeremy posted looks like it will work, when I have time I will try to use it.
Using the azure ext for multiple threads/workers applications is a common pattern for web applications I think. I had no problem with the appinsights python sdk but it is deprecated now so I had to switch my app to opencensus for logging.
It would be nice to have a fix as more and more people are going to migrate to this library.
PS: if two azure exporters can live together on the same .azure folder maybe the solution of @RenanAlonkin is better but I did not spend enough time on the code to say
Specifying the storage path is the recommended approach for this issue. Closing.
Re-opening to implement a more permanent fix. See [#903].
Hi @lzchen , Is the storage path thread safe? Because as I understand it tmpdir+opencensus+ikey is constant (Maybe we will same the same issue)
@jeremy010203 Good question. Changing the directory was not for fixing this issue. The SDK simply does not throw an error now if the folder already exists.
Hello there,
I'm currently having the following problem: I have an API, and I want to use Opencensus to export my exceptions to Azure's Application Insights, but, when I try to run it inside of a Docker Container this problem appears:
Describe your environment.
3.8.0 (default, Nov 6 2019, 16:00:02)
Server: Version: 17.03.1-ce-rc1 API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: 3476dbf Built: Wed Mar 15 20:28:18 2017 OS/Arch: linux/amd64
@app.middleware("http") async def opencensus_tracking(request: Request, call_next):
Creates Tracer and Span (Request)